From 7390740c29e2d456c213287e19823e68049e5ed5 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 6 Apr 2024 17:31:34 +0000 Subject: [PATCH] canbus: isotp: use proper CAN ID masks Use CAN ID masks matching the flags used in the CAN RX filter. Signed-off-by: Henrik Brix Andersen --- subsys/canbus/isotp/isotp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/subsys/canbus/isotp/isotp.c b/subsys/canbus/isotp/isotp.c index b36665a277..dcb3438dc2 100644 --- a/subsys/canbus/isotp/isotp.c +++ b/subsys/canbus/isotp/isotp.c @@ -595,8 +595,10 @@ static inline int add_ff_sf_filter(struct isotp_recv_ctx *rctx) if ((rctx->rx_addr.flags & ISOTP_MSG_FIXED_ADDR) != 0) { mask = ISOTP_FIXED_ADDR_RX_MASK; - } else { + } else if ((rctx->rx_addr.flags & ISOTP_MSG_IDE) != 0) { mask = CAN_EXT_ID_MASK; + } else { + mask = CAN_STD_ID_MASK; } prepare_filter(&filter, &rctx->rx_addr, mask); @@ -1167,8 +1169,15 @@ static void send_work_handler(struct k_work *item) static inline int add_fc_filter(struct isotp_send_ctx *sctx) { struct can_filter filter; + uint32_t mask; - prepare_filter(&filter, &sctx->rx_addr, CAN_EXT_ID_MASK); + if ((sctx->rx_addr.flags & ISOTP_MSG_IDE) != 0) { + mask = CAN_EXT_ID_MASK; + } else { + mask = CAN_STD_ID_MASK; + } + + prepare_filter(&filter, &sctx->rx_addr, mask); sctx->filter_id = can_add_rx_filter(sctx->can_dev, send_can_rx_cb, sctx, &filter);