diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index f6c5f13..9a2041f 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -522,10 +522,21 @@ class MiniMateProtocol: try: rsp = self._recv_one(expected_sub=rsp_sub, reset_parser=False) except TimeoutError: + raw = self._parser.bytes_fed log.warning( "5A TIMEOUT chunk=%d counter=0x%04X raw_bytes=%d", - chunk_num, counter, self._parser.bytes_fed, + chunk_num, counter, raw, ) + if raw > 0 and frames_data: + # Device sent a partial byte (likely a bare DLE/ETX end-of-stream + # signal) but never completed a full frame. Treat as graceful + # stream end and fall through to the termination step. + log.warning( + "5A end-of-stream detected at chunk=%d (raw_bytes=%d, " + "frames_collected=%d) — proceeding to termination", + chunk_num, raw, len(frames_data), + ) + break raise log.warning(