fix: Move lines=[] above lock in _read_cb() (Issue #683) #684

Merged
sl-jetson merged 1 commits from sl-jetson/issue-683-read-cb-fix into main 2026-03-18 07:49:03 -04:00
Collaborator

Summary

  • lines = [] was defined inside the with self._ser_lock: else-branch, but referenced outside the lock in the for raw in lines: loop
  • When _ser is None (port not open), the else-branch never runs, lines is never defined → UnboundLocalError
  • Fix: move lines = [] to top of _read_cb(), before acquiring the lock

Test plan

  • Deploy to Jetson, confirm node starts cleanly with serial disconnected
  • Reconnect serial, verify telemetry flows and no UnboundLocalError in logs

Closes #683

🤖 Generated with Claude Code

## Summary - `lines = []` was defined inside the `with self._ser_lock:` else-branch, but referenced outside the lock in the `for raw in lines:` loop - When `_ser is None` (port not open), the else-branch never runs, `lines` is never defined → `UnboundLocalError` - Fix: move `lines = []` to top of `_read_cb()`, before acquiring the lock ## Test plan - [ ] Deploy to Jetson, confirm node starts cleanly with serial disconnected - [ ] Reconnect serial, verify telemetry flows and no UnboundLocalError in logs Closes #683 🤖 Generated with Claude Code
sl-jetson added 1 commit 2026-03-17 22:38:11 -04:00
UnboundLocalError when _ser is None — lines was only assigned inside
the else branch. Move initialisation to function scope so the for-loop
outside the lock always has a valid list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit d132b74df0 into main 2026-03-18 07:49:03 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#684
No description provided.