fix: update STRT record parsing to reflect confirmed offsets and derive total/pretrig_samples from compliance config

This commit is contained in:
2026-04-14 18:32:16 -04:00
parent dbb9febe2c
commit c5a7914032
2 changed files with 105 additions and 99 deletions
+21 -6
View File
@@ -188,15 +188,30 @@ the `b'STRT'` magic bytes:
| +10..13 | prev_event_key | ✅ 3 events |
| +18 | mode byte: 0x46 ('F') = single-shot, 0x0E = continuous | ✅ |
**UNCONFIRMED — total_samples and pretrig_samples locations unknown:**
**CONFIRMED (2026-04-14) — total_samples and pretrig_samples are NOT stored in the STRT record.**
The prior documented offsets (+14..15 for total_samples, +16..17 for pretrig_samples) were
WRONG — confirmed by cross-checking STRT-derived rectime against compliance record_time
(4-14-26): all 3 events give STRT-derived rectime of 2161 s vs actual 3.0 s (ratio 720×).
The "confirmed 4-9-26" note in prior versions was incorrect.
(4-14-26): all 4 events give STRT-derived rectime of 2161 s vs actual 3.0 s (ratio 720×).
Extending the STRT dump to 32 bytes confirmed that bytes 21+ are the start of the raw ADC
waveform samples, not more STRT fields. Blastware itself derives total_samples and
pretrig_samples from the compliance config — exactly what our fallback does.
The true offsets for total_samples and pretrig_samples within STRT have not been located.
**Until they are found, `_decode_a5_waveform` relies on the compliance-config cross-check
fallback for all total_samples and pretrig_samples values.**
**The compliance-config fallback IS the correct permanent solution, not a workaround.**
`_decode_a5_waveform` uses:
- `pretrig_samples = round(0.25 × sample_rate)` (compliance monitoring standard)
- `total_samples = pretrig_samples + round(record_time × sample_rate)`
**CONFIRMED (2026-04-14) — waveform starts at strt_pos + 21 (no preamble).**
The original `sp + 27` skip (STRT 21B + null-pad 2B + 0xFF-sentinel 4B) was WRONG.
The 6-byte "preamble" in the 4-2-26 blast capture (`00 00 ff ff ff ff`) was actually the
first ~0.75 sample-sets of quiet pre-trigger ADC data misread as padding. Desk-thump
events show different bytes at positions 21-26 (e.g. `00 10 02 00 ff fc`) — they are real
ADC readings, not a fixed preamble. The `sp + 27` skip discarded 6 bytes of real waveform
data and misaligned the channel decode for all subsequent frames. Fixed: `wave = w[sp+21:]`.
The +6..9 next_key and +10..13 prev_key fields are confirmed across 4 events including the
first-event-after-erase case (prev_key = self-reference `01110000`; next_key = device
pre-allocates the predicted next slot even before any second event exists).
**CRITICAL — strt[18] is a record-mode byte, NOT rectime_seconds (confirmed 2026-04-14):**
Analysis of 15 distinct STRT records across the 4-9-26 ACH capture shows: