Skip to content

fix(serial): during auto-reconnect, update all pySerial references (CII-181)#416

Open
ofacklam wants to merge 1 commit into
espressif:mainfrom
ofacklam:bugfix/auto-reconnect-original-instance
Open

fix(serial): during auto-reconnect, update all pySerial references (CII-181)#416
ofacklam wants to merge 1 commit into
espressif:mainfrom
ofacklam:bugfix/auto-reconnect-original-instance

Conversation

@ofacklam
Copy link
Copy Markdown

Description

The previous implementation of the auto-reconnection feature (commit 019e38a) detects connection loss in the reader _event_loop() and proceeds to re-assign the local variable to a fresh pySerial instance. However, the proc member of the Serial class is not updated, and attempts to write to the Serial instance continue to fail even after the reconnection logic succeeded.

Therefore, make _SerialRedirectThread take the Serial instance as argument, instead of the pySerial.Serial object.
The _event_loop() can thus operate on and update the proc member directly.

Related

Testing

Tested locally with an Espressif DevKit, manually disconnecting & reconnecting the serial line


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

The previous implementation of the auto-reconnection feature
(commit 019e38a) detects
connection loss in the reader _event_loop() and proceeds to
re-assign the local variable to a fresh pySerial instance.
However, the `proc` member of the Serial class is not updated,
and attempts to write to the Serial instance continue to fail
even after the reconnection logic succeeded.

Therefore, make _SerialRedirectThread take the Serial instance as
argument, instead of the pySerial.Serial object.
The _event_loop() can thus operate on and update the `proc` member
directly.
@hfudev hfudev requested a review from horw April 17, 2026 14:15
@github-actions
Copy link
Copy Markdown

Title Coverage Tests Skipped Failures Errors Time
3.14 X64 Coverage 103 16 💤 0 ❌ 0 🔥 13m 32s ⏱️
3.10 ARM64 Coverage 103 18 💤 1 ❌ 0 🔥 10m 43s ⏱️
Qemu Coverage 7 0 💤 0 ❌ 0 🔥 25.467s ⏱️

@github-actions github-actions Bot changed the title fix(serial): during auto-reconnect, update all pySerial references fix(serial): during auto-reconnect, update all pySerial references (CII-181) Apr 17, 2026
@hfudev
Copy link
Copy Markdown
Member

hfudev commented Apr 17, 2026

Thank you. LGTM!

@horw PTAL.

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