linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* vcan multithreaded problem testing
@ 2014-02-16 10:04 John Whitmore
  2014-02-16 11:16 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: John Whitmore @ 2014-02-16 10:04 UTC (permalink / raw)
  To: linux-can

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

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

* Re: vcan multithreaded problem testing
  2014-02-16 10:04 vcan multithreaded problem testing John Whitmore
@ 2014-02-16 11:16 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2014-02-16 11:16 UTC (permalink / raw)
  To: John Whitmore, linux-can

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

On 02/16/2014 11:04 AM, John Whitmore wrote:
> 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.

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

-- 
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   |


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

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

end of thread, other threads:[~2014-02-16 11:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-16 10:04 vcan multithreaded problem testing John Whitmore
2014-02-16 11:16 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).