diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index c0f3ae6..c5f79c2 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -623,8 +623,7 @@ class MiniMateProtocol: ("D", 0x002A, _DATA_PARAMS), # _DATA_PARAMS built above ] - config = bytearray() - seen_bytes: set[bytes] = set() # exact-content dedup (not page_key+len) + config = bytearray() for step_name, step_offset, step_params in _STEPS: log.debug( @@ -637,32 +636,36 @@ class MiniMateProtocol: data_rsp = self._recv_one(expected_sub=rsp_sub) except TimeoutError: log.warning( - "read_compliance_config: frame %s — no E5 response (timeout); " - "device may return all data on a later request", + "read_compliance_config: frame %s — no E5 response (timeout)", step_name, ) continue chunk = data_rsp.data[11:] - page = data_rsp.page_key - - if chunk in seen_bytes: - log.warning( - "read_compliance_config: frame %s page=0x%04X data=%d " - "cfg_chunk=%d BYTE-IDENTICAL DUPLICATE — skipping", - step_name, page, len(data_rsp.data), len(chunk), - ) - continue - - seen_bytes.add(bytes(chunk)) log.warning( - "read_compliance_config: frame %s page=0x%04X data=%d " - "cfg_chunk=%d running_total=%d", - step_name, page, len(data_rsp.data), + "read_compliance_config: frame %s page=0x%04X data=%d cfg_chunk=%d running_total=%d", + step_name, data_rsp.page_key, len(data_rsp.data), len(chunk), len(config) + len(chunk), ) config.extend(chunk) + # Over TCP/modem the device responses are buffered one step behind: + # each recv() above collected the PREVIOUS send's response, so Frame D's + # real data is still sitting in the buffer. Drain it with a short-timeout + # recv — this is a no-op on direct serial where responses are synchronous. + try: + tail_rsp = self._recv_one(expected_sub=rsp_sub, timeout=3.0) + tail_chunk = tail_rsp.data[11:] + log.warning( + "read_compliance_config: tail drain page=0x%04X data=%d " + "cfg_chunk=%d running_total=%d", + tail_rsp.page_key, len(tail_rsp.data), + len(tail_chunk), len(config) + len(tail_chunk), + ) + config.extend(tail_chunk) + except TimeoutError: + log.debug("read_compliance_config: no tail frame (direct serial or already complete)") + log.warning( "read_compliance_config: done — %d cfg bytes total", len(config),