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
This commit is contained in:
1 parent
5527fcd91f
commit
a8cc516601
2 files changed
+35
-2
No files matched your search
@@ -1305,12 +1305,15 @@ def _decode_serial_number(data: bytes) -> DeviceInfo:
|
||||
# Actual serial payload starts at data[11].
|
||||
actual = data[11:] if len(data) > 11 else data
|
||||
|
||||
# The serial is a C string: cut at the first NUL. A short serial leaves a
|
||||
# stray byte after its terminator (BE9441 sends b"BE9441\x00?"), so
|
||||
# stripping trailing NULs alone is not enough.
|
||||
if len(actual) < 9:
|
||||
# Short payload — gracefully degrade
|
||||
serial = actual.rstrip(b"\x00").decode("ascii", errors="replace")
|
||||
serial = actual.split(b"\x00", 1)[0].decode("ascii", errors="replace")
|
||||
return DeviceInfo(serial=serial, firmware_minor=0)
|
||||
|
||||
serial = actual[:8].rstrip(b"\x00").decode("ascii", errors="replace")
|
||||
serial = actual[:8].split(b"\x00", 1)[0].decode("ascii", errors="replace")
|
||||
trail_0 = actual[8] if len(actual) > 8 else None
|
||||
fw_minor = actual[9] if len(actual) > 9 else 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user