fix(minimateplus): MiniMate requests escape 02/03/04/10, and the 5A walk is 32-bit linear -- the 64 KB page bug
A recording of Blastware downloading all 8 of BE9441's events (three crossing a 64 KB page; tests/fixtures/minimate-bench-10-26-26-blastware/) settles it: every one of its 748 requests is the standard 16-byte payload with a SUM8 checksum and every 02 / 03 / 04 / 10 byte DLE-escaped -- 748/748 re-encode byte-identically. A 5A request is not a special frame: it is that payload with a 2-byte LENGTH (0x0200 per chunk, the remainder for TERM) and a 4-byte linear ADDRESS. The walk is the event's start, +0x200 at a time carrying into the page byte, then TERM at the next boundary for exactly the remainder. What the old model misread: the fixed 'offset 0x1002' is length 0x0200 escaped (10 02 00); the first event's 'metadata pages at 0x1002/0x1004' are its chunks at 0x0200 and 0x0400; the 16-bit counter could not leave the key's page. - build_bw_frame escapes the four values (was 0x10 only); new s3_stuff(). - build_5a_request(address, length); parse_strt_end_key() -> the full 32 bits. - read_bulk_waveform_stream: one linear walk, no event-1 special case; strict mode keeps every refusal; an end at or before the start is refused as a corrupt STRT (a page crossing is no longer refused -- it downloads). Tests: all 540 Blastware 5A requests and all 208 others rebuilt byte for byte; SFM's walks for events 0, 1, 3 and 7 send exactly Blastware's requests and, fed Blastware's recorded replies, build whole events. In-page requests are byte-identical to before. No codec, store or DB change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
465bc704dd
commit
887e75d1ba
7 files changed
+339
-196
No files matched your search
@@ -71,8 +71,9 @@ def test_strict_raises_when_the_term_gets_no_reply():
|
||||
stream(a5_replies(), silent_from=50, strict=True) # every chunk answered, the TERM not
|
||||
|
||||
|
||||
def test_strict_raises_when_a_metadata_page_gets_no_reply():
|
||||
with pytest.raises(mp.ProtocolError, match="metadata page 0x1002 got no reply"):
|
||||
def test_strict_raises_when_the_first_events_second_chunk_gets_no_reply():
|
||||
# once called the "metadata page at 0x1002": it is event 0's chunk at 0x0200
|
||||
with pytest.raises(mp.ProtocolError, match="no reply for the chunk at 0x01110200"):
|
||||
stream(a5_replies(FIX_EVENT0), key=KEY0, silent_from=1, strict=True)
|
||||
|
||||
|
||||
@@ -101,15 +102,15 @@ def test_the_legacy_walk_keeps_its_tolerance():
|
||||
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."""
|
||||
def test_strict_refuses_a_strt_whose_end_is_not_after_its_start():
|
||||
"""An event that crosses a 64 KB page now downloads (tests/test_5a_blastware_walk.py);
|
||||
an end at or before the start can only be a corrupt STRT."""
|
||||
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
|
||||
assert r[0][i + 6:i + 10] == bytes.fromhex("0111c92c") # the end key
|
||||
r[0] = r[0][:i + 6] + bytes.fromhex("01110000") + r[0][i + 10:] # ... before the start
|
||||
p = mp.MiniMateProtocol(Replay(r))
|
||||
with pytest.raises(mp.ProtocolError, match="crosses the unit's 64 KB page boundary"):
|
||||
with pytest.raises(mp.ProtocolError, match="at or before its start"):
|
||||
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
|
||||
assert p._transport.sent == 1 # the first chunk, and nothing after
|
||||
Reference in new issue
Block a user