fix(protocol): refine extra chunk fetching logic for accurate termination response
This commit is contained in:
+9
-13
@@ -885,21 +885,17 @@ def device_event_blastware_file(
|
||||
def _do():
|
||||
with _build_client(port, baud, host, tcp_port, timeout=120.0) as client:
|
||||
info = client.connect()
|
||||
# Download extra chunks after "Project:" until the footer marker
|
||||
# 0x0e 0x08 is detected in a chunk tail. The cap prevents
|
||||
# accidentally downloading into post-event silence.
|
||||
# Cap = rectime * 4 + 4 covers up to ~10 sec events safely.
|
||||
rectime = 1.0
|
||||
try:
|
||||
rectime = float(info.compliance_config.record_time or 1.0)
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
pass
|
||||
extra_chunks = max(4, int(rectime * 6) + 8) # generous cap; silence detection stops early
|
||||
log.info("blastware_file: rectime=%.1fs → extra_chunks_cap=%d", rectime, extra_chunks)
|
||||
# Use full_waveform=True (stop_after_metadata=False) so the device
|
||||
# streams until it naturally signals end-of-stream (1-raw-byte signal).
|
||||
# BW does the same — the ACH download and manual pull both let the device
|
||||
# determine when to stop. The termination response at that point contains
|
||||
# the correct 0e 08 footer with monitoring timestamps.
|
||||
# For Continuous/Single-Shot events, end-of-stream comes after the real
|
||||
# ADC data (not after 35+ silence chunks as in Histogram+Continuous mode).
|
||||
# max_chunks=32 is a safety cap; natural end-of-stream stops much earlier.
|
||||
events = client.get_events(
|
||||
full_waveform=False,
|
||||
full_waveform=True,
|
||||
stop_after_index=index,
|
||||
extra_chunks_after_metadata=extra_chunks,
|
||||
)
|
||||
matching = [ev for ev in events if ev.index == index]
|
||||
return matching[0] if matching else None, info
|
||||
|
||||
Reference in New Issue
Block a user