Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion can/io/blf.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,10 @@ def _add_object(self, obj_type, data, timestamp=None):
if timestamp is None:
timestamp = self.stop_timestamp or time.time()
if self.start_timestamp is None:
self.start_timestamp = timestamp
# Save start timestamp using the same precision as the BLF format
# Truncating to milliseconds to avoid rounding errors when calculating
# the timestamp difference
self.start_timestamp = int(timestamp * 1000) / 1000
self.stop_timestamp = timestamp
timestamp = int((timestamp - self.start_timestamp) * 1e9)
header_size = OBJ_HEADER_BASE_STRUCT.size + OBJ_HEADER_V1_STRUCT.size
Expand Down
2 changes: 1 addition & 1 deletion test/data/example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def sort_messages(messages):

TEST_MESSAGES_ERROR_FRAMES = sort_messages(
[
Message(is_error_frame=True),
Message(is_error_frame=True, timestamp=TEST_TIME),
Message(is_error_frame=True, timestamp=TEST_TIME + 0.170),
Message(is_error_frame=True, timestamp=TEST_TIME + 17.157),
]
Expand Down
Loading