Skip to content

Commit 96754c1

Browse files
authored
Return timestamps relative to epoch in neovi interface (#1789)
1 parent fc6ff22 commit 96754c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

can/interfaces/ics_neovi/neovi_bus.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import tempfile
1515
from collections import Counter, defaultdict, deque
16+
from datetime import datetime
1617
from functools import partial
1718
from itertools import cycle
1819
from threading import Event
@@ -68,6 +69,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
6869
open_lock = FileLock(os.path.join(tempfile.gettempdir(), "neovi.lock"))
6970
description_id = cycle(range(1, 0x8000))
7071

72+
ICS_EPOCH = datetime.fromisoformat("2007-01-01")
73+
ICS_EPOCH_DELTA = (ICS_EPOCH - datetime.fromisoformat("1970-01-01")).total_seconds()
74+
7175

7276
class ICSApiError(CanError):
7377
"""
@@ -384,7 +388,7 @@ def _get_timestamp_for_msg(self, ics_msg):
384388
return ics_msg.TimeSystem
385389
else:
386390
# This is the hardware time stamp.
387-
return ics.get_timestamp_for_msg(self.dev, ics_msg)
391+
return ics.get_timestamp_for_msg(self.dev, ics_msg) + ICS_EPOCH_DELTA
388392

389393
def _ics_msg_to_message(self, ics_msg):
390394
is_fd = ics_msg.Protocol == ics.SPY_PROTOCOL_CANFD

0 commit comments

Comments
 (0)