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(
+20 -89
View File
@@ -284,103 +284,34 @@ def build_bw_write_frame(
sub: int,
data: bytes,
*,
offset: int = 0,
offset: Optional[int] = None,
params: bytes = bytes(10),
) -> bytes:
"""
Build a BW→S3 write-command frame.
"""A write request: the standard 16-byte request followed by `data`, escaped
and checksummed like every other request (s3_stuff, SUM8).
Write frames extend the standard 16-byte read header with a variable-length
data payload. They use a different checksum formula from read frames.
`offset` is the payload's [4:6] field -- the data's LENGTH; it defaults to
len(data), which is what Blastware sends on every write on record.
**CRITICAL: Write frames use minimal DLE stuffing.**
Measured 2026-10-26/27 (issue #46): all of Blastware's requests from February
to October 2026 -- 3,869 frames in the uploaded captures plus BE9441's 26
write frames tonight -- rebuild byte for byte this way, the 77 write frames
that carry data included (event index 68, compliance 71, trigger 82, waveform
data 69).
Unlike read frames (build_bw_frame), write frames do NOT apply full DLE
stuffing to the payload. Only the BW_CMD byte (0x10) at position [0] is
doubled to 0x10 0x10 on the wire. All other bytes — flags, sub, offset,
params, data, and checksum — are written RAW with no stuffing, even if they
contain 0x10 bytes (e.g. offset_hi=0x10 for compliance chunks, or 0x10
bytes in the write data payload).
Confirmed from 3-11-26 BW TX capture (frames 102–112): all 11 write frames
match the rule "double BW_CMD only; everything else raw." ✅ 2026-04-07.
Wire layout:
[41] ACK
[02] STX
[10 10] BW_CMD doubled (the ONLY DLE stuffing applied)
[00] flags
[sub] write command byte (0x68–0x83)
[00] always zero
[hi][lo] offset as uint16 BE (raw; NOT stuffed even if hi=0x10)
[params] 10 bytes (raw)
[data] variable-length write payload (raw; NOT stuffed)
[chk] checksum byte (raw; NOT stuffed even if 0x10)
[03] ETX
De-stuffed payload (for checksum computation):
[0] BW_CMD 0x10
[1] flags 0x00
[2] SUB write command byte
[3] 0x00 always zero
[4] offset_hi
[5] offset_lo
[6:16] params 10 bytes
[16:] data write payload
[-1] chk
**Checksum formula (confirmed 2026-03-12 from 3-11-26 BW TX capture):**
chk = (sum(b for b in payload[2:] if b != 0x10) + 0x10) % 256
where payload = destuffed content BEFORE appending chk.
This skips all 0x10 bytes in payload[2:] (sub onwards), including any
0x10 bytes in the offset, params, data, and the checksum byte itself.
The offset field [4:6] meaning per write SUB:
- SUBs 68, 69, 82 (single-chunk writes): offset = data[1] + 2, where
data[1] is an embedded length field in the write payload.
Confirmed from capture: 68→0x5A (data[1]=0x58+2), 82→0x1C
(data[1]=0x1A+2), 69→0xCA (data[1]=0xC8+2).
- SUB 71 (multi-chunk compliance): 0x1004 for full chunks, 0x002C
for the final partial chunk.
- Confirm frames (72, 73, 74, 83): offset=0, no data.
Args:
sub: Write command SUB byte.
data: Write payload (variable length; empty for confirm frames).
offset: 16-bit value placed at [4:6]. See per-SUB notes above.
params: 10 bytes placed at [6:16]. All-zero for most writes; compliance
chunk writes use chunk-specific values.
Returns:
Complete frame bytes ready to write to the transport.
⚠ RETRACTED: "only BW_CMD is doubled, everything else raw" and the "DLE-aware
checksum" `(sum of payload[2:] skipping 0x10) + 0x10`. That model rebuilt the
March frames only because it was fitted to data that still held its escape
bytes; the "data length 91, offset 90" it explained was 90 bytes plus one
escape. It got 7 of every 13 frames in a config write wrong.
"""
if len(params) != 10:
raise ValueError(f"params must be exactly 10 bytes, got {len(params)}")
if offset > 0xFFFF:
raise ValueError(f"offset must fit in uint16, got {offset:#06x}")
offset_hi = (offset >> 8) & 0xFF
offset_lo = offset & 0xFF
# Destuffed payload (used only for checksum; not sent directly)
payload_no_chk = bytes([BW_CMD, 0x00, sub, 0x00, offset_hi, offset_lo]) + params + data
# Large-frame checksum: sum payload[2:] skipping all 0x10 bytes, add 0x10.
# Applied to the destuffed representation — confirms correctly against
# all 11 write frames in the 3-11-26/170151 BW TX capture. ✅
chk = (sum(b for b in payload_no_chk[2:] if b != 0x10) + 0x10) & 0xFF
# Wire construction: only BW_CMD is doubled; everything else is raw.
# Do NOT use dle_stuff() here — that would incorrectly double 0x10 bytes
# in the offset, params, and data sections.
wire = (
bytes([ACK, STX]) # Frame prefix (not part of payload)
+ bytes([BW_CMD, BW_CMD]) # BW_CMD doubled (only DLE stuffing applied)
+ payload_no_chk[1:] # flags, sub, offset, params, data — RAW
+ bytes([chk]) # checksum — RAW
+ bytes([ETX]) # Frame terminator
)
return wire
length = len(data) if offset is None else offset
if not 0 <= length <= 0xFFFF:
raise ValueError(f"length must fit in 16 bits, got {length:#x}")
payload = bytes([BW_CMD, 0x00, sub, 0x00, (length >> 8) & 0xFF, length & 0xFF]) + params + data
return bytes([ACK, STX]) + s3_stuff(payload + bytes([checksum(payload)])) + bytes([ETX])
def waveform_key_params(key4: bytes) -> bytes:
+93 -205
View File
@@ -33,6 +33,7 @@ from .framing import (
waveform_key_params,
token_params,
parse_strt_end_key,
unescape_reply,
build_5a_request,
POLL_PROBE,
POLL_DATA,
@@ -130,6 +131,40 @@ _BULK_COUNTER_STEP = 0x0200 # bytes per chunk read, and the step between addre
# claim past this is a misread STRT, refused before walking megabytes of garbage.
_BULK_MAX_EVENT_BYTES = 0x400000 # 4 MiB
# Config writes (issue #46, measured on every Blastware write since February 2026).
_COMPLIANCE_CHUNK = 0x0200
# The two bytes after a block's N header bytes, when the read returned only N:
# Blastware's own, constant on record -- event index 02 00, trigger 00 00. The
# unit evidently does not check them (they are no CRC, and the compliance
# image's went out stale, unchanged across two different sends).
_WRITE_TAIL = {SUB_EVENT_INDEX_WRITE: b"\x02\x00", SUB_TRIGGER_CONFIG_WRITE: b"\x00\x00",
SUB_WAVEFORM_DATA_WRITE: b"\x00\x00", SUB_COMPLIANCE_WRITE: b"\x00\x00",
SUB_CALL_HOME_WRITE: b"\x00\x00"}
def write_image(sub: int, data: bytes) -> bytes:
"""The whole block a write sends: `data` unescaped, N + 2 bytes.
A config block starts with its own length N (uint16 BE) and is written as N
bytes plus two -- on every Blastware write on record. `data` may be the
block as a read returned it (N bytes, or N + 2) and may still hold the
parser's kept escape bytes (10 02 / 10 03 / 10 04), which come out here.
Anything else is refused before a byte is sent: a block one byte longer than
its header says is what an edit beside a kept escape byte leaves behind.
"""
image = unescape_reply(bytes(data))
if len(image) < 2:
raise ValueError(f"write SUB 0x{sub:02X}: {len(image)} bytes is not a whole block")
n = int.from_bytes(image[:2], "big")
if len(image) == n:
image += _WRITE_TAIL[sub]
elif len(image) != n + 2:
raise ValueError(
f"write SUB 0x{sub:02X}: {len(image)} bytes, but its header says {n} (+ 2) -- "
"not a whole block (a stray byte?); nothing sent")
return image
# Default timeout values (seconds).
# MiniMate Plus is a slow device — keep these generous.
DEFAULT_RECV_TIMEOUT = 10.0
@@ -383,7 +418,9 @@ class MiniMateProtocol:
self._send(build_bw_frame(SUB_EVENT_INDEX, length))
data_rsp = self._recv_one(expected_sub=rsp_sub)
raw = data_rsp.data[11 : 11 + length]
# Unescaped first (2026-10-27): a 02/03/04 inside the block arrives as
# 10 0X and the parser keeps both, so a slice by length came up short.
raw = unescape_reply(data_rsp.data)[11 : 11 + length]
log.debug("read_event_index: got %d bytes", len(raw))
return raw
@@ -515,7 +552,7 @@ class MiniMateProtocol:
self._send(build_bw_frame(SUB_WAVEFORM_DATA, length))
data_rsp = self._recv_one(expected_sub=rsp_sub)
raw = data_rsp.data[11:]
raw = unescape_reply(data_rsp.data)[11:] # unescaped, as read_event_index
log.debug("read_waveform_data_raw: got %d bytes", len(raw))
return raw
@@ -1013,208 +1050,66 @@ class MiniMateProtocol:
self._send(frame)
return self.recv_write_ack(expected_sub=rsp_sub)
def write_event_index(self, data: bytes) -> S3Frame:
"""
Send a SUB 68 (EVENT_INDEX_WRITE) frame and await the confirm ack (SUB 97).
Offset formula: data[1] + 2 — confirmed from 3-11-26 BW TX capture frame 102.
The write payload has a 2-byte header [0x00][length] where data[1] encodes
the length of the meaningful payload; offset = data[1] + 2.
Example from capture:
data[0:4] = 00 58 09 00 (data[1]=0x58=88 → offset=0x5A=90)
data length = 91, offset = 90
Write sequence fragment:
68 (data) → device acks with SUB 0x97
73 (confirm) → device acks with SUB 0x8C
Callers should call write_confirm(SUB_WRITE_CONFIRM_B) after this.
Args:
data: Raw event-index payload bytes to write to the device.
Must be at least 2 bytes. data[1] must contain the length field.
Returns:
The SUB 0x97 ack frame.
Raises:
ProtocolError: on timeout or wrong response SUB.
ValueError: if data is shorter than 2 bytes.
"""
if len(data) < 2:
raise ValueError(f"event index write data must be at least 2 bytes, got {len(data)}")
rsp_sub = _expected_rsp_sub(SUB_EVENT_INDEX_WRITE) # 0xFF - 0x68 = 0x97
offset = data[1] + 2
frame = build_bw_write_frame(SUB_EVENT_INDEX_WRITE, data, offset=offset)
log.debug(
"write_event_index: %d bytes data[1]=0x%02X offset=0x%04X rsp_sub=0x%02X",
len(data), data[1], offset, rsp_sub,
)
def _write_block(self, sub: int, data: bytes, params: bytes = bytes(10)) -> S3Frame:
"""Send one config block as a write and return its ack (0xFF - sub)."""
image = write_image(sub, data)
frame = build_bw_write_frame(sub, image, params=params)
log.debug("write SUB=0x%02X: %d-byte image", sub, len(image))
self._send(frame)
return self.recv_write_ack(expected_sub=rsp_sub)
return self.recv_write_ack(expected_sub=_expected_rsp_sub(sub))
def write_event_index(self, data: bytes) -> S3Frame:
"""SUB 68: write the event-index block (as SUB 08 read it). Ack 0x97;
callers follow with write_confirm(SUB_WRITE_CONFIRM_B). See write_image."""
return self._write_block(SUB_EVENT_INDEX_WRITE, data)
def write_waveform_data(self, data: bytes) -> S3Frame:
"""
Send a SUB 69 (WAVEFORM_DATA_WRITE) frame and await the confirm ack (SUB 96).
Offset formula: data[1] + 2 — same pattern as write_event_index().
Confirmed from 3-11-26 BW TX capture frame 110:
data[0:4] = 00 c8 08 00 (data[1]=0xC8=200 → offset=0xCA=202)
data length = 204, offset = 202
Write sequence fragment:
69 (data) → device acks with SUB 0x96
74 (confirm) → device acks with SUB 0x8B
72 (confirm) → device acks with SUB 0x8D
Callers should call write_confirm(SUB_WRITE_CONFIRM_C) then
write_confirm(SUB_WRITE_CONFIRM_A) after this.
Args:
data: Raw waveform-data payload bytes to write.
Must be at least 2 bytes. data[1] must contain the length field.
Returns:
The SUB 0x96 ack frame.
Raises:
ProtocolError: on timeout or wrong response SUB.
ValueError: if data is shorter than 2 bytes.
"""
if len(data) < 2:
raise ValueError(f"waveform data write payload must be at least 2 bytes, got {len(data)}")
rsp_sub = _expected_rsp_sub(SUB_WAVEFORM_DATA_WRITE) # 0xFF - 0x69 = 0x96
offset = data[1] + 2
frame = build_bw_write_frame(SUB_WAVEFORM_DATA_WRITE, data, offset=offset)
log.debug(
"write_waveform_data: %d bytes data[1]=0x%02X offset=0x%04X rsp_sub=0x%02X",
len(data), data[1], offset, rsp_sub,
)
self._send(frame)
return self.recv_write_ack(expected_sub=rsp_sub)
"""SUB 69: write the waveform-data block (as SUB 09 read it). Ack 0x96;
callers follow with write_confirm C then A. See write_image."""
return self._write_block(SUB_WAVEFORM_DATA_WRITE, data)
def write_compliance_config_raw(self, data: bytes) -> None:
"""SUB 71: write the compliance image in addressed chunks, then confirm (72).
Measured: the image is 2,092 bytes (its header N = 2,090, plus 2), sent as
512-byte chunks with the chunk's address at params[2:4] -- 0x0000, 0x0200,
0x0400, 0x0600, then the 44-byte rest at 0x0800 -- each acked 0x8E, then
SUB 72 (ack 0x8D). Blastware 10.74 on BE9441 (2026-10-26), byte for byte.
March 2026's Blastware sent 1,024-byte chunks the same way; the units took
both. (Retracted: "exactly 3 chunks, offset 0x1004, params 00 00 00 10 04"
-- the length 0x0400 and address 0x0400, read with their escape bytes.)
"""
Send the SUB 71 (COMPLIANCE_WRITE) 3-chunk sequence and final confirm.
The full compliance config payload (~2128 bytes) is split into exactly 3
chunks with hardcoded boundaries and params confirmed from the 3-11-26 BW
TX capture (frames 104–108):
Chunk 1 — first 1027 bytes:
offset=0x1004 params=bytes(10)
device acks SUB 0x8E
Chunk 2 — next 1055 bytes:
offset=0x1004 params=b'\\x00\\x00\\x00\\x00\\x10\\x04' + b'\\x00'*4
device acks SUB 0x8E
Chunk 3 — remaining bytes:
offset=0x002C params=b'\\x00\\x00\\x08' + b'\\x00'*7
device acks SUB 0x8E
Confirm — SUB 72 (zero data):
device acks SUB 0x8D
The total write payload should be at least 1027+1055=2082 bytes; chunk 3
carries everything after offset 2082 (typically ~46 bytes for a 2128-byte
config).
Args:
data: Raw compliance config bytes to write. Must be at least 2082 bytes.
Raises:
ValueError: if data is too short to fill chunks 1 and 2.
ProtocolError: on timeout or wrong response SUB from any chunk.
"""
_CHUNK1_SIZE = 1027
_CHUNK2_SIZE = 1055
_CHUNK1_OFFSET = 0x1004
_CHUNK2_OFFSET = 0x1004
_CHUNK3_OFFSET = 0x002C
_CHUNK1_PARAMS = bytes(10)
_CHUNK2_PARAMS = bytes([0x00, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00])
_CHUNK3_PARAMS = bytes([0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
min_size = _CHUNK1_SIZE + _CHUNK2_SIZE
if len(data) < min_size:
raise ValueError(
f"Compliance write data too short: {len(data)} bytes, "
f"need at least {min_size} (chunk1={_CHUNK1_SIZE} + chunk2={_CHUNK2_SIZE})"
)
rsp_sub = _expected_rsp_sub(SUB_COMPLIANCE_WRITE) # 0xFF - 0x71 = 0x8E
chunk1 = data[:_CHUNK1_SIZE]
chunk2 = data[_CHUNK1_SIZE : _CHUNK1_SIZE + _CHUNK2_SIZE]
chunk3 = data[_CHUNK1_SIZE + _CHUNK2_SIZE :]
chunks = [
(1, chunk1, _CHUNK1_OFFSET, _CHUNK1_PARAMS),
(2, chunk2, _CHUNK2_OFFSET, _CHUNK2_PARAMS),
(3, chunk3, _CHUNK3_OFFSET, _CHUNK3_PARAMS),
]
for chunk_num, chunk_data, chunk_offset, chunk_params in chunks:
frame = build_bw_write_frame(
SUB_COMPLIANCE_WRITE,
chunk_data,
offset=chunk_offset,
params=chunk_params,
)
log.debug(
"write_compliance_config_raw: chunk %d %d bytes "
"offset=0x%04X params=%s",
chunk_num, len(chunk_data), chunk_offset, chunk_params.hex(),
)
image = write_image(SUB_COMPLIANCE_WRITE, data)
rsp_sub = _expected_rsp_sub(SUB_COMPLIANCE_WRITE)
for addr in range(0, len(image), _COMPLIANCE_CHUNK):
params = bytes([0x00, 0x00, (addr >> 8) & 0xFF, addr & 0xFF]) + bytes(6)
frame = build_bw_write_frame(SUB_COMPLIANCE_WRITE,
image[addr:addr + _COMPLIANCE_CHUNK], params=params)
log.debug("write_compliance_config_raw: chunk at 0x%04X", addr)
self._send(frame)
self.recv_write_ack(expected_sub=rsp_sub)
log.debug("write_compliance_config_raw: chunk %d acked", chunk_num)
# Final confirm (SUB 72)
log.debug("write_compliance_config_raw: sending confirm (SUB 0x72)")
self.write_confirm(SUB_WRITE_CONFIRM_A)
log.debug("write_compliance_config_raw: done")
def write_trigger_config(self, data: bytes) -> S3Frame:
"""SUB 82: write the trigger block (as SUB 0x2E read it). Ack 0x7D;
callers follow with write_confirm(SUB_TRIGGER_CONFIRM). See write_image."""
return self._write_block(SUB_TRIGGER_CONFIG_WRITE, data)
def read_trigger_config(self) -> bytes:
"""SUB 0x2E two-step read: the 26-byte trigger block that SUB 82 writes.
Blastware reads it before writing it (BE9441, 2026-10-26). Its byte 5
differs by unit and session (01 / 03 / 04 on record) -- so a block copied
from another unit, as apply_config once wrote, changes a setting.
Returns the block unescaped (data[11:] after unescape_reply).
"""
Send a SUB 82 (TRIGGER_CONFIG_WRITE) frame and await the confirm ack (SUB 7D).
Offset formula: data[1] + 2 — same pattern as write_event_index().
Confirmed from 3-11-26 BW TX capture frame 108:
data[0:4] = 00 1a d5 00 (data[1]=0x1A=26 → offset=0x1C=28)
data length = 29, offset = 28
Write sequence fragment:
82 (data) → device acks with SUB 0x7D
83 (confirm) → device acks with SUB 0x7C
Callers should call write_confirm(SUB_TRIGGER_CONFIRM) after this.
Args:
data: Raw trigger-config payload bytes to write.
Must be at least 2 bytes. data[1] must contain the length field.
Returns:
The SUB 0x7D ack frame.
Raises:
ProtocolError: on timeout or wrong response SUB.
ValueError: if data is shorter than 2 bytes.
"""
if len(data) < 2:
raise ValueError(f"trigger config write payload must be at least 2 bytes, got {len(data)}")
rsp_sub = _expected_rsp_sub(SUB_TRIGGER_CONFIG_WRITE) # 0xFF - 0x82 = 0x7D
offset = data[1] + 2
frame = build_bw_write_frame(SUB_TRIGGER_CONFIG_WRITE, data, offset=offset)
log.debug(
"write_trigger_config: %d bytes data[1]=0x%02X offset=0x%04X rsp_sub=0x%02X",
len(data), data[1], offset, rsp_sub,
)
self._send(frame)
return self.recv_write_ack(expected_sub=rsp_sub)
rsp_sub = _expected_rsp_sub(SUB_UNKNOWN_2E)
length = DATA_LENGTHS[SUB_UNKNOWN_2E]
self._send(build_bw_frame(SUB_UNKNOWN_2E, 0))
self._recv_one(expected_sub=rsp_sub)
self._send(build_bw_frame(SUB_UNKNOWN_2E, length))
data_rsp = self._recv_one(expected_sub=rsp_sub)
return unescape_reply(data_rsp.data)[11:11 + length]
# ── Call home config (SUBs 0x2C / 0x7E / 0x7F) ──────────────────────────
@@ -1278,20 +1173,13 @@ class MiniMateProtocol:
ValueError: if data is not exactly 127 bytes or lacks expected header.
ProtocolError: on timeout or wrong response SUB.
"""
if len(data) < 2:
raise ValueError(f"call home write payload must be at least 2 bytes, got {len(data)}")
rsp_sub_write = _expected_rsp_sub(SUB_CALL_HOME_WRITE) # 0xFF - 0x7E = 0x81
rsp_sub_confirm = _expected_rsp_sub(SUB_CALL_HOME_CONFIRM) # 0xFF - 0x7F = 0x80
# Offset formula: data[1] + 2 (same pattern as other single-chunk writes)
offset = data[1] + 2 # 0x7C + 2 = 0x7E = 126
frame = build_bw_write_frame(SUB_CALL_HOME_WRITE, data, offset=offset)
log.debug(
"write_call_home_config: %d bytes data[1]=0x%02X offset=0x%04X",
len(data), data[1], offset,
)
self._send(frame)
self.recv_write_ack(expected_sub=rsp_sub_write)
# 2026-10-27 (#46): the read payload holds the parser's kept escape bytes
# (num_retries 3 arrives as 10 03); write_image removes them, so the
# 127-byte "read + 00 00" goes out as its 126-byte image (N = 0x7C, + 2),
# escaped like every request. No Blastware call-home write is on record
# here to compare against -- inferred from the 77 other write frames.
self._write_block(SUB_CALL_HOME_WRITE, data)
log.debug("write_call_home_config: write acked; sending confirm 0x7F")
confirm_frame = build_bw_write_frame(SUB_CALL_HOME_CONFIRM, b"")