Skip to content

fix: swallow Arduino boot-glitch frames after (re)connect#4

Merged
PalmarHealer merged 1 commit into
mainfrom
fix/arduino-reset-glitch-frames
Jun 7, 2026
Merged

fix: swallow Arduino boot-glitch frames after (re)connect#4
PalmarHealer merged 1 commit into
mainfrom
fix/arduino-reset-glitch-frames

Conversation

@PalmarHealer

Copy link
Copy Markdown
Contributor

What

Fixes two user-reported runtime bugs with a shared root cause, plus parser hardening.

Root cause

Opening the serial port toggles DTR, which resets the Arduino. For ~1s while it boots, its pins float to garbage — analog pins read near max and button pins read HIGH. Those frames are valid CSV, so the engine acted on them:

  • floating button pin → fresh 0→1 edge → fires Openphantom "Open Spotify"
  • floating analog pins → every configured volume flashes to 100% (~250ms) before real frames restore it

It recurs "randomly" because any USB hiccup reconnects the session, re-resetting the board each time.

Changes

  • events.rs — 1s post-(re)connect settle window: frames are mirrored to the UI but emit no commands and don't poison the edge-detection baseline. The first good frame past the window re-baselines buttons and re-syncs slider volumes to the real physical positions.
  • protocol.rs — reject lines whose field count ≠ FRAME_FIELDS so a corruption-merged line can't be processed as a misaligned frame (defense-in-depth). Added a unit test.

Test

  • cargo test --bin slidr protocol:: → 4 passed (incl. new rejects_extra_fields)
  • Release build verified GUI-subsystem (no console) and launches cleanly.

Note

The separate "console window on boot" report needs no code change here — already fixed on main by 89a3568; it just needs a rebuild/reinstall.

🤖 Generated with Claude Code

Opening the serial port toggles DTR, which resets the Arduino. For ~1s
while it boots, its pins float to garbage: analog pins read near max
(every configured volume jumps to 100%) and button pins read HIGH (a
fresh 0->1 edge fires Open -> a phantom "Open Spotify"). These frames are
valid CSV, so the engine acted on them. It recurs randomly because any
USB hiccup reconnects the session, re-resetting the board each time.

- events.rs: add a 1s post-(re)connect settle window that mirrors frames
  to the UI but emits no commands and doesn't poison the edge-detection
  baseline; on the first good frame past the window, re-baseline buttons
  and re-sync slider volumes to the real physical positions.
- protocol.rs: reject lines whose field count != FRAME_FIELDS so a
  corruption-merged line can't be processed as a misaligned frame
  (defense-in-depth); add a unit test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PalmarHealer PalmarHealer merged commit 3d19b97 into main Jun 7, 2026
@PalmarHealer PalmarHealer deleted the fix/arduino-reset-glitch-frames branch June 7, 2026 20:34
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