fix(minimateplus): read a MiniMate's settings by position, not the 'anchor' (#48)
The legacy SUB 1A decode found the record mode, sample rate, histogram interval and record time by searching for be 80 00 00 00 00, believed a stable anchor. It is the block's [12:18]: the pre-trigger (-0.25 s) and the stop mode (Fixed). A unit in Auto stop mode, or with another pre-trigger, has no such bytes, and all four read None -- in connect()'s legacy routes (/device/info without a serial, the legacy event download's sample rate). The serial-routed settings path already read by position. The block is now found by its own length field N = 2090 (08 2a, at unescaped[12] on every recorded reply) and read by position, Series IV's 0x1A layout. It never struck: every DL2 event file's setup copy has stop mode Fixed, 70,041 / 70,041, and Blastware's reports agree (7,631 / 7,631). Tested on recorded replies patched to Auto stop and to a -0.5 s pre-trigger (8 new tests; the 7 existing ones unchanged); not yet on a unit in Auto stop mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
This commit is contained in:
1 parent
621c836109
commit
71bd14156d
4 files changed
+90
-35
No files matched your search
@@ -98,3 +98,39 @@ def test_a_reply_without_the_settings_block_reads_as_unknown():
|
||||
|
||||
# The write side moved to the shared settings codec in phase 5 (2026-11-03):
|
||||
# tests/test_setup_fields.py reproduces every Blastware write byte for byte.
|
||||
|
||||
|
||||
# ── #48: the "anchor" is two settings, not a marker ───────────────────────────
|
||||
# `be 80 00 00 00 00` is the block's [12:18]: the pre-trigger (-0.25 s, f32 BE)
|
||||
# then [16] and the stop mode [17] (0 = Fixed). A unit in Auto stop mode, or
|
||||
# with another pre-trigger, has no such bytes. The block is found instead by its
|
||||
# own length field N = 2090 (`08 2a`), and its fields read by position: the layout
|
||||
# Series 4's 0x1A shares (reference D.6.2; setup_block.py). No DL2 event was
|
||||
# recorded in Auto stop mode (70,041 / 70,041 Fixed, measured 2026-12-01), so this
|
||||
# tests a reply patched from a real one.
|
||||
|
||||
import struct # noqa: E402
|
||||
|
||||
|
||||
def _patched(i, at, new):
|
||||
"""Reply i with the anchor's bytes [at:at+len(new)] replaced. The anchor holds
|
||||
no 02/03/04, so the raw bytes can be patched in place."""
|
||||
d = bytearray(_settings_replies()[i])
|
||||
a = bytes(d).find(ANCHOR)
|
||||
assert a >= 0
|
||||
d[a + at:a + at + len(new)] = new
|
||||
return bytes(d)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("i", range(4))
|
||||
def test_auto_stop_mode_still_reads_the_settings(i):
|
||||
cc = _decode(_patched(i, 5, b"\x01")) # [17] stop mode = Auto
|
||||
got = (cc.recording_mode, cc.sample_rate, cc.histogram_interval_sec, round(cc.record_time, 2))
|
||||
assert got == EXPECT[i]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("i", range(4))
|
||||
def test_another_pretrigger_still_reads_the_settings(i):
|
||||
cc = _decode(_patched(i, 0, struct.pack(">f", -0.5))) # [12:16] pre-trigger
|
||||
got = (cc.recording_mode, cc.sample_rate, cc.histogram_interval_sec, round(cc.record_time, 2))
|
||||
assert got == EXPECT[i]
|
||||
Reference in new issue
Block a user