From 783b90206e1f2ebf32fbeed86f680f725f9ecf75 Mon Sep 17 00:00:00 2001 From: Florian Mickler Date: Fri, 11 Sep 2026 09:03:05 +0200 Subject: [PATCH] blf: interpret object timestamps as signed 64-bit values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change BLF object header timestamp fields from uint64 (Q) to int64 (q) for both V1 and V2 object headers. Observed CANape-generated BLF files containing messages before the recording start timestamp. When interpreted as unsigned values, these timestamps wrap around and appear approximately 2^64 ns in the future, resulting in invalid timestamps (e.g. year 2611) and NaT values in pandas. Using signed 64-bit timestamps correctly preserves negative recording-relative offsets while still providing a usable range of approximately ±292 years at nanosecond resolution. Root cause:   A timestamp of -60 s was decoded as   2^64 ns - 60 s   which produced timestamps approximately 584 years in the future. The resulting values exceeded the valid pandas datetime range and appeared as NaT. --- can/io/blf.py | 4 ++-- doc/changelog.d/+blf_prerecording_timestamps.fixed.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 doc/changelog.d/+blf_prerecording_timestamps.fixed.rst diff --git a/can/io/blf.py b/can/io/blf.py index 77bd02fae..26cae7de5 100644 --- a/can/io/blf.py +++ b/can/io/blf.py @@ -49,10 +49,10 @@ class BLFParseError(Exception): OBJ_HEADER_BASE_STRUCT = struct.Struct("<4sHHLL") # flags, client index, object version, timestamp -OBJ_HEADER_V1_STRUCT = struct.Struct("