On 21.03.2011 08:25, Jorge Fernandez Monteagudo wrote:

I would like to know how to set the filter masks in order to receive can
frames.

Hello Jorge,

please read

http://lxr.linux.no/#linux+v2.6.38/Documentation/networking/can.txt#L378

It tells that ...

A filter matches, when

   <received_can_id> & mask == can_id & mask

which is analogous to known CAN controllers hardware filter semantics.



In my current code I'm using only standard frames with 11 bits. The
three possible

situations for me are:

- Read frames from only an identifier: Then I set :

can_id = 0x1A4

can_mask = 0x00


No.

Setting the can_mask to '0' means that no bits are relevant for the filter and therefore you'll receive *anything* with this filter.

If you would like to filter only for 0x1A4 the filter mask must be 0x7FF and as you would like to have no RTR nor EFF frames the higher bits must be set:

can_mask = 0xC00007FF

which is the #defines (CAN_EFF_FLAG | CAN_RTR_FLAG | CAN_SFF_MASK) in can.h

Your other examples are flipped in the can_mask bits also.

Regards,
Oliver
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to