Skip to content

Commit 6d44fd0

Browse files
Karl Schärlundhardbyte
authored andcommitted
Avoid padding CAN_FD_MESSAGE_64 objects to 4 bytes
1 parent f9198f3 commit 6d44fd0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

can/io/blf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ def __iter__(self):
195195
raise BLFParseError()
196196

197197
obj_size = header[3]
198+
obj_type = header[4]
198199
# Calculate position of next object
199-
next_pos = pos + obj_size + (obj_size % 4)
200+
if obj_size % 4 and obj_type != CAN_FD_MESSAGE_64:
201+
next_pos = pos + obj_size + (obj_size % 4)
202+
else:
203+
# CAN_FD_MESSAGE_64 objects are not padded to 4 bytes.
204+
next_pos = pos + obj_size
200205
if next_pos > len(data):
201206
# Object continues in next log container
202207
break
@@ -222,7 +227,6 @@ def __iter__(self):
222227
factor = 1e-9
223228
timestamp = timestamp * factor + self.start_timestamp
224229

225-
obj_type = header[4]
226230
# Both CAN message types have the same starting content
227231
if obj_type in (CAN_MESSAGE, CAN_MESSAGE2):
228232
(channel, flags, dlc, can_id,

0 commit comments

Comments
 (0)