feat(s3): assemble a settings read into the 2,090-byte block
Unescape each 1A data frame, take data[11:], drop the one non-content byte that starts every frame but the last: 2,090 bytes headed by N = 2090, Series IV's 0x1A layout. Measured on BE9441's 10-26 recording (12 reads, both frame patterns); the read after each Blastware write equals the image written. read_compliance_content is strict (a missing frame raises) and unjudged (a monitoring unit's device-info answer comes back for the caller to recognise). 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
e3a77e421d
commit
1bb15573fc
4 files changed
+163
No files matched your search
@@ -1132,6 +1132,21 @@ class MiniMateClient:
|
||||
read-modify-write (`call_home_image`)."""
|
||||
return self._require_proto().read_call_home_config()
|
||||
|
||||
def read_compliance_content(self) -> bytes:
|
||||
"""The 1A settings read as the logical 2,090-byte block, unjudged (a
|
||||
monitoring unit's device-info answer comes back as it is; see
|
||||
`minimateplus.protocol.is_compliance_content`)."""
|
||||
return self._require_proto().read_compliance_content()
|
||||
|
||||
def read_settings_blocks(self) -> dict:
|
||||
"""The four blocks a settings write sends back, each as its read returns it:
|
||||
event index (08), settings (1A, logical), trigger (2E), waveform data (09)."""
|
||||
proto = self._require_proto()
|
||||
return {"event_index": proto.read_event_index(),
|
||||
"compliance": proto.read_compliance_content(),
|
||||
"trigger": proto.read_trigger_config(),
|
||||
"waveform": proto.read_waveform_data_raw()}
|
||||
|
||||
def write_call_home_image(self, image: bytes) -> None:
|
||||
"""Send a `0x7E` image (`call_home_image`) and its `0x7F` confirm, each ack
|
||||
checked -- framed once, never unescaped again. Raises ImageRefused before
|
||||
|
||||
@@ -169,6 +169,33 @@ class ImageRefused(ValueError):
|
||||
"""A write refused before any byte was sent: the image is not a whole block."""
|
||||
|
||||
|
||||
# ── The settings block (SUB 1A), as content ─────────────────────────────────
|
||||
#
|
||||
# Measured 2026-11-03 on BE9441's 10-26 recording (12 reads, both Blastware's
|
||||
# 4 x 512 + 42 pattern and SFM's 1024 + 1024 + 42): unescape each data frame and
|
||||
# take data[11:]; every frame but the last then starts with one `00` that is not
|
||||
# content. Dropped, the frames join into 2,090 bytes that start with their own
|
||||
# length N = 2090 -- Series IV's 0x1A content layout -- and the read after each
|
||||
# of Blastware's two writes equals the image it had just written.
|
||||
# tests/test_s3_settings_read.py.
|
||||
|
||||
COMPLIANCE_CONTENT_LEN = 2090
|
||||
|
||||
|
||||
def assemble_compliance_content(frames: "list[bytes]") -> bytes:
|
||||
"""Join a 1A read's data frames (each S3Frame.data, kept escapes and all, in
|
||||
order) into the logical settings block. Judges nothing: a monitoring unit's
|
||||
device-info answer assembles too -- `is_compliance_content` tells them apart."""
|
||||
parts = [unescape_reply(bytes(f))[11:] for f in frames]
|
||||
return b"".join(p[1:] for p in parts[:-1]) + (parts[-1] if parts else b"")
|
||||
|
||||
|
||||
def is_compliance_content(block: bytes) -> bool:
|
||||
"""Whether `block` is the settings block: 2,090 bytes headed by N = 2090."""
|
||||
return (len(block) == COMPLIANCE_CONTENT_LEN
|
||||
and int.from_bytes(block[0:2], "big") == COMPLIANCE_CONTENT_LEN)
|
||||
|
||||
|
||||
def is_call_home_block(raw: bytes) -> bool:
|
||||
"""Whether a 0x2C reply payload is the call-home block: it starts with its own
|
||||
length N = 0x7C (00 7C DC on every read on record) and is N (or N + 2) bytes
|
||||
@@ -1029,6 +1056,25 @@ class MiniMateProtocol:
|
||||
|
||||
return bytes(config)
|
||||
|
||||
def read_compliance_content(self) -> bytes:
|
||||
"""The 1A read as the logical settings block (see assemble_compliance_content).
|
||||
|
||||
The same requests as read_compliance_config -- probe, then B / C / D -- but
|
||||
strict: a data frame that does not arrive raises, and there is no tail
|
||||
drain, so a short read is never assembled. Returns whatever assembled,
|
||||
unjudged; a MONITORING unit answers with its device-info block, which
|
||||
is_compliance_content() rejects.
|
||||
"""
|
||||
rsp_sub = _expected_rsp_sub(SUB_COMPLIANCE)
|
||||
self._send(build_bw_frame(SUB_COMPLIANCE, 0, bytes([0, 0, 0, 0, 0, 0, 0, 0x64, 0, 0])))
|
||||
self._recv_one(expected_sub=rsp_sub)
|
||||
frames = []
|
||||
for offset, page in ((0x0400, 0x00), (0x0400, 0x04), (0x002A, 0x08)):
|
||||
self._send(build_bw_frame(SUB_COMPLIANCE, offset,
|
||||
bytes([0, 0, page, 0, 0, 0, 0, 0x64, 0, 0])))
|
||||
frames.append(self._recv_one(expected_sub=rsp_sub).data)
|
||||
return assemble_compliance_content(frames)
|
||||
|
||||
# ── Write commands (SUBs 68–83) ───────────────────────────────────────────
|
||||
|
||||
def recv_write_ack(
|
||||
|
||||
Reference in new issue
Block a user