Skip to content

Commit b97f12a

Browse files
committed
Merge latest changes to asc
2 parents 7601f22 + dc86906 commit b97f12a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

can/io/asc.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class ASCReader(BaseIOHandler):
3131
"""
3232
Iterator of CAN messages from a ASC logging file. Meta data (comments,
3333
bus statistics, J1939 Transport Protocol messages) is ignored.
34-
35-
TODO: turn relative timestamps back to absolute form
3634
"""
3735

3836
def __init__(
@@ -183,15 +181,26 @@ def __iter__(self) -> Generator[Message, None, None]:
183181
self.file = cast(IO[Any], self.file)
184182
self._extract_header()
185183

184+
start_time = 0.0
185+
186186
for line in self.file:
187187
temp = line.strip()
188+
189+
#check for timestamp
190+
if "begin triggerblock" in temp.lower():
191+
try:
192+
_, _, start_time = temp.split(None, 2)
193+
start_time = datetime.strptime(start_time, "%a %b %m %I:%M:%S.%f %p %Y").timestamp()
194+
except ValueError:
195+
continue
196+
188197
if not temp or not temp[0].isdigit():
189198
# Could be a comment
190199
continue
191200
msg_kwargs = {}
192201
try:
193202
timestamp, channel, rest_of_message = temp.split(None, 2)
194-
timestamp = float(timestamp)
203+
timestamp = float(timestamp) + start_time
195204
msg_kwargs["timestamp"] = timestamp
196205
if channel == "CANFD":
197206
msg_kwargs["is_fd"] = True

0 commit comments

Comments
 (0)