fix(protocol): add record_time based chunk scaling for longer event record times

This commit is contained in:
2026-04-23 17:33:16 -04:00
parent 2a2031c3a9
commit aa2b02535b
5 changed files with 56 additions and 26 deletions
+20 -16
View File
@@ -527,6 +527,7 @@ class MiniMateProtocol:
stop_after_metadata: bool = True,
max_chunks: int = 32,
include_terminator: bool = False,
extra_chunks_after_metadata: int = 1,
) -> list[S3Frame]:
"""
Download the SUB 5A (BULK_WAVEFORM_STREAM) A5 frames for one event.
@@ -651,22 +652,25 @@ class MiniMateProtocol:
# and primes the device to return a valid footer in the termination
# response. Without it, termination returns an empty ack with no
# footer bytes (confirmed 2026-04-23 from HxD comparison).
log.debug("5A A5[%d] metadata found — fetching one more chunk then stopping", chunk_num)
chunk_num += 1
counter = chunk_num * _BULK_COUNTER_STEP
params = bulk_waveform_params(key4, counter)
self._send(build_5a_frame(_BULK_CHUNK_OFFSET, params))
try:
extra = self._recv_one(expected_sub=rsp_sub, timeout=10.0)
log.debug("5A A5[%d] extra chunk page_key=0x%04X data_len=%d",
chunk_num, extra.page_key, len(extra.data))
if extra.page_key == 0x0000:
if include_terminator:
frames_data.append(extra)
return frames_data
frames_data.append(extra)
except TimeoutError:
log.debug("5A extra chunk timed out — end of stream")
log.debug("5A A5[%d] metadata found — fetching %d more chunk(s) then stopping",
chunk_num, extra_chunks_after_metadata)
for _extra_n in range(extra_chunks_after_metadata):
chunk_num += 1
counter = chunk_num * _BULK_COUNTER_STEP
params = bulk_waveform_params(key4, counter)
self._send(build_5a_frame(_BULK_CHUNK_OFFSET, params))
try:
extra = self._recv_one(expected_sub=rsp_sub, timeout=10.0)
log.debug("5A A5[%d] extra chunk page_key=0x%04X data_len=%d",
chunk_num, extra.page_key, len(extra.data))
if extra.page_key == 0x0000:
if include_terminator:
frames_data.append(extra)
return frames_data
frames_data.append(extra)
except TimeoutError:
log.debug("5A extra chunk %d timed out — end of stream", _extra_n + 1)
break
break
else:
log.warning(