Skip to content

Add robust serial reconnection for DrawingThread - #58

Merged
MidnightJava merged 1 commit into
MidnightJava:mainfrom
timoteuszelle:fix/drawing-thread-reconnect
Jun 30, 2026
Merged

MidnightJava merged 1 commit into
MidnightJava:mainfrom
timoteuszelle:fix/drawing-thread-reconnect

Conversation

@timoteuszelle

@timoteuszelle timoteuszelle commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add resilient serial recovery in DrawingThread after panel write failures
  • close/reset dead serial handle on exception and attempt reconnect automatically
  • use reconnect backoff to avoid tight retry loops when the device is temporarily unavailable
  • restore animate state after reconnect so behavior remains consistent

Root cause

When a panel serial write fails (Error in DrawingThread / I/O failure), the thread could continue looping on a dead serial handle without restoring connectivity. That leaves one side stale until a process restart.

Validation

  • syntax check: python -m py_compile led_mon/drawing.py
  • mock reconnection scenario: forced write failure -> failed reconnect -> successful reconnect and resumed draw

- close and reset dead serial handles on write failures
- reconnect with exponential backoff
- restore animate state after reconnect
- keep processing frames when the device returns
@MidnightJava

Copy link
Copy Markdown
Owner

Looks good!

@MidnightJava
MidnightJava merged commit 280433e into MidnightJava:main Jun 30, 2026
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