diag: per-chunk WARNING logging in 5A bulk stream loop
Wraps each recv_one call in a try/except TimeoutError, logging: - On timeout: chunk_num, counter, raw bytes_fed (distinguishes "device silent" from "device sent unparseable bytes") - On success: chunk_num, page_key, data_len, contains_Project flag Parser is explicitly reset before each chunk recv so bytes_fed is accurate per-chunk rather than cumulative. Helps identify exactly which chunk fails and whether the device is responding at all. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -518,7 +518,20 @@ class MiniMateProtocol:
|
|||||||
params = bulk_waveform_params(key4, counter)
|
params = bulk_waveform_params(key4, counter)
|
||||||
log.debug("5A chunk %d counter=0x%04X", chunk_num, counter)
|
log.debug("5A chunk %d counter=0x%04X", chunk_num, counter)
|
||||||
self._send(build_5a_frame(_BULK_CHUNK_OFFSET, params))
|
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:
|
if rsp.page_key == 0x0000:
|
||||||
# Device unexpectedly terminated mid-stream (no termination needed).
|
# Device unexpectedly terminated mid-stream (no termination needed).
|
||||||
@@ -526,10 +539,6 @@ class MiniMateProtocol:
|
|||||||
return frames_data
|
return frames_data
|
||||||
|
|
||||||
frames_data.append(rsp.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:
|
if stop_after_metadata and b"Project:" in rsp.data:
|
||||||
log.debug("5A A5[%d] metadata found — stopping early", chunk_num)
|
log.debug("5A A5[%d] metadata found — stopping early", chunk_num)
|
||||||
|
|||||||
Reference in New Issue
Block a user