From 9160f45bea0e8b601c5f79792e46e67b8c656eca Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Fri, 29 Apr 2022 11:06:23 +0200 Subject: [PATCH] fix #1299 --- can/io/asc.py | 4 ++-- test/data/issue_1299.asc | 11 +++++++++++ test/logformats_test.py | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/data/issue_1299.asc diff --git a/can/io/asc.py b/can/io/asc.py index 1a97f6b72..3a320f007 100644 --- a/can/io/asc.py +++ b/can/io/asc.py @@ -202,9 +202,9 @@ def _process_classic_can_frame( _, dlc_str = rest_of_message.split(None, 1) data = "" - dlc = int(dlc_str, self._converted_base) + dlc = dlc2len(int(dlc_str, self._converted_base)) msg_kwargs["dlc"] = dlc - self._process_data_string(data, dlc, msg_kwargs) + self._process_data_string(data, min(8, dlc), msg_kwargs) return Message(**msg_kwargs) diff --git a/test/data/issue_1299.asc b/test/data/issue_1299.asc new file mode 100644 index 000000000..43c29302e --- /dev/null +++ b/test/data/issue_1299.asc @@ -0,0 +1,11 @@ +date Thu Apr 28 10:44:52.480 am 2022 +base hex timestamps absolute +internal events logged +// version 12.0.0 +Begin TriggerBlock Thu Apr 28 10:44:52.480 am 2022 + 0.000000 Start of measurement + 13.258199 1 180 Tx d 8 6A 00 00 00 00 00 00 00 Length = 244016 BitCount = 125 ID = 384 + 13.258433 1 221 Tx d 8 C2 4A 05 81 00 00 15 10 Length = 228016 BitCount = 117 ID = 545 + 13.258671 1 3FF Tx d D 55 AA 01 02 03 04 05 06 Length = 232016 BitCount = 119 ID = 1023 + 13.258907 1 F4 Tx d 8 8A 1A 0D F2 13 00 00 07 Length = 230016 BitCount = 118 ID = 244 +End TriggerBlock diff --git a/test/logformats_test.py b/test/logformats_test.py index eb8984ef6..49e9c563e 100644 --- a/test/logformats_test.py +++ b/test/logformats_test.py @@ -561,6 +561,9 @@ def test_ignore_comments(self): def test_no_triggerblock(self): _msg_list = self._read_log_file("issue_1256.asc") + def test_can_dlc_greater_than_8(self): + _msg_list = self._read_log_file("issue_1299.asc") + class TestBlfFileFormat(ReaderWriterTest): """Tests can.BLFWriter and can.BLFReader.