vcan multithreaded problem testing
Hello all, I'll try keep this short. I'm using vcan to test code I'm porting from my embedded hardware. My embedded code has a simple dispatcher which process all messages received from the Network. Higher layers of the Application register an interest in certain CAN ids or ranges.
I don't need this dispatcher as Socket CAN filters already so in porting my application the higher layers now simply create a new linux thread and socket to listen for CAN Frames that they have an interest in.
My problem is that in testing with vcan if my core process thead sends a CAN id which a child thread is filtering on then the child thread receives the message. I've looked at vcan code and it simply consumes the sent frames back into the linux networking stack.
At present a single process will not receive a CAN Frame which is sends but it's child threads will recive the frame. Is there a way to restrict this? I might have to wait until I get back to Hardware and test there but it would be very handy to be able to use vcan.
John
Marc Kleine-Budde
maintainerQuoted 14 lines · John Whitmore
Hello all, I'll try keep this short. I'm using vcan to test code I'm porting from my embedded hardware. My embedded code has a simple dispatcher which process all messages received from the Network. Higher layers of the Application register an interest in certain CAN ids or ranges.
I don't need this dispatcher as Socket CAN filters already so in porting my application the higher layers now simply create a new linux thread and socket to listen for CAN Frames that they have an interest in.
My problem is that in testing with vcan if my core process thead sends a CAN id which a child thread is filtering on then the child thread receives the message. I've looked at vcan code and it simply consumes the sent frames back into the linux networking stack.
Quoted 4 lines
At present a single process will not receive a CAN Frame which is sends but it's child threads will recive the frame. Is there a way to restrict this? I might have to wait until I get back to Hardware and test there but it would be very handy to be able to use vcan.
The CAN stack doesn't care about thread or processes, it's all about sockets.
By default a socket doesn't receive the CAN frame it sends. When a CAN frame is successfully send, by default all other sockets receive the locally created CAN frames, too. You can change both defaults. Have a look at the can.txt documentation in the Linux kernel:
http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L184
http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L502
http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L513
Feel free to ask, if you need more information.
cheers,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |