harden USB telemetry transport
This commit is contained in:
+16
-5
@@ -7,9 +7,9 @@ from pathlib import Path
|
||||
|
||||
from trikke_protocol import (
|
||||
CSV_COLUMNS,
|
||||
PACKET_FLAG_TIMESTAMP_DELTA_SATURATED,
|
||||
PACKET_TYPE_METADATA,
|
||||
Frame,
|
||||
IntegrityTracker,
|
||||
StreamParser,
|
||||
sample_to_csv_row,
|
||||
)
|
||||
@@ -40,13 +40,12 @@ def main() -> int:
|
||||
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
sample_count = 0
|
||||
timestamp_saturation_frame_count = 0
|
||||
integrity = IntegrityTracker()
|
||||
with args.output.open("w", encoding="utf-8", newline="") as target:
|
||||
writer = csv.writer(target)
|
||||
writer.writerow(CSV_COLUMNS)
|
||||
for frame in frames:
|
||||
if frame.flags & PACKET_FLAG_TIMESTAMP_DELTA_SATURATED:
|
||||
timestamp_saturation_frame_count += 1
|
||||
integrity.observe(frame)
|
||||
if frame.packet_type == PACKET_TYPE_METADATA:
|
||||
if frame.metadata is not None:
|
||||
metadata = frame.metadata
|
||||
@@ -62,7 +61,19 @@ def main() -> int:
|
||||
f"startup_crc_rejects={stream.startup_crc_errors}, "
|
||||
f"stream_crc_errors={stream.crc_errors}, header_errors={stream.header_errors}, "
|
||||
f"skipped_nonframe_bytes={stream.skipped_bytes}, "
|
||||
f"timestamp_saturation_frames={timestamp_saturation_frame_count}, "
|
||||
f"packet_gaps={integrity.packet_gap_count}, "
|
||||
f"packet_resets={integrity.packet_reset_count}, "
|
||||
f"sample_gaps={integrity.sample_gap_count}, "
|
||||
f"sample_resets={integrity.sample_reset_count}, "
|
||||
f"timing_anomalies={integrity.timing_anomaly_count}, "
|
||||
"timestamp_saturation_frames="
|
||||
f"{integrity.timestamp_saturation_frame_count}, "
|
||||
f"accel_stale={integrity.accel_stale_count}, "
|
||||
f"accel_overrun={integrity.accel_overrun_count}, "
|
||||
f"gyro_stale={integrity.gyro_stale_count}, "
|
||||
f"gyro_overrun={integrity.gyro_overrun_count}, "
|
||||
f"dropped={integrity.final_dropped_sample_count}, "
|
||||
f"acquisition_loop_overruns={integrity.final_loop_overrun_count}, "
|
||||
f"trailing_partial_bytes={stream.buffered_bytes}; saved {args.output}"
|
||||
)
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user