From d4b1b834a7fb2ecd464c949429e9d1487f64a7d7 Mon Sep 17 00:00:00 2001 From: Brian Harrison Date: Wed, 1 Apr 2026 14:20:12 -0400 Subject: [PATCH] fix: refine SUB 1A compliance config read parameters and logging --- minimateplus/protocol.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index 0a52194..09b05ff 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -397,7 +397,7 @@ class MiniMateProtocol: def read_compliance_config(self) -> bytes: """ - Send the SUB 1A (CHANNEL_SCALING / COMPLIANCE_CONFIG) two-step read. + Send the SUB 1A (COMPLIANCE_CONFIG) two-step read. Returns the full 2090-byte compliance config block (E5 response) containing: @@ -413,22 +413,33 @@ class MiniMateProtocol: Raises: ProtocolError: on timeout, bad checksum, or wrong response SUB. - Confirmed from protocol reference §7.6: - - SUB 1A request uses all-zero params - - E5 response is 2090 bytes (0x082A fixed length) - - Response data section: data[11:11+0x082A] + Confirmed from raw BW captures (3-11-26): + Probe (Frame A): [5]=0x00, params[7]=0x64 + Data req (Frame D): [5]=0x2A, params[2]=0x08, params[7]=0x64 + + The 16-bit length 0x082A is split across two fields: + byte[5] = 0x2A (offset/length low byte, as in all two-step reads) + params[2] = 0x08 (length high byte, packed into params rather than byte[4]) + + params[7] = 0x64 = 100 is required in both probe and data request. + Purpose unknown — possibly max channel count or backlight timeout. """ rsp_sub = _expected_rsp_sub(SUB_COMPLIANCE) - length = 0x082A # 2090 bytes, fixed length for compliance config + # Probe — params[7]=0x64 required (confirmed from BW capture) + _PROBE_PARAMS = bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00]) log.debug("read_compliance_config: 1A probe") - self._send(build_bw_frame(SUB_COMPLIANCE, 0)) + self._send(build_bw_frame(SUB_COMPLIANCE, 0, _PROBE_PARAMS)) self._recv_one(expected_sub=rsp_sub) - log.debug("read_compliance_config: 1A data request offset=0x%04X", length) - self._send(build_bw_frame(SUB_COMPLIANCE, length)) + # Data request — 0x082A encoded as: byte[5]=0x2A, params[2]=0x08, params[7]=0x64 + # NOT as a uint16 split across bytes[4:5] — confirmed from BW capture 3-11-26. + _DATA_PARAMS = bytes([0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00]) + log.debug("read_compliance_config: 1A data request offset=0x2A params[2]=0x08") + self._send(build_bw_frame(SUB_COMPLIANCE, 0x2A, _DATA_PARAMS)) data_rsp = self._recv_one(expected_sub=rsp_sub) + length = 0x082A # 2090 bytes total expected config = data_rsp.data[11:11 + length] log.debug("read_compliance_config: received %d config bytes", len(config)) return config