
— 16 —
A filter consists of a header, which begins with the keyword
match()
with parameters defining the incoming
CAN frames "match criteria" followed by a data processing subprogram in specially created programming
language.
The order of the filters is significant. Device will match received messages against the filters in an exact
same order they are specified in the program. After a successful match, the message will be processed by
corresponding filter subprogram and will not be processed by further filters.
In case there is no match with any filters, the Device follows the forwarding settings. If message forwarding is
enabled for the interface (by default, yes), the given message will be sent to the other CAN interface. If disabled,
the message will be discarded.
Looking ahead, we explain the operation of this program.
The program in
example 1
above has only two forwarding settings and three filters.
First, we have two default forwarding rules — those will be applied to messages for which no corresponding
match()
subprogram was defined. FW_CAN1_TO_CAN2=ON instructs the Device to forward all messages
received on CAN1 interface to CAN2 interface. FW_CAN2_TO_CAN1=OFF instructs the Device to not forward
(drop) all messages received on CAN2 interface to CAN1 interface.
1st filter will intercept PGN 0x1FD06 received on CAN2 interface — from any device address, however, as its
subprogram is empty, this PGN will be dropped.
2nd filter will intercept any PGN received on CAN2 interface — but only from device with address 0x10 —
and as the subprogram dictates, it will send the message to CAN 1 interface. As PGN 0x1FD06 was already
processed by the 1st filter, forwarding is disabled via FW_CAN2_TO_CAN1=OFF and there are no more filters
for CAN2, the net result will be that all PGNs from CAN2 device 0x10 will be forwarded to CAN2, except
0x1FD06.
3rd filter will intercept all PGNs received on CAN1 interface from device with address 0x20 and block
it. As we have CAN1 -> CAN2 forwarding enabled via FW_CAN1_TO_CAN2=ON, the net result will be
that all PGNs from CAN1 will be forwarded to CAN2, except those from device 0x20.