fix(framing): checksum_valid sums the reply's payload unescaped

S3FrameParser summed its payload with the kept `10` of each `10 02/03/04`
still in, so checksum_valid was False on about a third of good replies (the
old "S3 checksums frequently fail" belief).  SUM8 of the unescaped payload
is the unit's checksum on 7,747 of 7,747 recorded replies; the test pins it
on the 2,509 in the committed October fixtures (62 with an escaped checksum),
which also proves #58's split of data from checksum on real replies.

Nothing decides on checksum_valid; seismo_lab's display stops crying wolf.

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-11-06 14:54:45 -05:00
1 parent 89c5234ac0
commit 47da0ddef0
2 files changed
+17 -1

No files matched your search

+3 -1
View File
@@ -764,7 +764,9 @@ class S3FrameParser:
n_chk = 2 if body[-2] == DLE and body[-1] in (STX, ETX, 0x04) else 1
raw_payload = body[:-n_chk] # everything except the checksum
chk_received = body[-1]
chk_computed = checksum(raw_payload)
# SUM8 of the payload unescaped: the kept `10` of a `10 02/03/04` is not
# summed (7,747 of 7,747 recorded replies check this way).
chk_computed = checksum(unescape_reply(raw_payload))
if len(raw_payload) < 5:
return None
+14
View File
@@ -75,6 +75,20 @@ def test_a_last_data_byte_of_0x10_survives_an_escaped_checksum(chk):
assert (unescape_reply(f.data), f.chk_byte) == (data, chk)
REPLY_RECORDINGS = ["minimate-bench-10-25-26/BE9441_event0_01110000_rx.bin",
"minimate-bench-10-25-26/BE9441_event1_0111646a_rx.bin",
"minimate-bench-10-26-26-blastware/unit_replies.bin",
"minimate-bench-10-26-26-histogram/unit_replies.bin"]
@pytest.mark.parametrize("name", REPLY_RECORDINGS)
def test_every_recorded_reply_checks(name):
# BE9441, October 2026: 2,509 replies, 62 with an escaped checksum.
frames = S3FrameParser().feed((FIX / name).read_bytes())
assert frames
assert [i for i, f in enumerate(frames) if not f.checksum_valid] == []
@pytest.mark.parametrize("chk", [0x10, 0x00, 0x55])
def test_any_other_checksum_reads_as_before(chk):
data = data_for(chk, last=0x10)