This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 7cb09d96e3 arch/sim/sim_canchar.c: fix compilation when CAN FD is disabled 7cb09d96e3 is described below commit 7cb09d96e37610e5cdf4bd6836be435a95ad68e7 Author: p-szafonimateusz <p-szafonimate...@xiaomi.com> AuthorDate: Fri May 23 11:39:43 2025 +0200 arch/sim/sim_canchar.c: fix compilation when CAN FD is disabled Fix case for CAN character driver in simulator when CANFD is disabled and ch_edl field is not present in CAN header. Signed-off-by: p-szafonimateusz <p-szafonimate...@xiaomi.com> --- arch/sim/src/sim/sim_canchar.c | 54 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/arch/sim/src/sim/sim_canchar.c b/arch/sim/src/sim/sim_canchar.c index ef30e49664..5101a91ddd 100644 --- a/arch/sim/src/sim/sim_canchar.c +++ b/arch/sim/src/sim/sim_canchar.c @@ -182,32 +182,8 @@ static int sim_can_send(struct can_dev_s *dev, struct can_msg_s *msg) struct sim_canchar_s *priv = dev->cd_priv; int ret; - if (!msg->cm_hdr.ch_edl) - { - struct can_frame frame; - - frame.can_id = msg->cm_hdr.ch_id; - frame.can_dlc = msg->cm_hdr.ch_dlc; - - if (msg->cm_hdr.ch_rtr) - { - frame.can_id |= CAN_RTR_FLAG; - } - -#ifdef CONFIG_CAN_EXTID - /* Extended frame */ - - if (msg->cm_hdr.ch_extid) - { - frame.can_id |= CAN_EFF_FLAG; - } -#endif - - memcpy(frame.data, msg->cm_data, frame.can_dlc); - - ret = host_can_send(&priv->host, &frame, sizeof(struct can_frame)); - } - else +#ifdef CONFIG_CAN_FD + if (msg->cm_hdr.ch_edl) { struct canfd_frame frame; @@ -243,6 +219,32 @@ static int sim_can_send(struct can_dev_s *dev, struct can_msg_s *msg) ret = host_can_send(&priv->host, &frame, sizeof(struct canfd_frame)); } + else +#endif + { + struct can_frame frame; + + frame.can_id = msg->cm_hdr.ch_id; + frame.can_dlc = msg->cm_hdr.ch_dlc; + + if (msg->cm_hdr.ch_rtr) + { + frame.can_id |= CAN_RTR_FLAG; + } + +#ifdef CONFIG_CAN_EXTID + /* Extended frame */ + + if (msg->cm_hdr.ch_extid) + { + frame.can_id |= CAN_EFF_FLAG; + } +#endif + + memcpy(frame.data, msg->cm_data, frame.can_dlc); + + ret = host_can_send(&priv->host, &frame, sizeof(struct can_frame)); + } if (ret > 0) {