From 660c4eb621f4de5db74474f4966429f203808992 Mon Sep 17 00:00:00 2001 From: onejope Date: Sat, 2 May 2015 16:34:07 -0400 Subject: [PATCH] Fixed extended id support for transmitting CAN messages --- Src/slcan.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Src/slcan.c b/Src/slcan.c index 4be0259..2604f10 100644 --- a/Src/slcan.c +++ b/Src/slcan.c @@ -121,14 +121,25 @@ int8_t slcan_parse_str(char *buf, uint8_t len) { return -1; } - uint8_t id_len = frame.IDE == CAN_ID_EXT ? SLCAN_EXT_ID_LEN : SLCAN_STD_ID_LEN; frame.StdId = 0; - i = 1; - while (i <= id_len) { - frame.StdId += buf[i++]; - frame.StdId *= 16; + frame.ExtId = 0; + if (frame.IDE == CAN_ID_EXT) { + uint8_t id_len = SLCAN_EXT_ID_LEN; + i = 1; + while (i <= id_len) { + frame.ExtId *= 16; + frame.ExtId += buf[i++]; + } } - frame.StdId /= 16; + else { + uint8_t id_len = SLCAN_STD_ID_LEN; + i = 1; + while (i <= id_len) { + frame.StdId *= 16; + frame.StdId += buf[i++]; + } + } + frame.DLC = buf[i++]; if (frame.DLC < 0 || frame.DLC > 8) {