MessageFilter

This parameter causes a modification of the acceptance filter of the CAN chip of a PCAN Channel, thus allowing it to receive messages or not. It can be used for switching the acceptance of messages temporarily, for example, to avoid receiving messages during a defined amount of time.

  Caution

An internal hardware reset is carried out when the acceptance filter is modified. If other application is using the same device, its communication could be affected in some scenarios.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter accepts values of type ParameterValueFilter. In a setting operation, this parameter can be opened or closed. In a get operation, a value indicating that the filter was customized can also be retrieved.

Default Value

The default state of the filter is to receive all messages (Open). A PCAN Channel starts receiving messages immediately after it is initialized.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to close the acceptance filter of a USB Channel:

C#
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.MessageFilter, ParameterValue.Filter.Close) == PcanStatus.OK)
        Console.WriteLine($"The acceptance filter of {channelUsed} was successfully closed.");
    else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}

See Also