fix: redefines rectime_seconds from strt[18] byte to new computed time.

The server now re-computes rectime_seconds using the actual sample rate from the compliance config (overriding the default 1024 in the client), so if the device runs at 2048 or 4096 sps it's still correct.

Viewer — The rectime display now shows Xs (stored) / Ys (cfg) so you can compare the STRT-derived duration against the compliance config's record_time setting side-by-side. I also clamped the y-axis to ±(0C peak × 1.4) so near-saturation decode artifacts don't squash the real blast signal into a flat line.
This commit is contained in:
2026-04-14 14:19:17 -04:00
parent edb4698bfb
commit 0da88ec6aa
4 changed files with 98 additions and 10 deletions
+28
View File
@@ -163,6 +163,34 @@ record — 5A remains the sole source for those fields and they are set uncondit
`stop_after_metadata=True` (default) stops the 5A loop as soon as `b"Project:"` appears,
then sends the termination frame.
### SUB 5A — STRT record layout and rectime_seconds (CORRECTED 2026-04-14)
The STRT record is 21 bytes embedded at the start of A5[0] data. Offsets relative to
the `b'STRT'` magic bytes:
```
+0..3 b'STRT' magic
+4..5 flags 0xFF 0xFE (single-shot) or 0xFF 0xFD (continuous)
+6..9 key4 4-byte event key
+10..13 prev_key4
+14..15 uint16 BE total_samples (full event sample-set count) ← confirmed 4-9-26
+16..17 uint16 BE pretrig_samples (pre-trigger sample-set count)
+18 uint8 record-MODE byte — NOT rectime in seconds
+19..20 typically 0x00 0x00
```
**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:
- `flags=0xFFFE` (single-shot) → `strt[18] = 0x46` ('F') for EVERY event regardless of duration
- `flags=0xFFFD` (continuous) → `strt[18] = 0x0E` for EVERY event regardless of duration
The actual record duration (post-trigger seconds) must be computed as:
```python
rectime_seconds = int(round((total_samples - pretrig_samples) / sample_rate))
```
`_decode_a5_waveform` uses `sample_rate=1024` as a default; the server overrides with
`compliance_config.sample_rate` when available. Do NOT use `strt[18]` for rectime.
### SUB 5A — end-of-stream signal (confirmed 2026-04-06)
After streaming all waveform chunks, the device sends exactly **1 raw byte** in response to