fix(minimateplus): every A5 header is 12 bytes once inner DLE pairs count as one -- the general rule
Review of 352f694: the metadata-page detection fixed every observed stream but
was one case of a general rule. An A5 header is 12 bytes in the stripped sense
(TERM's 11); its raw length is 13 whenever the echoed address carries an inner
DLE pair -- the metadata pages at 0x1002 / 0x1004, but equally a sample chunk
or TERM boundary that lands there (inferred: ~1 in 128 events spanning
0x1000-0x1200, not in any capture). _raw_skip() counts it per frame, the way
probe_skip already did; _has_metadata_pages is gone. The reviewer measured
the rule reproducing the shipped bodies byte for byte on all 26 current-walk
streams on this box. Test: a chunk moved to 0x1002 yields the same body.
No DB or schema change; TOOL_VERSION not bumped (the file builder changed, the
.h5 decode did not).
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
f6166b4b04
commit
ac34f80daa
3 files changed
+54
-35
No files matched your search
@@ -90,6 +90,12 @@ def test_be9441_event_1_downloads_verified():
|
||||
|
||||
|
||||
def test_the_check_refuses_the_file_the_metadata_page_bug_produced(monkeypatch):
|
||||
monkeypatch.setattr(bw, "_has_metadata_pages", lambda frames: True) # the bug, back
|
||||
real = bw._frame_body_bytes
|
||||
calls = []
|
||||
|
||||
def old_rule(frame, skip): # the bug, back: frames 1 and 2 cut as metadata pages
|
||||
calls.append(1)
|
||||
return real(frame, skip + 1 if len(calls) in (2, 3) and skip == 12 else skip)
|
||||
monkeypatch.setattr(bw, "_frame_body_bytes", old_rule)
|
||||
with pytest.raises(MalformedReply, match="not saved"):
|
||||
adapter().download_event(CABLE, "BE9441", KEY, "20261025141049")
|
||||
@@ -60,3 +60,17 @@ def test_the_written_file_reads_back_whole(which, tmp_path):
|
||||
pv = read_blastware_file(path).peak_values
|
||||
got = {"Tran": pv.tran, "Vert": pv.vert, "Long": pv.long}
|
||||
assert got == pytest.approx(UNIT_PEAKS[which], abs=1e-6)
|
||||
|
||||
|
||||
def test_a_sample_chunk_at_0x1002_is_not_mistaken_for_a_header_byte():
|
||||
"""Every A5 header is 12 bytes once inner DLE pairs (10 02/03/04) count as one;
|
||||
the TERM's is 11. A sample chunk echoing address 0x1002 carries 13 raw header
|
||||
bytes, like a metadata page -- the general rule handles both."""
|
||||
frames = a5_frames("event1")
|
||||
_s, want, _f = extract_body_bytes(frames)
|
||||
one = frames[1]
|
||||
hdr, payload = bytes(one.data[:12]), bytes(one.data[12:])
|
||||
assert hdr[4:6] != b"\x10\x02"
|
||||
moved = type(one)(**{**vars(one), "data": hdr[:4] + b"\x10\x02" + b"\x00" + hdr[6:] + payload})
|
||||
_s, got, _f = extract_body_bytes([frames[0], moved] + frames[2:])
|
||||
assert got == want
|
||||
Reference in new issue
Block a user