Skip to content

Detect firmware event-buffer truncation and plot count rate, not raw sums - #17

Merged
kaklik merged 1 commit into
masterfrom
feature/event-buffer-truncation-and-rate-display
Sep 6, 2026
Merged

Detect firmware event-buffer truncation and plot count rate, not raw sums#17
kaklik merged 1 commit into
masterfrom
feature/event-buffer-truncation-and-rate-display

Conversation

@kaklik

@kaklik kaklik commented Sep 6, 2026

Copy link
Copy Markdown
Member

Related to UniversalScientificTechnologies/AIRDOS03#15 (the "spectrum doesn't connect at channel 64" report) and its fix, UniversalScientificTechnologies/AIRDOS03#16.

Summary

  • Warn (file parser and live UART thread) whenever a $STOP's evCount exceeds the number of $E lines actually received — i.e. the firmware's per-interval event buffer was exceeded and the spectrum above THRESHOLD is undercounted for that interval.
  • Parse captStart/stopSystime from $START/$STOP and derive each record's real duration: prefer the delta between consecutive GNSS-synced timestamps (or host wall-clock in the live case), falling back to the raw TCNT1 tick pair (128 µs/tick) when no absolute time is available yet. Persisted through save_as()/NpzLogParser so reopened sessions keep it.
  • Evolution plot now shows counts/sec ("Count rate", cps) whenever a duration is known, since the corresponding firmware change (Flush above-threshold event buffer early instead of waiting out the interval AIRDOS03#16) can now flush the event buffer early on a high-rate burst, producing variable-length intervals whose raw per-record totals aren't directly comparable. Falls back to the previous "Total count per exposition" raw-count display for sources with no duration info (older logs/NPZ archives).

Test plan

  • pytest tests/ passes (8/8).
  • Manual smoke test: synthetic multi-run log exercising GNSS-diff, tick-fallback, and NPZ round-trip duration paths — durations computed as expected.
  • Offscreen (QT_QPA_PLATFORM=offscreen) construction/plot smoke test for PlotCanvas, both with and without duration data, confirming correct axis label and counts/sec values.
  • Manual check with a live device / real log file.

…sums

The AIRDOS03 firmware caps above-threshold events at MAX_EVENTS per
interval; anything past that is silently dropped while the true count
(evCount in $STOP) keeps growing. Nothing surfaced this to the user.
Separately, since the firmware can now flush early when that buffer
fills (see the corresponding AIRDOS03 firmware change), interval length
is no longer fixed, making raw per-record totals hard to compare.

- Warn (file parser and live UART thread) whenever a $STOP's evCount
  exceeds the number of $E lines actually received, i.e. the firmware's
  per-interval event buffer was exceeded and the spectrum above
  THRESHOLD is undercounted for that interval.
- Parse captStart/stopSystime from $START/$STOP and derive each
  record's real duration: prefer the delta between consecutive
  GNSS-synced timestamps (or host wall-clock in the live case), falling
  back to the raw TCNT1 tick pair (128 µs/tick) when no absolute time is
  available yet. Persisted through save_as()/NpzLogParser so reopened
  sessions keep it.
- Evolution plot now shows counts/sec ("Count rate", cps) whenever a
  duration is known, since a shortened (early-flushed) interval and a
  full one are no longer directly comparable as raw sums. Falls back to
  the previous "Total count per exposition" raw-count display for
  sources with no duration info (older logs/NPZ archives).

Verified against the existing test suite plus manual smoke tests
(synthetic multi-run logs exercising GNSS-diff, tick-fallback and
NPZ round-trip paths); no display-side (PyQt) smoke test since this
environment has no display, only offscreen import/construction checks.
@kaklik
kaklik merged commit e313e85 into master Sep 6, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant