Explanation of the code and mask format used by the canAccept(), canSetAcceptanceFilter(), and canObjBufSetFilter() functions:
A binary 1 in a mask means "the corresponding bit in the code is relevant"
A binary 0 in a mask means "the corresponding bit in the code is not relevant"
A relevant binary 1 in a code means "the corresponding bit in the identifier must be 1"
A relevant binary 0 in a code means "the corresponding bit in the identifier must be 0"
In other words, the message is accepted if ((code XOR id) AND mask) == 0.
- Note:
- You can set the extended code and mask only on CAN boards that support extended identifiers.
-
Not all CAN boards support different masks for standard and extended CAN identifiers.
-
If you want to remove a filter, call canAccept with the mask set to 0.
-
On some boards the acceptance filtering is done by the CAN hardware; on other boards (typically those with an embedded CPU,) the acceptance filtering is done by software. canAccept behaves in the same way for all boards, however.
-
canSetAcceptanceFilter and canAccept both serve the same purpose but the former can set the code and mask in just one call.