Files
seismo-relay/tests/test_minimate_serial_decode.py
T
serversdownandClaude Opus 5.5 a8cc516601 fix(minimateplus): SUB 0x15's serial is a C string -- cut at the first NUL
BE9441 (MiniMate bench, 2026-10-25) answers b"BE9441\x00?": six characters,
the terminator, a leftover byte.  rstrip(b"\x00") kept the "?", so the serial
read "BE9441\x00?" and the serial-named path refused every request as the wrong
unit (409).  Seven-character serials fill the field to the terminator, which is
why no earlier unit showed it.  The legacy /device/info output is cleaned too.
No codec, store or DB change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-25 17:14:11 -04:00

31 lines
1.2 KiB
Python

"""SUB 0x15's serial is a C string in an 8-byte field: cut at the first NUL.
BE9441 (bench, 2026-10-25) answers `BE9441\\x00?` -- six characters, the
terminator, then a leftover byte. Stripping only trailing NULs kept the `?`, so
the serial read as "BE9441\\x00?" and every serial-named request was refused as
the wrong unit. Seven-character serials (BE11529, BE18189) fill the field up to
the terminator, which is why this never showed before.
"""
from __future__ import annotations
from minimateplus.client import _decode_serial_number
_HEADER = bytes(11) # data[0:11]: the section header
def _reply(field8: bytes, trail: int = 0x00, fw_minor: int = 0x11) -> bytes:
return _HEADER + field8 + bytes([trail, fw_minor])
def test_a_six_character_serial_stops_at_its_terminator():
assert _decode_serial_number(_reply(b"BE9441\x00?")).serial == "BE9441"
def test_a_seven_character_serial_is_unchanged():
info = _decode_serial_number(_reply(b"BE18189\x00", trail=0x2A, fw_minor=0x11))
assert (info.serial, info.firmware_minor) == ("BE18189", 0x11)
def test_a_short_payload_also_stops_at_the_terminator():
assert _decode_serial_number(_HEADER + b"BE9441\x00?").serial == "BE9441"