fix(protocol): add record_time based chunk scaling for longer event record times
This commit is contained in:
+16
-7
@@ -885,13 +885,22 @@ def device_event_blastware_file(
|
||||
def _do():
|
||||
with _build_client(port, baud, host, tcp_port, timeout=120.0) as client:
|
||||
info = client.connect()
|
||||
# Use full_waveform=False (stop_after_metadata=True) — stops when
|
||||
# "Project:" is found in the 5A stream. Content is byte-identical to
|
||||
# BW for Continuous/Single-Shot events; our file is slightly shorter
|
||||
# (~286 bytes of extra ADC signal BW includes past the metadata).
|
||||
# full_waveform=True corrupts the body: silence chunks past the event
|
||||
# contain device-internal pointers that embed extra STRT records.
|
||||
events = client.get_events(full_waveform=False, stop_after_index=index)
|
||||
# Calculate extra ADC chunks to download after finding "Project:".
|
||||
# BW downloads ~2 extra chunks per second of record time.
|
||||
# Without enough extra chunks the termination response contains no
|
||||
# footer bytes and Blastware rejects the file.
|
||||
rectime = 1.0
|
||||
try:
|
||||
rectime = float(info.compliance_config.record_time or 1.0)
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
pass
|
||||
extra_chunks = max(1, round(rectime * 2))
|
||||
log.info("blastware_file: rectime=%.1fs → extra_chunks=%d", rectime, extra_chunks)
|
||||
events = client.get_events(
|
||||
full_waveform=False,
|
||||
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
|
||||
ev, info = _run_with_retry(_do, is_tcp=_is_tcp(host))
|
||||
|
||||
Reference in New Issue
Block a user