Skip to content

examples/lely: Fix lost and CAN FD frames in the char backend - #4084

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
raiden00pl:lely-chardev-min
Nov 19, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
raiden00pl:lely-chardev-min

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

Summary

Two fixes in candev_char.c of lely_master and lely_slave:

  • read() on the CAN character driver copies every queued message that fits
    into the buffer, but *_candev_recv() decodes only the first one, so e.g.
    the second of two back-to-back NMT commands was lost. Set
    CANIOC_SET_MSGALIGN to 0, so read() returns exactly one message.
  • *_candev_send() fills a struct can_msg_s on the stack but does not set
    ch_edl, ch_brs and ch_esi. With CONFIG_CAN_FD this stack garbage made the
    driver send some frames as CAN FD frames. Zero the header first.

Impact

Lely CANopen over the CAN character driver no longer loses frames that
arrive together and sends only classic CAN frames.

Testing

sim and qemu-intel64 (CAN character driver) against a host CANopen master:
back-to-back NMT start/stop now leaves the slave STOPPED, all frames sent by
coslave are classic CAN frames; boot, NMT, SDO, PDO, heartbeat, time and
master tests unchanged.

read() on the CAN character driver copies every queued message that
fits into the buffer, but *_candev_recv() decodes only the first one,
so e.g. the second of two back-to-back NMT commands was lost.  Set
CANIOC_SET_MSGALIGN to 0, so read() returns exactly one message.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
*_candev_send() fills a struct can_msg_s on the stack but does not set
ch_edl, ch_brs and ch_esi.  With CONFIG_CAN_FD this stack garbage made
the driver send some frames as CAN FD frames.  Zero the header first.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @raiden00pl :-)

CI fails due to other pr gsnsspps ?

@xiaoxiang781216
xiaoxiang781216 merged commit 5e0f069 into apache:master Nov 19, 2026
32 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants