diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index c6aa338..f6c5f13 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -518,7 +518,20 @@ class MiniMateProtocol: params = bulk_waveform_params(key4, counter) log.debug("5A chunk %d counter=0x%04X", chunk_num, counter) self._send(build_5a_frame(_BULK_CHUNK_OFFSET, params)) - rsp = self._recv_one(expected_sub=rsp_sub) + self._parser.reset() # reset bytes_fed for accurate per-chunk count + try: + rsp = self._recv_one(expected_sub=rsp_sub, reset_parser=False) + except TimeoutError: + log.warning( + "5A TIMEOUT chunk=%d counter=0x%04X raw_bytes=%d", + chunk_num, counter, self._parser.bytes_fed, + ) + raise + + log.warning( + "5A RX chunk=%d page_key=0x%04X data_len=%d contains_Project=%s", + chunk_num, rsp.page_key, len(rsp.data), b"Project:" in rsp.data, + ) if rsp.page_key == 0x0000: # Device unexpectedly terminated mid-stream (no termination needed). @@ -526,10 +539,6 @@ class MiniMateProtocol: return frames_data frames_data.append(rsp.data) - log.debug( - "5A A5[%d] page_key=0x%04X %d bytes", - chunk_num, rsp.page_key, len(rsp.data), - ) if stop_after_metadata and b"Project:" in rsp.data: log.debug("5A A5[%d] metadata found — stopping early", chunk_num)