Finally I got the answer. It was an understanding problem.

>CAN_RAW_RECV_OWN_MSG will *not* work, if CAN_RAW_LOOPBACK is disabled.,
>which is the case in your test program.
Yes. You are correct.

test case 1
-----------
If CAN_RAW_LOOPBACK (by default, it is set) is set, then sent data will be 
received on all sockets other than the sending socket.
I wrote a program to write the data to the socket and reads data from the 
same socket. lets call it as cantest (No socketoptions are set in creating 
the cantest).
I run candump in one terminal. (#candump can0)
I run the cantest in another terminal. (#./cantest)
Now, data is received on the candump terminal but cantest is not returning 
to the console (expected behaviour). Means, cantest is blocked at the read 
system call.
CAN_RAW_LOOPBACK will make the data to be received on all sockets other 
than the sending socket.

test case 2
-----------
I enabled CAN_RAW_RECV_OWN_MSGS option using setsockoptions call and 
compiled the code & created cantest.
Now, I run candump in one terminal.(#candump can0)
I run the cantest in another terminal. (#./cantest)
Now, data is received on the candump terminal. Also cantest is returning 
to the console (expected behaviour). It also receives the data.

It is perfectly working in the above said behaviour. Thanks to my customer 
who has given this info.

Thanks to all for your respectable time & Wolfgang for wonderful replies.


Thanks & Regards,
Navaneethan P 




Wolfgang Grandegger <[email protected]> 
06/02/2010 10:44 PM

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






On 06/02/2010 05:35 PM, Navaneethan P wrote:
>>> 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

CAN_RAW_RECV_OWN_MSG will *not* work, if CAN_RAW_LOOPBACK is disabled.,
which is the case in your test program.

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

I will do some testing later thihs week.

Wolfgang.

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

Reply via email to