RTCan missing frames

Johannes Holtz johannes.holtz at compador.de
Tue Feb 12 11:42:55 CET 2019


Am 11.02.19 um 17:46 schrieb Wolfgang Grandegger:
> Hello,
>
> Am 11.02.19 um 16:12 schrieb Johannes Holtz:
>> Am 11.02.19 um 16:07 schrieb Wolfgang Grandegger:
>>> Hello,
>>>
>>> at a first glance, your code looks good, but you are using the native
>>> api.. more inline...
>>>
>>> Am 11.02.19 um 14:13 schrieb Johannes Holtz:
>>>> Am 11.02.19 um 13:40 schrieb Wolfgang Grandegger:
>>>>> Hello,
>>>>>
>>>>> Am 11.02.19 um 12:55 schrieb Johannes Holtz:
>>>>>> Am 11.02.19 um 12:26 schrieb Wolfgang Grandegger:
>>>>>>> Hello,
>>>>>>>
>>>>>>> Am 11.02.19 um 10:16 schrieb Johannes Holtz via Xenomai:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> In my application i set up a RTCAN socket and a pair of rt-threads.
>>>>>>>> One
>>>>>>>> to read and one to write. Writing works perfectly and I receive
>>>>>>>> answers
>>>>>>>> in the initial phase of the program.
>>>>>>>>
>>>>>>>> In particular I send CANopen NMT messages out and receive the
>>>>>>>> responses
>>>>>>>> from the other Nodes in the Network.
>>>>>>>>
>>>>>>>> 2019-02-11 09:52:13.309[       500][    CAN TX] > NMT Node 0:0:
>>>>>>>> CAN ID 0x000 FC 0x0 DLC 2
>>>>>>>>             0       82 00
>>>>>>>> 2019-02-11 09:52:13.310[       503][    CAN RX] > NMT Error Control
>>>>>>>> Node
>>>>>>>> 0:8:
>>>>>>>> CAN ID 0x708 FC 0xe DLC 1
>>>>>>>>             0       00
>>>>>>>> 2019-02-11 09:52:13.311[       503][    CAN RX] > NMT Error Control
>>>>>>>> Node
>>>>>>>> 0:9:
>>>>>>>> CAN ID 0x709 FC 0xe DLC 1
>>>>>>>>             0       00
>>>>>>>> 2019-02-11 09:52:13.317[       509][    CAN RX] > NMT Error Control
>>>>>>>> Node
>>>>>>>> 0:3:
>>>>>>>> CAN ID 0x703 FC 0xe DLC 1
>>>>>>>>             0       00
>>>>>>>> 2019-02-11 09:52:13.317[       509][    CAN RX] > NMT Error Control
>>>>>>>> Node
>>>>>>>> 0:4:
>>>>>>>> CAN ID 0x704 FC 0xe DLC 1
>>>>>>>>             0       00
>>>>>>>> 2019-02-11 09:52:13.317[       509][    CAN RX] > NMT Error Control
>>>>>>>> Node
>>>>>>>> 0:5:
>>>>>>>> CAN ID 0x705 FC 0xe DLC 7
>>>>>>>>             0       00 06 07 00
>>>>>>>>             4       00 01 01
>>>>>>>> 2019-02-11 09:52:13.317[       509][    CAN RX] > NMT Node 0:0:
>>>>>>>> CAN ID 0x000 FC 0x0 DLC 3
>>>>>>>>             0       07 00 00
>>>>>>>> 2019-02-11 09:52:13.326[       519][    CAN RX] > TIME Node 0:1:
>>>>>>>> CAN ID 0x101 FC 0x2 DLC 0
>>>>>>>>
>>>>>>>> As you can see, I capture 7 frames. However, the RX count from
>>>>>>>> /proc/rtcan/devices is 10.
>>>>>>>>
>>>>>>>> If I send specific SDO requests to one of the node which have
>>>>>>>> answered I
>>>>>>>> don't capture a response but the RX count increases and rtcanrecv
>>>>>>>> program captures the correct response. Only my application's read
>>>>>>>> doesn't return.
>>> What do you mean with "doesn't return". rt_can_recv(MSG_DONTWAIT) should
>>> not block. What does it return?
>> It only returns EAGAIN like there is nothing to read.
> UI suggest to write a simple test program to demonstrate the issue. It
> should just open the socket and trying to receive messages... just the
> necessary stuff. First with a blocking recv() and then non-blocking.
>
> What hardware and software are you using (arch, board, linux, xenomai)?
>
> Wolfgang.

The source code is attached:

compiled with -I/opt/xenomai/include -D_GNU_SOURCE -D_REENTRANT 
-D__XENO__ -lrtdm -L/opt/xenomai/lib -lxenomai -lpthread -lrt -lnative

can frames sent by rtcansend

Test 1: blocking:

ID:0 DLC:2hex:  81 00       <-- NMT request
ID:709 DLC:1hex:  00        <-- answer node #9
ID:708 DLC:1hex:  00        <-- answer node #8
ID:703 DLC:1hex:  00        <-- answer node #3
ID:705 DLC:0hex:             <-- here it gets weird ! DLC == 0
ID:70400 DLC:1hex:  01
ID:70600 DLC:1hex:  01
ID:70100 DLC:1hex:  01
ID:70200 DLC:1hex:  01
ID:1010000 DLC:1hex:  08
ID:53220 DLC:124 out of bounds. abort.

Test 2: non blocking:

ID:0 DLC:2hex:  81 00    <-- NMT request
ID:709 DLC:1hex:  00     <-- answer node #9
ID:708 DLC:1hex:  00     <-- answer node #8
ID:703 DLC:1hex:  00     <-- answer node #3
ID:705 DLC:0hex:          <-- same issue DLC is 0
ID:70600 DLC:1hex:  01
ID:70400 DLC:1hex:  01
ID:70200 DLC:1hex:  01
ID:70100 DLC:1hex:  01
ID:1010000 DLC:1hex:  08
ID:53220 DLC:124 out of bounds. abort.


Also, I found another possible error source and I don't know if this 
error picture would corresponds to this.

However,  While reviewing all settings, I noticed that I made a mistake 
with the RXBUF_SIZE which is set to 8096 instead of 8192. Must have been 
asleep when writing this. I'm going to rebuild this module.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: can_recv.c
Type: text/x-csrc
Size: 6516 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20190212/3a4ad2e4/attachment.c>


More information about the Xenomai mailing list