CAN dump utility Filter and mask id

40 Views Asked by At

Can anyone help me out with the difference between can_id and can_mask with an example i am trying to understand by going through the man pages still i am unable to get it. Kindly help me

1

There are 1 best solutions below

0
Geisterfahrer On

The ID is the element responsible for the identification of the devices in the CAN-Bus networks. Each device on the CAN bus must possess a unique ID to prevent data conflicts. Additionally, the ID indicates the priority during the communication phase, the lower the ID values, the higher its message priority.

For the method using CAN ID as identification, there is a previous ID List defined, in case the ID of the message matches the one in the List the message is accepted, otherwise ignored.

Before explaining the CAN mask, let me explain the concept of CAN filters.

The CAN Filter is responsible for specifying the types of messages a device should actively monitor and process.

Now, about the CAN mask, it functions like a selective tool, it defines which bits within a filter must match and which bits can be disregarded.

For example: Let's take as example a configuration in which the Filter is 0x55 and Mask is 0xDC

In binary, we have:

0b01010101 Filter.
0b11011100 Mask.

So let's perform an AND operation, first, the values which are 0's in the Mask will act as a non-care bit, in the result we put an X.

So we have the following result:

0b01X101XX

The X you can substitute as 1 or 0, therefore any value that fits this will be read by the device with that Filter and Mask selection.

For example, all IDs listed below will have their data read

0b01X101XX
0b01110101  -> 0x75
0b01010111  -> 0x57
0b01010101  -> 0x55
0b01010100  -> 0x54

To summarise, the CAN-Mask allows a wide range of ID selections, compared to the CAN-ID, whose List allows the addition of a very limited number of IDs.