Skip to content

Commit 78d142b

Browse files
authored
Return timestamps relative to EPOCH in neovi interface
1 parent 32c7640 commit 78d142b

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
@@ -12,6 +12,7 @@
1212
import logging
1313
import os
1414
import tempfile
15+
import time
1516
from collections import Counter, defaultdict, deque
1617
from functools import partial
1718
from itertools import cycle
@@ -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 = time.strptime("1/1/2007", "%m/%d/%Y")
73+
ICS_EPOCH_DELTA = time.mktime(ICS_EPOCH) - time.mktime(time.gmtime(0))
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)