debug: figuring out whats wrong with waveform viewer

This commit is contained in:
2026-04-14 16:00:14 -04:00
parent 0da88ec6aa
commit 4f4c1a8f64
3 changed files with 118 additions and 88 deletions
+15 -1
View File
@@ -1395,6 +1395,18 @@ def _decode_a5_waveform(
total_samples = struct.unpack_from(">H", strt, 14)[0]
pretrig_samples = struct.unpack_from(">H", strt, 16)[0]
# Sanity check: pretrig must be less than total_samples.
# If not, the STRT layout is suspect (DLE-stuffing shift, different record variant, etc.).
# Log the raw bytes for diagnosis and clamp pretrig to 0 so the viewer renders.
if pretrig_samples >= total_samples:
log.warning(
"_decode_a5_waveform: pretrig_samples=%d >= total_samples=%d"
"STRT layout suspect. Raw strt[0:21]: %s "
"Clamping pretrig to 0 for rendering.",
pretrig_samples, total_samples, strt[0:21].hex(' '),
)
pretrig_samples = 0
# strt[18] is a record-mode/type byte, NOT rectime in seconds.
# Confirmed from analysis of 4-9-26 ACH capture (15 distinct events):
# flags=0xFFFE (single-shot) → strt[18]=0x46 ('F') for all events regardless of duration
@@ -1412,8 +1424,10 @@ def _decode_a5_waveform(
log.debug(
"_decode_a5_waveform: STRT total_samples=%d pretrig=%d "
"strt[18]=0x%02X (mode byte, not seconds) computed_rectime=%ds",
"strt[18]=0x%02X (mode byte, not seconds) computed_rectime=%ds "
"raw strt[0:21]: %s",
total_samples, pretrig_samples, strt[18], rectime_seconds,
strt[0:21].hex(' '),
)
# ── Collect per-frame waveform bytes with global offset tracking ─────────