Ground truth: Blastware changing BE11529's call-home settings on 2026-04-20 (Remote Access -> Setup Unit), paired raw files of what it sent and what the unit answered: the read, the enable (read 0x00 -> wrote 0x01), the disable (read 0x01 -> wrote 0x00). From the unit's own read before each write, SFM's 0x7E frame (call_home_image + build_bw_write_frame) is Blastware's byte for byte -- nothing but byte 5 differs from the read -- and the 0x7F confirm too. Mutation-checked: inverting the byte SFM writes fails the test. S3_CALL_HOME_FRAME_VERIFIED is now True; the gate stays tested shut by monkeypatch, and a test pins that its comment names this proof. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
65 lines
3.1 KiB
Python
65 lines
3.1 KiB
Python
"""SFM's MiniMate call-home write is Blastware's, frame for frame (phase 4).
|
|
|
|
Ground truth: Blastware changing BE11529's call-home settings on 2026-04-20
|
|
(Remote Access -> Setup Unit), recorded as paired raw files -- what Blastware
|
|
sent (raw_bw_*) and what the unit answered (raw_s3_*). Copied from
|
|
bridges/captures/4-20-26/call home settings/: the read, the enable, the disable.
|
|
For each 0x7E, SFM builds its frame from the unit's own read just before it and
|
|
the value Blastware asked for; it must equal Blastware's frame byte for byte.
|
|
This test is what opens sfm.device_access.s3.S3_CALL_HOME_FRAME_VERIFIED.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from test_minimate_write_frames import _frames, _payload # noqa: E402
|
|
from minimateplus.framing import S3FrameParser, build_bw_write_frame # noqa: E402
|
|
from minimateplus.protocol import ( # noqa: E402
|
|
SUB_CALL_HOME, SUB_CALL_HOME_CONFIRM, SUB_CALL_HOME_WRITE, call_home_image, write_image,
|
|
)
|
|
|
|
FIX = Path(__file__).parent / "fixtures" / "s3-call-home-bw"
|
|
ACTIONS = ["162148_pull_call_home_options", "162221_enable_auto_call_home", "162255_disable_auto_call_home"]
|
|
|
|
|
|
def _action(tag):
|
|
bw = _frames((FIX / f"raw_bw_20260420_{tag}.bin").read_bytes())
|
|
requests = [(_payload(f)[2], f) for f in bw]
|
|
reads = [bytes(f.data)[11:] for f in S3FrameParser().feed((FIX / f"raw_s3_20260420_{tag}.bin").read_bytes())
|
|
if f.sub == 0xFF - SUB_CALL_HOME and len(f.data) > 100]
|
|
return requests, reads
|
|
|
|
|
|
def test_sfm_builds_blastwares_call_home_write():
|
|
last_read, asserted, confirms = None, [], 0
|
|
for tag in ACTIONS:
|
|
requests, reads = _action(tag)
|
|
subs = [s for s, _ in requests]
|
|
if reads and SUB_CALL_HOME_WRITE in subs:
|
|
# this action's read went out before its write
|
|
last_2c = max(i for i, s in enumerate(subs) if s == SUB_CALL_HOME)
|
|
assert last_2c < subs.index(SUB_CALL_HOME_WRITE)
|
|
last_read = reads[-1]
|
|
for sub, frame in requests:
|
|
if sub == SUB_CALL_HOME_WRITE:
|
|
bw_image = _payload(frame)[16:]
|
|
wanted = bw_image[5]
|
|
base = write_image(SUB_CALL_HOME_WRITE, last_read)
|
|
assert wanted in (0x00, 0x01)
|
|
assert [i for i in range(len(base)) if base[i] != bw_image[i] and i != 5] == []
|
|
assert build_bw_write_frame(SUB_CALL_HOME_WRITE, call_home_image(last_read, wanted == 0x01)) == frame
|
|
asserted.append((tag, base[5], wanted))
|
|
elif sub == SUB_CALL_HOME_CONFIRM:
|
|
assert build_bw_write_frame(SUB_CALL_HOME_CONFIRM, b"") == frame
|
|
confirms += 1
|
|
if reads and SUB_CALL_HOME_WRITE not in subs:
|
|
last_read = reads[-1]
|
|
# Blastware turned call-home on (read 0x00 -> 0x01), then off (read 0x01 -> 0x00).
|
|
assert asserted == [("162221_enable_auto_call_home", 0x00, 0x01),
|
|
("162255_disable_auto_call_home", 0x01, 0x00)]
|
|
assert confirms == 2
|