fix(minimateplus): MiniMate config writes are ordinary escaped requests carrying whole blocks; apply_config reads the unit's own trigger block (#46)

Measured against every Blastware request on record: the uploaded Feb-Apr 2026
captures (3,869 frames, 3,869 re-encode exactly) and BE9441's two sends on
2026-10-26 (26 write frames).  A write is the standard 16-byte request plus its
data, every 02/03/04/10 escaped, SUM8 checksum; the length field is the data's
length.  A config block starts with its own length N and is written as N + 2
bytes: event index (68) and trigger (82) as read plus 02 00 / 00 00 (constant on
15 sends), waveform data (69) and the 2,092-byte compliance image (71) whole.
The compliance image goes in addressed chunks (params[2:4] = address): 512 bytes
tonight (Blastware 10.74), 1,024 in March.

- framing.build_bw_write_frame: uniform escaping, SUM8, length = len(data).
  RETRACTED: 'only BW_CMD doubled', the 'DLE-aware checksum', 'offset = data[1]
  + 2' -- fitted to frames still holding their escape bytes ('data 91, offset 90'
  was 90 bytes and one escape).  It got 7 of every 13 frames in a write wrong.
- protocol.write_image(): unescapes (callers may pass the parser's form), adds
  the trailing two bytes to an N-byte block, and REFUSES anything else before a
  byte is sent -- an edit beside a kept escape byte (the old encoder's anc-9
  hazard) leaves an image one byte long.
- write_compliance_config_raw: 512-byte addressed chunks, then confirm 72.
- read_event_index / read_waveform_data_raw unescape before slicing (a block
  holding 02/03/04/10 came out short); new read_trigger_config (SUB 0x2E).
- apply_config reads the unit's trigger block.  RETRACTED: the block
  'hardcoded from 3-11-26 -- no read exists'.  Blastware reads it; byte 5 has
  been 01 / 03 / 04 by unit and session, and the March copy (03) would have
  changed BE9441's (01).
- The call-home write (7E) goes through write_image: its 127-byte 'read + 00 00'
  is the 126-byte image (N = 0x7C).  No Blastware 7E is on record here -- that
  one is inferred from the other 77 write frames.

Tests: tonight's 26 and every Feb-Apr write frame rebuilt byte for byte; each
block as read written exactly as Blastware wrote it; the parser's form; the
stray-byte refusal; the reads against the unit's recorded replies; apply_config
writes BE9441's own trigger block.  Six mutants, each caught.  The old
test_write_frames.py (25 tests that had been skipping) runs now that the
captures are here, rewritten to the measured model.

Not yet sent to a unit: a config push changes settings, so its first live use
is a bench session with Brian.  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:
serversdownandClaude Opus 5.5 committed 2026-10-27 02:54:26 -04:00
1 parent a7f581f66a
commit b5037b0b1e
5 files changed
+436 -702

No files matched your search

+8 -10
View File
@@ -67,14 +67,11 @@ S3_MONITORING_FLAGS = frozenset({0x10, 0x0B})
# ── Module-level constants ────────────────────────────────────────────────────
# Trigger config payload hardcoded from 3-11-26 BW TX capture (BW frame 108).
# No SUB 0x22 read exists in the capture — Blastware writes this fixed blob.
# 29 bytes: [00][1A][D5][00][00][10][03][08][0A] + 18×FF + [00][00]
_TRIGGER_DATA_HARDCODED: bytes = bytes.fromhex(
"001ad500001003080a"
"ffffffffffffffffffffffffffffffffffffff"
"0000"
)
# ⚠ RETRACTED 2026-10-27 (#46): a trigger block "hardcoded from 3-11-26 -- no
# read exists, Blastware writes this fixed blob". Blastware reads it first (SUB
# 0x2E), and its byte 5 differs by unit and session (01 / 03 / 04 on record), so
# the copy changed that setting on any unit that differed. apply_config reads
# the unit's own block (MiniMateProtocol.read_trigger_config).
# Compliance ASCII slot format (confirmed from 3-11-26 capture + label search):
# Each label occupies a 64-byte slot.
@@ -1037,7 +1034,7 @@ class MiniMateClient:
Write payloads:
event_index_data : 88 bytes — read live via SUB 08
compliance_data : ~2128 bytes — read live via SUB 1A (~2126 bytes, varies ±1-2) + \\x00\\x00 footer
trigger_data : 29 bytes — hardcoded from 3-11-26 capture
trigger_data : 26 bytes — read live via SUB 2E (was hard-coded; #46)
waveform_data : 204 bytes — read live via SUB 09
Raises:
@@ -1057,7 +1054,8 @@ class MiniMateClient:
log.info("apply_config: reading waveform data (SUB 09)")
waveform_data = proto.read_waveform_data_raw() # 204 bytes
trigger_data = _TRIGGER_DATA_HARDCODED # 29 bytes
log.info("apply_config: reading trigger config (SUB 2E)")
trigger_data = proto.read_trigger_config() # 26 bytes, this unit's own
# 2. Patch the compliance buffer and build the 2128-byte write payload
compliance_data = _encode_compliance_config(