Hi,
While debugging a more complex problem; I came up with this simple reproducer.
This does not completely fix my issues but uncover an undesired pitfall.
Here is a reproducer that creates a good.blf and a bad.blf
Reading the bad.blf will chockes on "BLFParseError("Could not find next object")".
I think that python-can should forbid the creation of unereadable files.
Explicitely setting is_extended_id=True does not helper either.
Greetings
Alexandre
-----
#!/usr/bin/python3
import can
DATA = b'\xff' * 8
ZERO = b'\x00' * 8
def good() -> None:
writer = can.BLFWriter('good.blf')
timestamp = 0.0
for _ in range(10):
for pgn in range(0xf001,0xf00e):
print('.', end='')
timestamp += 0.1
arbitration_id = pgn << 8
msg = can.Message(timestamp=timestamp, arbitration_id=arbitration_id, data=DATA)
writer.on_message_received(msg)
writer.on_message_received(msg)
writer.stop()
good()
print('', flush=True)
def bad() -> None:
writer = can.BLFWriter('bad.blf')
timestamp = 0.0
for _ in range(10):
for pgn in range(0xf001,0xf00e):
timestamp += 0.1
arbitration_id = pgn << 8
msg = can.Message(timestamp=timestamp, arbitration_id=arbitration_id, data=DATA)
writer.on_message_received(msg)
# add ZERO's
for _ in range(10):
timestamp += 0.1
pgn = 0
arbitration_id = pgn << 8
msg = can.Message(timestamp=timestamp, arbitration_id=arbitration_id, data=ZERO)
writer.on_message_received(msg)
for _ in range(10):
for pgn in range(0xf001,0xf00e):
timestamp += 0.1
arbitration_id = pgn << 8
msg = can.Message(timestamp=timestamp, arbitration_id=arbitration_id, data=DATA)
writer.on_message_received(msg)
writer.stop()
bad()