Repository navigation
examples/lely: Fix lost and CAN FD frames in the char backend - #4084
Merged
Merged
Conversation
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
approved these changes
Nov 19, 2026
cederom
left a comment
Contributor
There was a problem hiding this comment.
Thank you @raiden00pl :-)
CI fails due to other pr gsnsspps ?
xiaoxiang781216
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in candev_char.c of lely_master and lely_slave:
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.
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.