From f464cd6d68ec1575ec76fc9fbb9d506c48d8ae39 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Date: Fri, 7 Jun 2024 11:43:03 -0400 Subject: [PATCH 1/2] Return timestamps relative to EPOCH in neovi interface --- can/interfaces/ics_neovi/neovi_bus.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/can/interfaces/ics_neovi/neovi_bus.py b/can/interfaces/ics_neovi/neovi_bus.py index 7863fcb65..203d58008 100644 --- a/can/interfaces/ics_neovi/neovi_bus.py +++ b/can/interfaces/ics_neovi/neovi_bus.py @@ -12,6 +12,7 @@ import logging import os import tempfile +import time from collections import Counter, defaultdict, deque from functools import partial from itertools import cycle @@ -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 = time.strptime("1/1/2007", "%m/%d/%Y") +ICS_EPOCH_DELTA = time.mktime(ICS_EPOCH) - time.mktime(time.gmtime(0)) + class ICSApiError(CanError): """ @@ -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 From 165ee4cd36517d1bd197bfed78426046ee51cafb Mon Sep 17 00:00:00 2001 From: Pierre-Luc Date: Mon, 10 Jun 2024 08:20:32 -0400 Subject: [PATCH 2/2] Update neovi_bus.py --- can/interfaces/ics_neovi/neovi_bus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/can/interfaces/ics_neovi/neovi_bus.py b/can/interfaces/ics_neovi/neovi_bus.py index 203d58008..815ed6fa0 100644 --- a/can/interfaces/ics_neovi/neovi_bus.py +++ b/can/interfaces/ics_neovi/neovi_bus.py @@ -12,8 +12,8 @@ import logging import os import tempfile -import time from collections import Counter, defaultdict, deque +from datetime import datetime from functools import partial from itertools import cycle from threading import Event @@ -69,8 +69,8 @@ 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 = time.strptime("1/1/2007", "%m/%d/%Y") -ICS_EPOCH_DELTA = time.mktime(ICS_EPOCH) - time.mktime(time.gmtime(0)) +ICS_EPOCH = datetime.fromisoformat("2007-01-01") +ICS_EPOCH_DELTA = (ICS_EPOCH - datetime.fromisoformat("1970-01-01")).total_seconds() class ICSApiError(CanError):