This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 5e0f069cde60a2746d1dcade3efa217cd0f70527 Author: raiden00pl <[email protected]> AuthorDate: Mon Oct 12 13:13:54 2026 +0200 examples/lely: Clear the CAN header before write() in the char backend. *_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 <[email protected]> --- examples/lely_master/candev_char.c | 11 +++++++---- examples/lely_slave/candev_char.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/lely_master/candev_char.c b/examples/lely_master/candev_char.c index d4c684d10..470917b96 100644 --- a/examples/lely_master/candev_char.c +++ b/examples/lely_master/candev_char.c @@ -27,6 +27,7 @@ #include <nuttx/config.h> #include <stdio.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> @@ -112,16 +113,18 @@ int comaster_candev_send(FAR const struct can_msg *msg) ssize_t nwritten; int i; + /* Lely CANopen sends classic CAN frames only. Clear the whole header, + * so that all other fields (e.g. the CAN FD flags) are zero. + */ + + memset(&txmsg.cm_hdr, 0, sizeof(txmsg.cm_hdr)); + txmsg.cm_hdr.ch_id = msg->id; txmsg.cm_hdr.ch_rtr = (msg->flags & CAN_FLAG_RTR) != 0; txmsg.cm_hdr.ch_dlc = msg->len; #ifdef CONFIG_CAN_EXTID txmsg.cm_hdr.ch_extid = (msg->flags & CAN_FLAG_IDE) != 0; #endif -#ifdef CONFIG_CAN_ERRORS - txmsg.cm_hdr.ch_error = 0; -#endif - txmsg.cm_hdr.ch_tcf = 0; for (i = 0; i < msg->len; i++) { diff --git a/examples/lely_slave/candev_char.c b/examples/lely_slave/candev_char.c index c840781d0..8281f9c3e 100644 --- a/examples/lely_slave/candev_char.c +++ b/examples/lely_slave/candev_char.c @@ -27,6 +27,7 @@ #include <nuttx/config.h> #include <stdio.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> @@ -112,16 +113,18 @@ int coslave_candev_send(FAR const struct can_msg *msg) ssize_t nwritten; int i; + /* Lely CANopen sends classic CAN frames only. Clear the whole header, + * so that all other fields (e.g. the CAN FD flags) are zero. + */ + + memset(&txmsg.cm_hdr, 0, sizeof(txmsg.cm_hdr)); + txmsg.cm_hdr.ch_id = msg->id; txmsg.cm_hdr.ch_rtr = (msg->flags & CAN_FLAG_RTR) != 0; txmsg.cm_hdr.ch_dlc = msg->len; #ifdef CONFIG_CAN_EXTID txmsg.cm_hdr.ch_extid = (msg->flags & CAN_FLAG_IDE) != 0; #endif -#ifdef CONFIG_CAN_ERRORS - txmsg.cm_hdr.ch_error = 0; -#endif - txmsg.cm_hdr.ch_tcf = 0; for (i = 0; i < msg->len; i++) {
