On 29.01.2011 20:15, Daniele Venzano wrote: > On Wed, Jan 26, 2011 at 07:38:24PM +0100, Oliver Hartkopp wrote: >> Hello Daniele, >> >> can you tell me, why you are setting the sockets to not loop sent CAN frames >> to the local host? > > I was porting an application that used a char-device CAN driver > to check if some IDs are present on the CAN. If those IDs are not > on the bus, it decides to be the master and sends the messages. > > With loopback the application was looping between the following > statuses: > - wonderful, no one is sending, I'm the master, I start sending > - oh no! someone else is the master, I stop sending
Ah, ok - that makes it clear. > BCM could do the receiving side with the RX_FILTER option very efficently, > simplyfing a lot of code at the same time, but I could not use that > without some major overhaul. That's life ... :-[ > The bigger picture is a big crane with two cabins, each with an HMI that > the operator can use. The HMIs can be in a "passive" or "active" status, > according to the master mechanism explained above and the status of > ignition keys. > The CAN architecture is far from optimal, but it works and the software > on the controllers is, after 7-8 years, very stable. > > A search for "reggiane mhc" on Google images will give you an idea of > the machine. Very very cool :-) But coming back to your original request. AFAICS your major problem is to distinguish whether a specific CAN ID was received from the 'real' CAN bus. Since 2.6.37 some new flags can be read via recvmsg(), see: http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.37.y.git;a=commitdiff;h=1e55659ce6ddb5247cee0b1f720d77a799902b85 The patch from this commit applies to older kernels very well also. So maybe it's the best to use the defaults (with loopback enabled), so that you can see the correct traffic on your Linux host, when running candump, etc. And if you need to check whether the received CAN traffic comes from outside your host, you can look at the message flags retrieved by recvmsg(). Would that help to meet your requirements? Regards, Oliver _______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
