Skip to content

transport: Fix hangs and lost scripts on stop/exec - #29

Merged
iabdalkader merged 3 commits into
masterfrom
transport_resync_fixes
Nov 7, 2026
Merged

iabdalkader merged 3 commits into
masterfrom
transport_resync_fixes

Conversation

@iabdalkader

Copy link
Copy Markdown
Member

After a script ends the camera soft-reboots and its sequence resets to 0. The host dropped the camera's reply because of the sequence mismatch, and stdout events kept resetting the timeout, so it hung. Separately, stop() returned before the script had exited, so a script uploaded right after could be thrown away when the old one exited.

  • Don't reset the receive timeout on events.
  • Raise on a sequence mismatch so the host resyncs.
  • stop() waits for the script to exit, and exec() stops a running script first.

This still requires firmware fixes.

A camera that keeps sending events (e.g. stdout) while never answering
a command would keep resetting the timeout and hang the host forever.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Packets with a valid header but an unexpected sequence were dropped
silently, so the host waited until the timeout for a response that
would never come (e.g. the camera NAKs with sequence 0 after a soft
reboot). Raise a SequenceException instead so the host resyncs. The
header CRC is now checked before the sequence, so a corrupted header
is skipped rather than raised on.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
STOP only schedules an interrupt, the script may take a while to exit
(e.g. it handles KeyboardInterrupt). A script written before then is
ACKed by the old context and discarded when the script exits. Poll the
stdin channel until the script stops or a timeout expires, and stop a
running script before exec.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@iabdalkader
iabdalkader force-pushed the transport_resync_fixes branch from 1353e7c to 2c9e1d4 Compare November 7, 2026 15:42
@iabdalkader
iabdalkader merged commit a68cd1a into master Nov 7, 2026
2 checks passed
@iabdalkader
iabdalkader deleted the transport_resync_fixes branch November 7, 2026 15:43
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