>> I commented IFF_ECHO and also commented the can_get/put_echo_skb, now, 
>> without enabling the loopback itself, the data is looped back.

> OK, enabling the hardware loopback does not make sense anyway. See 
below.

 I understood this behaviour. Loopback is enabled by default in 
net/can/raw.c:raw_init function.
http://lxr.linux.no/#linux+v2.6.34/net/can/raw.c#L270


> If you set IFF_ECHO, your driver *must* support local loopback by using
> can_get/put_echo_skb. It will not work otherwise. And again, forget the
> hardware loopback.
Thanks.  I understood this behaviour also . I saw the source code 
drivers/net/can/dev.c:can_put_echo_skb()
http://lxr.linux.no/#linux+v2.6.34/drivers/net/can/dev.c#L266



>How do you test if CAN_RAW_RECV_OWN_MSGS is working?
I am using the attached code.


#ip link set can0 up type can bitrate 125000
#candump can0 -> in one terminal 
#./can_rcvownmsg  ->in another terminal . This is the compiled output of 
sockcan.c.
socket s:3
ifindex: 3
bind successful
(not returning to console. Means it is struck at the recvfrom.)

Also, I expect the data to be received at can0 ("candump can0" terminal). 
But that is also not happening.

I can see from the net/can/raw.c,  recv_own_msgs, member of the struct 
raw_sock is set when setsockoptions(CAN_RAW_RECV_OWN_MSGS) is called.
But I think, it is not used to make the recv own msgs functionality. (I 
may be wrong. It may be done at a different place also.)
http://lxr.linux.no/#linux+v2.6.34/net/can/raw.c

Has anybody tested the recv own msgs functionality in linux-2.6.31? (Just 
for confirmation).

Thanks to Wolfgang for useful replies.


Thanks & Regards,
Navaneethan P 




Wolfgang Grandegger <[email protected]> 
06/02/2010 12:26 AM

To
Navaneethan P <[email protected]>
cc
Oliver Hartkopp <[email protected]>, [email protected]
Subject
Re: [Socketcan-users] linux-2.6.31 CAN driver - CAN_RAW_RECV_OWN_MSGS - 
receive own messages problem






On 06/01/2010 06:00 PM, Navaneethan P wrote:
>> Does it work if you *unset* IFF_ECHO and do *not* use 
> can_get/put_echo_skb?
> Case 1
> ------
> I commented IFF_ECHO and also commented the can_get/put_echo_skb, now, 
> without enabling the loopback itself, the data is looped back.

OK, enabling the hardware loopback does not make sense anyway. See below.

> 
> Case 2
> ----------
> If I enable IFF_ECHO, and commented can_get/put_echo_skb, now, data is 
> looped back when the loopback is on (#ip link set can0 type can loopback 

> on) but CAN_RAW_RECV_OWN_MSGS is not working.

If you set IFF_ECHO, your driver *must* support local loopback by using
can_get/put_echo_skb. It will not work otherwise. And again, forget the
hardware loopback.

> case 3
> ----------
> If I enable  IFF_ECHO and also enabled can_get/put_echo_skb, result is 
> same as case 1. without enabling the loopback data is looped back.

Good, that's what you want, right?

The hardware loopback enabled via "ip link set can0 type can loopback"
is only useful for testing and debugging. *No* message will go out to
the wire. It is not even available on for other CAN controllers.
Therefore, you should not mix it with the software loopbacks, which
serve a different purpose.

How do you test if CAN_RAW_RECV_OWN_MSGS is working?

Wolfgang.

Attachment: sockcan.c
Description: Binary data

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

Reply via email to