Skip to content

Commit a672dd1

Browse files
[driver] Set can_message.dlc field when receiving
The Lawicel ASCII protocol does not support CAN-FD at all.
1 parent 9dc4f19 commit a672dd1

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/modm/driver/can/can_lawicel_formatter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ modm::CanLawicelFormatter::convertToCanMessage(const char* in, can::Message& out
3939

4040
// get the number of data-bytes for this message
4141
out.length = in[dlc_pos] - '0';
42+
out.dlc = out.length;
4243
if (out.length > 8)
4344
return false; // too many data-bytes
4445

test/modm/driver/can/can_lawicel_formatter_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ CanLawicelFormatterTest::testStringToMessage()
104104
TEST_ASSERT_TRUE(modm::CanLawicelFormatter::convertToCanMessage(input, output));
105105

106106
TEST_ASSERT_EQUALS(output.identifier, 0x00001610U);
107+
TEST_ASSERT_EQUALS(output.dlc, 8U);
107108
TEST_ASSERT_EQUALS(output.length, 8U);
108109
TEST_ASSERT_EQUALS(output.flags.extended, true);
109110
TEST_ASSERT_EQUALS(output.flags.rtr, false);
@@ -154,6 +155,7 @@ CanLawicelFormatterTest::testRoudtripString()
154155
TEST_ASSERT_TRUE(modm::CanLawicelFormatter::convertToCanMessage(buffer, myMsg));
155156

156157
TEST_ASSERT_EQUALS(msg.identifier, myMsg.identifier);
158+
TEST_ASSERT_EQUALS(msg.dlc, myMsg.dlc);
157159
TEST_ASSERT_EQUALS(msg.length, myMsg.length);
158160
TEST_ASSERT_EQUALS(msg.flags.extended, myMsg.flags.extended);
159161
TEST_ASSERT_EQUALS(msg.flags.rtr, myMsg.flags.rtr);

0 commit comments

Comments
 (0)