From 94c207c8c60de293f710399ceff1fa3958b88d20 Mon Sep 17 00:00:00 2001 From: RitheeshBaradwaj Date: Mon, 8 Jul 2024 22:38:51 +0900 Subject: [PATCH 1/2] fix: handle "Start of measurement" line in ASCReader --- CONTRIBUTORS.txt | 3 ++- can/io/asc.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index ae7792e42..389d26412 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -81,4 +81,5 @@ Felix Nieuwenhuizen @fjburgos @pkess @felixn -@Tbruno25 \ No newline at end of file +@Tbruno25 +@RitheeshBaradwaj diff --git a/can/io/asc.py b/can/io/asc.py index 2955ad7f9..af9812c43 100644 --- a/can/io/asc.py +++ b/can/io/asc.py @@ -275,6 +275,11 @@ def __iter__(self) -> Generator[Message, None, None]: ) continue + # Handle the "Start of measurement" line + if line.startswith("0.000000") and "Start of measurement" in line: + # Skip this line as it's just an indicator + continue + if not ASC_MESSAGE_REGEX.match(line): # line might be a comment, chip status, # J1939 message or some other unsupported event From 394b58d1fa4b36bfcb467cc245938ef9cf40e307 Mon Sep 17 00:00:00 2001 From: RitheeshBaradwaj Date: Tue, 9 Jul 2024 08:44:41 +0900 Subject: [PATCH 2/2] chore: use regex to identify start line --- can/io/asc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/io/asc.py b/can/io/asc.py index af9812c43..3a14f0a88 100644 --- a/can/io/asc.py +++ b/can/io/asc.py @@ -276,7 +276,7 @@ def __iter__(self) -> Generator[Message, None, None]: continue # Handle the "Start of measurement" line - if line.startswith("0.000000") and "Start of measurement" in line: + if re.match(r"^\d+\.\d+\s+Start of measurement", line): # Skip this line as it's just an indicator continue