All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] Extended CAN frame filtering
@ 2007-02-14 16:28 Jan Kiszka
  2007-02-15  8:34 ` [Xenomai-core] " Wolfgang Grandegger
  2007-02-16 12:37 ` Wolfgang Grandegger
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Kiszka @ 2007-02-14 16:28 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 2556 bytes --]

Hi Wolfgang,

unless I messed something up, the first patch aligns the implementation of
Socket-CAN filters in Xenomai with their current specification. Right now, if you
set a filter on a standard frame ID, you will also receive extended frames with
the same ID. In contrast, when the extended bit is set, only extended frames are
received, not standard frames with the same ID (that's again spec-conforming).

--- ksrc/drivers/can/rtcan_raw_filter.c	(Revision 2178)
+++ ksrc/drivers/can/rtcan_raw_filter.c	(Arbeitskopie)
@@ -55,11 +55,11 @@ void rtcan_raw_print_filter(struct rtcan
 static inline void rtcan_raw_mount_filter(can_filter_t *recv_filter,
 					  can_filter_t *filter)
 {
-   if (filter->can_id & CAN_EFF_FLAG)
-	recv_filter->can_mask = ((filter->can_mask & CAN_EFF_MASK) |
-				 CAN_EFF_FLAG);
+    if (filter->can_id & CAN_EFF_FLAG)
+	recv_filter->can_mask = filter->can_mask & CAN_EFF_MASK;
     else
-	recv_filter->can_mask = (filter->can_mask & CAN_SFF_MASK);
+	recv_filter->can_mask = filter->can_mask & CAN_SFF_MASK;
+    recv_filter->can_mask |= CAN_EFF_FLAG;
 
     recv_filter->can_id = filter->can_id & recv_filter->can_mask;
 } 


However, I wonder if this behaviour is useful. You can now either set a filter
for extended frames or standard frame, not for both frame type, just varying on
the ID length. If we consider EFF just as another bit of the CAN ID, we could
take this into account for the mask:

--- ksrc/drivers/can/rtcan_raw_filter.c	(Revision 2178)
+++ ksrc/drivers/can/rtcan_raw_filter.c	(Arbeitskopie)
@@ -55,11 +55,12 @@ void rtcan_raw_print_filter(struct rtcan
 static inline void rtcan_raw_mount_filter(can_filter_t *recv_filter,
 					  can_filter_t *filter)
 {
-   if (filter->can_id & CAN_EFF_FLAG)
-	recv_filter->can_mask = ((filter->can_mask & CAN_EFF_MASK) |
-				 CAN_EFF_FLAG);
+    if (filter->can_id & CAN_EFF_FLAG)
+	recv_filter->can_mask = filter->can_mask &
+				(CAN_EFF_MASK | CAN_EFF_FLAG);
     else
-	recv_filter->can_mask = (filter->can_mask & CAN_SFF_MASK);
+	recv_filter->can_mask = filter->can_mask &
+				(CAN_SFF_MASK | CAN_EFF_FLAG);
 
     recv_filter->can_id = filter->can_id & recv_filter->can_mask;
 }


Note: this alternative patch would also require a patch to rtdm/rtcan.h.

Actually, the second variant was what I intuitively expected. What is the
behaviour of non-RT Socket-CAN here?

Jan


PS: A few lines above those hunks is still a "#if 0" code block. Either make
this configurable or please clean it up.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-02-18 19:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 16:28 [Xenomai-core] Extended CAN frame filtering Jan Kiszka
2007-02-15  8:34 ` [Xenomai-core] " Wolfgang Grandegger
2007-02-16 12:37 ` Wolfgang Grandegger
2007-02-17 14:31   ` Wolfgang Grandegger
2007-02-17 17:55     ` Jan Kiszka
2007-02-17 18:20       ` Wolfgang Grandegger
2007-02-17 18:54         ` Jan Kiszka
2007-02-17 20:49           ` Wolfgang Grandegger
2007-02-18 18:18             ` Jan Kiszka
2007-02-18 19:49               ` Wolfgang Grandegger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.