From bfe1d3438d82c93754c86a9f9789f73a754fd64c Mon Sep 17 00:00:00 2001 From: Martin Stellmacher Date: Sat, 7 Mar 2020 22:53:14 +0100 Subject: [PATCH] Replaced assumption about padding by just searching for the start of the next frame by the help of the 'LOBJ' mark. --- can/io/blf.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/can/io/blf.py b/can/io/blf.py index ca0b5bd38..d88f239ce 100644 --- a/can/io/blf.py +++ b/can/io/blf.py @@ -220,6 +220,14 @@ def _parse_data(self, data): # Loop until a struct unpack raises an exception while True: self._pos = pos + #fix padding + if pos + obj_header_base_size > max_pos: + # This object continues in the next container + return + for i in range(4): + if data[pos+i:pos+i+4] == b"LOBJ": + break + pos += i header = unpack_obj_header_base(data, pos) # print(header) signature, _, header_version, obj_size, obj_type = header @@ -228,9 +236,6 @@ def _parse_data(self, data): # Calculate position of next object next_pos = pos + obj_size - if obj_type != CAN_FD_MESSAGE_64: - # Add padding bytes - next_pos += obj_size % 4 if next_pos > max_pos: # This object continues in the next container return