Skip to content

Fix live UART data loss and time-axis glitches - #16

Merged
kaklik merged 1 commit into
masterfrom
fix/uart-live-data-loss
Sep 2, 2026
Merged

Fix live UART data loss and time-axis glitches#16
kaklik merged 1 commit into
masterfrom
fix/uart-live-data-loss

Conversation

@kaklik

@kaklik kaklik commented Sep 1, 2026

Copy link
Copy Markdown
Member

The live serial reader rebuilt the full time/sum/spectral history from scratch on every incoming record, making per-record work grow with session length; once that fell behind the incoming baud rate, the OS serial buffer could overflow and drop bytes. It also used readline() with a timeout, which silently truncates a line that arrives slower than the timeout, corrupting or dropping that record. Parsing failures were swallowed with bare except: pass, so none of this was visible.

  • Replace the growing-list-to-array rebuild with amortized O(1) append buffers (_GrowableArray/_GrowableMatrix) so per-record cost stays constant over a session.
  • Read raw bytes and split on '\n' ourselves instead of relying on readline(timeout=...), so a slow/bursty record is only parsed once it has fully arrived.
  • Log dropped/malformed records instead of discarding them silently.
  • Drop the $STOP timestamp fallback that substituted the run index for time (compressing the x-axis); fall back to host wall-clock time only when the device itself reports no timestamp (no RTC).

The live serial reader rebuilt the full time/sum/spectral history from
scratch on every incoming record, making per-record work grow with
session length; once that fell behind the incoming baud rate, the OS
serial buffer could overflow and drop bytes. It also used readline()
with a timeout, which silently truncates a line that arrives slower
than the timeout, corrupting or dropping that record. Parsing
failures were swallowed with bare `except: pass`, so none of this was
visible.

- Replace the growing-list-to-array rebuild with amortized O(1)
  append buffers (_GrowableArray/_GrowableMatrix) so per-record cost
  stays constant over a session.
- Read raw bytes and split on '\n' ourselves instead of relying on
  readline(timeout=...), so a slow/bursty record is only parsed once
  it has fully arrived.
- Log dropped/malformed records instead of discarding them silently.
- Drop the $STOP timestamp fallback that substituted the run index
  for time (compressing the x-axis); fall back to host wall-clock
  time only when the device itself reports no timestamp (no RTC).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NcmUFSZ3EJwkN4DcJpcMKN
@kaklik
kaklik merged commit e0bc63a into master Sep 2, 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.

2 participants