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.

@hfudev hfudev requested a review from horw April 17, 2026 14:15
@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown
Title Coverage Tests Skipped Failures Errors Time
Qemu Coverage 7 0 💤 0 ❌ 0 🔥 25.512s ⏱️
3.14 X64 Coverage 117 16 💤 0 ❌ 0 🔥 15m 33s ⏱️
3.10 ARM64 Coverage 117 18 💤 0 ❌ 0 🔥 12m 56s ⏱️

@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

hfudev commented Apr 17, 2026

Copy link
Copy Markdown
Member

Thank you. LGTM!

@horw PTAL.

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 force-pushed the bugfix/auto-reconnect-original-instance branch from 7596863 to a9e990f Compare June 3, 2026 08:53
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