Return timestamps relative to epoch in neovi interface by pierreluctg · Pull Request #1789 · hardbyte/python-can

Expand Up @@ -13,6 +13,7 @@ import os import tempfile from collections import Counter, defaultdict, deque from datetime import datetime from functools import partial from itertools import cycle from threading import Event Expand Down Expand Up @@ -68,6 +69,9 @@ def __exit__(self, exc_type, exc_val, exc_tb): open_lock = FileLock(os.path.join(tempfile.gettempdir(), "neovi.lock")) description_id = cycle(range(1, 0x8000))
ICS_EPOCH = datetime.fromisoformat("2007-01-01") ICS_EPOCH_DELTA = (ICS_EPOCH - datetime.fromisoformat("1970-01-01")).total_seconds()

class ICSApiError(CanError): """ Expand Down Expand Up @@ -384,7 +388,7 @@ def _get_timestamp_for_msg(self, ics_msg): return ics_msg.TimeSystem else: # This is the hardware time stamp. return ics.get_timestamp_for_msg(self.dev, ics_msg) return ics.get_timestamp_for_msg(self.dev, ics_msg) + ICS_EPOCH_DELTA
def _ics_msg_to_message(self, ics_msg): is_fd = ics_msg.Protocol == ics.SPY_PROTOCOL_CANFD Expand Down