Re: [Question] Sending CAN error frames

From
Jimmy Assarsson <hidden>
Date
2021-02-02 10:00:52
Reply to
Vincent MAILHOL, 2021-02-02
On 2021-02-02 01:22, Vincent MAILHOL wrote> On Tue. 2 Feb 2021 at 00:41, Jimmy Assarsson [off-list ref] wrote:
quoted
On 2021-02-01 15:19, Vincent MAILHOL wrote:
quoted
On Mon. 1 Feb 2021 at 05:42, Jimmy Assarsson [off-list ref] wrote:
...
quoted
quoted
There are two forms of error flags:
    - The active error flag: 6 consecutive dominant bits
    - The passive error flag: 6 consecutive recessive bits
Can it generate both or only one of these? Is it generated as
soon as the device receives the command or is it generated at a
predefined timing (e.g. beginning of the frame)?
It can only generate the active error flag.
It will generate an error frame on the bus as soon as the bus is idle.

$ sudo ip link set can4 type can bitrate 100000
$ sudo ip link set can5 type can bitrate 100000
$ sudo ip link set can4 up
$ sudo ip link set can5 up
$ ./candump -c -ta -H -d -e -x can4,#FFFFFFFF &
[1] 177884
$ ./cansend can5 20000000#
   (0000000084.786201)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 01   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{1}}
$ ./cansend can5 20000123#0011223344556677
   (0000000086.798898)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 02   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{2}}
$ ./cansend can5 20000000#
   (0000000087.385292)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 03   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{3}}
$ ./cansend can5 20000000#
   (0000000087.911860)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 04   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{4}}
$ ./cansend can5 20000000#
   (0000000088.404890)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 05   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{5}}
$ ./cansend can5 005#FF.12.20
   (0000000093.061655)  can4  RX - -  005   [3]  FF 12 20
$ ./cansend can5 005#FF.12.21
   (0000000094.667557)  can4  RX - -  005   [3]  FF 12 21
$ ./cansend can5 005#FF.12.22
   (0000000095.617019)  can4  RX - -  005   [3]  FF 12 22
$ ./cansend can5 20000000#
   (0000000097.883071)  can4  RX - -  20000080   [8]  00 00 00 00 00 00
00 03   ERRORFRAME
         bus-error
         error-counter-tx-rx{{0}{3}}
Thanks for the example, things are now clear.

So the error flag always increments the RX counter even if you
are the transmitter.
To be clear, the printouts (from candump) are from the interface
that is not transmitting the error frame (can4). I transmit error
frames with can5. However, the transmitting interface (can5) will
also detect and report the error frame (and increase the rx error
counter). The only difference in the above example would be that the rx
error counter wont decrement when can5 successfully transmits a CAN
frame.
Sorry for the confusion.

Regards,
jimmy
Thread (22 messages) 22 messages, 6 authors, last reply 2021-02-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help