diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index 07f1a06..1e2b55d 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -664,6 +664,16 @@ class MiniMateProtocol: raise ProtocolError( f"5A probe for {key4.hex()} carried no STRT record, so the event's end " "is unknown -- not downloaded") + if strict and end_offset is not None and end_offset < start_offset: + # The known 5A page bug: parse_strt_end_offset keeps only the low 16 + # bits, so an event that ends in the next 64 KB page reads as ending + # before it starts, and the walk cannot follow it yet. BE9441's + # events 2 and 19 (bench 2026-10-26) -- named here, before any chunk. + raise ProtocolError( + f"event {key4.hex()} crosses the unit's 64 KB page boundary (starts at " + f"0x{start_offset:04X} in page 0x{key4[1]:02X}, ends at 0x{end_offset:04X} in " + "the next) -- SFM cannot download such an event yet (the known 5A page bug); " + "not saved") if end_offset is None: log.warning( "5A probe response did not contain a STRT record; " diff --git a/tests/test_minimate_5a_strict.py b/tests/test_minimate_5a_strict.py index 325cc40..397739c 100644 --- a/tests/test_minimate_5a_strict.py +++ b/tests/test_minimate_5a_strict.py @@ -99,3 +99,17 @@ def test_strict_raises_when_the_probe_has_no_strt(): def test_the_legacy_walk_keeps_its_tolerance(): frames = stream(a5_replies(), silent_from=40) assert 0 < len(frames) < 51 # short, returned, not raised -- as before + + +def test_strict_names_an_event_that_crosses_the_64kb_page_boundary(): + """BE9441 events 2 and 19 end in the next page (end offset < start offset); + the walk cannot follow them yet. Refused by name, before any chunk is sent.""" + r = a5_replies() + i = r[0].find(b"STRT") + assert r[0][i + 6:i + 10] == bytes.fromhex("0111c92c") # the end key: same page + r[0] = r[0][:i + 6] + bytes.fromhex("01122f06") + r[0][i + 10:] # ... now the next page + p = mp.MiniMateProtocol(Replay(r)) + with pytest.raises(mp.ProtocolError, match="crosses the unit's 64 KB page boundary"): + p.read_bulk_waveform_stream(KEY, stop_after_metadata=False, include_terminator=True, + strict=True) + assert p._transport.sent == 1 # the probe, and nothing after