AcceptanceFilter29Bit
This parameter restricts the reception of messages from a PCAN Channel by modifying the acceptance filter of its CAN chip,
using specific 29-bit code and mask values.
It allows the configuration of complex filter patterns, and it is intended for users with extended CAN knowledge. Note that the
calculation of mask and code patterns is not a trivial matter. For most applications the use of the
FilterMessages
for setting message reception ranges is more adequate.
The acceptance code and mask are coded together in a 64-bit value, each of them using 4 bytes. The acceptance code is stored at the
most significant bytes. Bitwise and shifting operations are needed to code and decode the values into and from a 64-bit unsigned integer
variable.
To set an acceptance code and mask denoting 11-bit CAN IDs, the parameter AcceptanceFilter11Bit must be used instead.
The SJA1000 CAN controller has only one acceptance filter for both, standard (11-bit) and extended (64-bit) IDs. When doing settings for 11-bit IDs, the acceptance
mask and code are internally shifted to the left as adaptation measure, which also causes possible reception of unwanted messages. For this reason, is also not
advisable to mix 11-bits and 29-bits filters.
An internal hardware reset is done each time the acceptance filter is modified. If other application is using the same device, its communication could be affected
in some scenarios.
For more information on the SJA1000 CAN controller acceptance filter, see
Philips Data Sheet SJA1000 Stand-alone CAN-controller.
It is available since PCAN-Basic version 4.2.0.
This parameter is read/write. It can be configured and retrieved.
This is a numeric value with a quad-word resolution. Since it contains two double-word values representing the acceptance code and mask, the maximum value range
accepted for this parameter is given by the limits of their internal values, which is a range between [0...4294967295]. This means, the maximum value of this parameter
as 64-bit value is 2305843005455597567 (hexadecimal 1FFFFFFF_1FFFFFFFh).
The default state of the receive filter is to receive all messages (Open). This
represents a default acceptance code of 0h and an acceptance mask of 1FFFFFFFh (00000000_1FFFFFFFh).
An automatic filter reset is done before registering the desired code and mask, if the filter state before using this parameter was
Open.
Get: The PCAN Channel must be initialized before using this parameter.
Set: The PCAN Channel must be initialized before using this parameter.
The following code shows how to modify the acceptance filter of a USB Channel using 29-bit code and mask values:
PcanChannel channelUsed = PcanChannel.Usb01;
if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
ulong acceptanceFilter = 0x00001000_00000500;
if (Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter) == PcanStatus.OK)
Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.");
else
Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01
If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
Dim acceptanceFilter As ULong = &H00001000_00000500
If Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter) = PcanStatus.OK Then
Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.")
Else
Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.")
End If
Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;
if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
UInt64 acceptanceFilter = 0x00001000'00000500;
if (Api::SetValue(channelUsed, PcanParameter::AcceptanceFilter29Bit, acceptanceFilter) == PcanStatus::OK)
Console::WriteLine("The acceptance filter for {0} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.", channelUsed);
else
Console::WriteLine("Error configuring the acceptance filter on channel {0}.", channelUsed);
Api::Uninitialize(channelUsed);
}