test(minimateplus): a 71 KB histogram past the old 128-chunk cap walks as Blastware's and rebuilds its file

Tonight's bridge recording of BE9441 (16:08-19:06) as a fixture, with
Blastware's files: Blastware's and SFM's requests in order (1,596, 722 of them
5A, 722 A5 replies), two Blastware config writes, SFM's stop, and three events.
Event 2 is a 4,096-sps, 2 s histogram of 71,088 bytes -- 139 requests, two 64 KB
crossings.

Measured live the same evening (SFM through the bridge, read-only downloads):
SFM's files for events 1 and 2 are byte-identical to Blastware's (sha256), the
71 KB histogram included -- the first event past the old cap downloaded from a
unit.  Event 0, the mic-off histogram, was refused ('decodes as neither'), as
expected on this branch: its decoder fix (#47) is on dev.

The test, fed the recorded replies with max_chunks=128: SFM's walks send
exactly Blastware's 139 and 118 requests and rebuild both files byte for byte.
Reverting the STRT-sized cap (8acb951) fails it.  No code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-26 19:09:48 -04:00
1 parent d990466407
commit 258a6e2143
9 files changed
+3686

No files matched your search

@@ -0,0 +1,34 @@
# BE9441 through the recording bridge, 16:08–19:06 on 2026-10-26
BE9441 (S338.17) on the dev box's serial port, shared on TCP by `bridges/mm_link.py`.
Both Blastware and SFM connected through it, so `requests.bin` holds both clients'
requests in order and `unit_replies.bin` everything the unit sent: 1,596 requests,
722 of them 5A, matched by 722 A5 replies.
What happened, in order:
| time | who | what |
|---|---|---|
| 16:10–16:15 | Blastware | listed and downloaded events 0 and 1 (below); a cancelled re-read of event 1 |
| 16:26:10 | Blastware | **config write**: Histogram mode, 15-minute interval, mic enabled (13 frames) |
| 16:27:21 | Blastware | **config write**: interval back to 2 s (13 frames; 2 image bytes differ) |
| 17:00 | keypad | histogram monitoring started |
| 18:47–18:53 | SFM | status reads; the flag read 0x0B (monitoring, histogram) |
| 18:53:53 | SFM | **stop** (0x97): acked 0x68, read back idle; audit c9c17128 |
| 18:55–19:00 | Blastware | downloaded event 2 (a cancelled partial walk, then the full one) |
| 19:03–19:06 | SFM | downloaded events 1 and 2 by serial, byte-identical to `blastware/` |
Events (Blastware's files in `blastware/`):
| event | key → end | what | file |
|---|---|---|---|
| 0 | `01110000` → `011106A0` | histogram, 2 s, **mic off**, 22 intervals (1,696 B) | `K441LTOK.QZ0` (+ ASCII) |
| 1 | `011106A0` → `0111F210` | waveform, 60,272 B | `K441LTOK.R10` |
| 2 | `0111F210` → `011307C0` | histogram, 2 s, mic on, 4,096 sps, 3,398 intervals, **71,088 B: 139 requests, two 64 KB crossings** | `K441LTON.900` (+ ASCII) |
Measured from this recording:
- every request, write frames included, follows the uniform escape model (#46);
- the config image's layout matches Series 4's `0x1A` (#48);
- the mic-off histogram format (#47);
- the old histogram reader misreads 87/3,398 of event 2's intervals at 4,096 sps (#49);
- the 0x1C flag 0x0B and the escaped-memory-field decode (`d990466`).
@@ -0,0 +1,72 @@
"Event Type : Full Histogram"
"Serial Number : BE9441"
"Version : V 10.72-8.17 MiniMate Plus"
"File Name : K441LTOK.QZ0"
"Histogram Start Time : 16:06:35"
"Histogram Start Date : October 26, 2026"
"Histogram Stop Time : 16:07:21"
"Histogram Stop Date : October 26, 2026"
"Number of Intervals : 22.00"
"Interval Size : 2 seconds "
"Sample Rate : 2048 sps"
"Battery Level : 6.8 Volts"
"Calibration : October 6, 2026 by Instantel"
"Units : in/s and "
"Project: : TestUnit-Minimate"
"Client: : Terra-Mechanics"
"User Name: : Terra-Mechanics Inc. - Harrison"
"Seis. Loc: : Test unit 1"
"Geo Range : 10.000 in/s"
"Tran PPV : 0.250 in/s"
"Vert PPV : 1.080 in/s"
"Long PPV : 0.195 in/s"
"Tran ZC Freq : 16.8 Hz"
"Vert ZC Freq : 22 Hz"
"Long ZC Freq : 19.3 Hz"
"Tran Peak Time : 16:06:45"
"Tran Peak Date : October 26, 2026"
"Vert Peak Time : 16:06:49"
"Vert Peak Date : October 26, 2026"
"Long Peak Time : 16:06:43"
"Long Peak Date : October 26, 2026"
"Peak Vector Sum : 1.083 in/s"
"Peak Vector Sum Time : 16:06:49"
"Peak Vector Sum Date : October 26, 2026"
"Tran Test Freq : 7.3 Hz"
"Tran Test Ratio : 4.5"
"Tran Test Results : Passed"
"Vert Test Freq : 7.4 Hz"
"Vert Test Ratio : 3.5"
"Vert Test Results : Passed"
"Long Test Freq : 7.3 Hz"
"Long Test Ratio : 4.2"
"Long Test Results : Passed"
"Monitor Log(s)"
"Oct 26 /26 16:06:34 Oct 26 /26 16:07:21 Event recorded. (Keyboard Exit)"
"PC SW Version : V 10.74"
Tran Tran Vert Vert Long Long Geo
PPV Freq PPV Freq PPV Freq PVS
Time in/s Hz in/s Hz in/s Hz in/s
October 26, 2026
16:06:37 0.040 21 0.060 21 0.025 21 0.065
16:06:39 0.030 12.8 0.030 16.5 0.015 73 0.034
16:06:41 0.010 >200 0.010 >200 0.010 >200 0.015
16:06:43 0.230 26 0.400 17.4 0.195 19.3 0.461
16:06:45 0.250 16.8 0.120 24 0.135 20 0.255
16:06:47 0.015 20 0.020 10.7 0.015 39 0.022
16:06:49 0.235 33 1.080 22 0.165 20 1.083
16:06:51 0.015 19.7 0.040 19.0 0.020 25 0.043
16:06:53 0.085 4.3 0.140 3.0 0.115 3.4 0.185
16:06:55 0.045 2.9 0.140 2.9 0.120 2.8 0.181
16:06:57 0.015 31 0.010 >200 0.010 >200 0.015
16:06:59 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:01 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:03 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:05 0.015 114 0.010 >200 0.010 >200 0.016
16:07:07 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:09 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:11 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:13 0.045 4.0 0.055 3.4 0.055 5.7 0.066
16:07:15 0.055 5.0 0.070 3.0 0.075 2.2 0.111
16:07:17 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:19 0.010 >200 0.010 >200 0.010 >200 0.015
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
+124
View File
@@ -0,0 +1,124 @@
"""SFM's 5A walk past the old 128-chunk cap, against Blastware (BE9441, 2026-10-26).
Event 2 of tests/fixtures/minimate-bench-10-26-26-histogram/ is a 71,088-byte
histogram: 139 requests, crossing two 64 KB pages. Before the walk was sized from
STRT, a caller's max_chunks=128 cut it short. Fed the unit's recorded replies,
SFM's walk must send exactly Blastware's requests and rebuild Blastware's file.
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
import pytest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import minimateplus.protocol as mp # noqa: E402
from minimate_replay import fast_clock # noqa: E402
from minimateplus.blastware_file import write_blastware_file # noqa: E402
from minimateplus.framing import S3FrameParser # noqa: E402
from minimateplus.models import Event # noqa: E402
FIX = Path(__file__).parent / "fixtures" / "minimate-bench-10-26-26-histogram"
def _unstuff(b: bytes) -> bytes:
out, k = bytearray(), 0
while k < len(b):
if b[k] == 0x10 and k + 1 < len(b):
out.append(b[k + 1]); k += 2
else:
out.append(b[k]); k += 1
return bytes(out)
def _requests() -> list:
raw, out, i = (FIX / "requests.bin").read_bytes(), [], 0
while i < len(raw):
if raw[i:i + 2] == b"\x41\x03":
i += 2
continue
if raw[i:i + 2] != b"\x41\x02":
i += 1
continue
j = i + 2
while raw[j] != 0x03:
j += 2 if raw[j] == 0x10 else 1
out.append(raw[i:j + 1])
i = j + 1
return out
def _addr_len(frame: bytes) -> tuple:
p = _unstuff(frame[2:-1])
return int.from_bytes(p[6:10], "big"), int.from_bytes(p[4:6], "big")
def _a5_replies() -> list:
raw, out, start, p = (FIX / "unit_replies.bin").read_bytes(), [], 0, S3FrameParser()
for i in range(len(raw)):
for f in p.feed(raw[i:i + 1]):
if f.sub == 0xA5:
out.append(raw[start:i + 1])
start = i + 1
return out
FIVE_A = [f for f in _requests() if _unstuff(f[2:-1])[2] == 0x5A]
REPLIES = {}
for _q, _r in zip(FIVE_A, _a5_replies()):
REPLIES.setdefault(_addr_len(_q), _r)
class ByAddress:
def __init__(self):
self.sent, self._buf = [], b""
def write(self, data):
data = bytes(data)
self.sent.append(data)
self._buf += REPLIES.get(_addr_len(data), b"")
def read(self, n):
out, self._buf = self._buf[:n], self._buf[n:]
return out
def _blastware_walk(start: int) -> list:
"""Blastware's last complete walk for the event at `start` (it also cancelled one)."""
starts = [k for k, f in enumerate(FIVE_A) if _addr_len(f) == (start, 0x200)]
for i in reversed(starts):
walk = [FIVE_A[i]]
while i + 1 < len(FIVE_A) and _addr_len(walk[-1])[1] == 0x200:
i += 1
walk.append(FIVE_A[i])
if _addr_len(walk[-1])[1] != 0x200:
return walk
raise AssertionError("no complete walk")
@pytest.fixture(autouse=True)
def _fast(monkeypatch):
fast_clock(monkeypatch)
def test_the_recording_pairs_up():
assert len(FIVE_A) == len(_a5_replies()) == 722
@pytest.mark.parametrize("key,bw,n", [("0111f210", "K441LTON.900", 139),
("011106a0", "K441LTOK.R10", 118)])
def test_the_walk_is_blastwares_and_rebuilds_its_file(key, bw, n, tmp_path):
t = ByAddress()
frames = mp.MiniMateProtocol(t).read_bulk_waveform_stream(
bytes.fromhex(key), stop_after_metadata=False, include_terminator=True,
strict=True, max_chunks=128)
want = _blastware_walk(int(key, 16))
assert len(want) == n and t.sent == want
ev = Event(index=0)
ev.timestamp = None
write_blastware_file(ev, frames, tmp_path / bw)
assert (tmp_path / bw).read_bytes() == (FIX / "blastware" / bw).read_bytes()