All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: Johannes Holtz <johannes.holtz@compador.de>, xenomai@xenomai.org
Subject: Re: RTCan missing frames
Date: Wed, 13 Feb 2019 11:20:33 +0100	[thread overview]
Message-ID: <2daab8d2-f785-8c10-5a8f-2f26f53346ff@grandegger.com> (raw)
In-Reply-To: <086c1e2a-04a2-16b3-5269-6e10fe315fd7@compador.de>

Am 13.02.19 um 10:37 schrieb Johannes Holtz:
> Am 12.02.19 um 18:53 schrieb Wolfgang Grandegger:
>> Am 12.02.19 um 18:24 schrieb Johannes Holtz:
>>> Am 12.02.19 um 18:05 schrieb Wolfgang Grandegger:
>>>> Am 12.02.19 um 16:19 schrieb Johannes Holtz:
>>>>> Am 12.02.19 um 16:00 schrieb Wolfgang Grandegger:
>>>>>> Hello Johannes,
>>>>>>
>>>>>> Am 12.02.19 um 15:38 schrieb Johannes Holtz:
>>>>>>> Am 12.02.19 um 12:24 schrieb Wolfgang Grandegger:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> Am 12.02.19 um 11:42 schrieb Johannes Holtz:
>>>>>>>>> Am 11.02.19 um 17:46 schrieb Wolfgang Grandegger:
>>>>>>>> ... snip ...
>>>>>>>>>> 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
>>>>>>>> This means that you can receive messages from the CAN bus.
>>>>>>>>
>>>>>>>>> ID:53220 DLC:124 out of bounds. abort.
>>>>>>>> But that's wired.
>>>>>>>>
>>>>>>>>> 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.
>>>>>>>> Looks identical.
>>>>>>>>
>>>>>>>>> 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.
>>>>>>>> Let's try to understand why rt_dev_recv() does return bogus dlc.
>>>>>>>>
>>>>>>>> What hardware and software are you using (arch, board, can
>>>>>>>> controlelr,
>>>>>>>> linux, xenomai)?
>>>>>>>>
>>>>>>>> Wolfgang.
>>>>>>> I modified the program a little to send it's own requests via one
>>>>>>> single
>>>>>>> socket. The output look like this.
>>>>>>>
>>>>>>> send succeeded
>>>>>>> ID:708 DLC:1hex:  00
>>>>>>> ID:709 DLC:1hex:  00
>>>>>>> ID:703 DLC:1hex:  00
>>>>>>> ID:706 DLC:1hex:  00
>>>>>>> ID:705 DLC:7hex:  00 00 01 01 00 09 07
>>>>>>> send succeeded
>>>>>>> send succeeded
>>>>>>> send succeeded
>>>>>>> send succeeded
>>>>>>> send succeeded
>>>>>>>
>>>>>>> And a parallel rtcanrecv output  like this:
>>>>>>>
>>>>>>> root@machinectrl:~# rtcanrecv rtcan0
>>>>>>> #0: (1) <0x000> [2] 81 00
>>>>>>> #1: (1) <0x708> [1] 00
>>>>>>> #2: (1) <0x709> [1] 00
>>>>>>> #3: (1) <0x703> [1] 00
>>>>>>> #4: (0) <0x706> [0]
>>>>>>> #5: (0) <0x500> [1] 01
>>>>>>> #6: (0) <0x400> [1] 01
>>>>>>> #7: (0) <0x100> [1] 01
>>>>>>> #8: (0) <0x200> [1] 01
>>>>>>> #9: (0) <0x000> [1] 08
>>>>>>> #10: (24) <0x220> [124] 00 00 82 00 00 00 01 08 01 00 00 00 f0 84
>>>>>>> 04 08
>>>>>> Why is "addr.can_ifindex = 24"? Something is broken in you build.
>>>>> In the xenomai build? how do I find out what? it all compiled well.
>>>>>
>>>>> I patched the driver  before building tkernel with
>>>>> 0001-rtcan-ems_pci-driver-update-to-support-more-devices.patch.gz
>>>> Can you show me that patch.
>>> See attachment.
>>>>> I used the ipipe patch from the stable release,
>>>>>
>>>>> and then build it normally.
>>>>>
>>>>> Might the RX buf size that I changed a problem?
>>>> What exactly did you change? I think "rtcanrecv" does not use it.
>>>>
>>>> Wolfgang
>>> The kernel option CONFIG_XENO_DRIVERS_CAN_RXBUF_SIZE I at first I set it
>>> to a wrong value  8096 but eve after I changed it to 8192 it didnt
>>> change anythingand now i set it back to 1024 with no improvement either.
>> Ah, a value of 8096 does make trouble, e.g. with expression like the
>> following:
>>
>>          sock->recv_tail = (sock->recv_tail + cpy_size) &
>>              (RTCAN_RXBUF_SIZE - 1);
>>
>> Could you please make a *clean* rebuild from scratch with a value 2^N,
>> either 8192 or 1024.
>>
>> Wolfgang.
> 
> Building the complete Kernel anew did the trick. Don't really understand
> why re-building (and installing) just the module didn't work.
> 
> Anyway, I'm happy that it works now. So, as a takeaway: Don't mess with
> the CAN_RXBUF_SIZE.

Yes, but also the code should check as much as possible... it's normal
that the human being makes mistakes.

Wolfgang


      reply	other threads:[~2019-02-13 10:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11  9:16 RTCan missing frames Johannes Holtz
2019-02-11 11:14 ` Philippe Gerum
2019-02-11 11:53   ` Johannes Holtz
2019-02-11 14:18   ` Johannes Holtz
     [not found] ` <5f653b5a-e82f-ce42-c8c6-3fa05ccce53d@grandegger.com>
2019-02-11 11:55   ` Johannes Holtz
2019-02-11 12:40     ` Wolfgang Grandegger
2019-02-11 13:13       ` Johannes Holtz
2019-02-11 15:06         ` Wolfgang Grandegger
2019-02-11 15:12           ` Johannes Holtz
2019-02-11 16:46             ` Wolfgang Grandegger
2019-02-12 10:42               ` Johannes Holtz
2019-02-12 11:24                 ` Wolfgang Grandegger
2019-02-12 11:35                   ` Johannes Holtz
2019-02-12 14:38                   ` Johannes Holtz
2019-02-12 15:00                     ` Wolfgang Grandegger
2019-02-12 15:19                       ` Johannes Holtz
2019-02-12 17:05                         ` Wolfgang Grandegger
2019-02-12 17:24                           ` Johannes Holtz
2019-02-12 17:53                             ` Wolfgang Grandegger
2019-02-12 18:14                               ` Steve Freyder
2019-02-12 18:20                                 ` Wolfgang Grandegger
2019-02-13  9:37                               ` Johannes Holtz
2019-02-13 10:20                                 ` Wolfgang Grandegger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2daab8d2-f785-8c10-5a8f-2f26f53346ff@grandegger.com \
    --to=wg@grandegger.com \
    --cc=johannes.holtz@compador.de \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.