Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
mpremote: Fix disconnect handling on Windows and Linux.#17321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- Handle SerialException on Windows when device disconnects- Print clean 'device disconnected' message instead of stack trace- Fix terminal formatting issues on Linux after disconnect- Return disconnected state after console cleanup to avoid terminal issuesThis ensures proper disconnect messages on both platforms withoutshowing confusing error traces to users.Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
codecovbot commentedMay 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## master #17321 +/- ##==========================================- Coverage 98.54% 98.54% -0.01%========================================== Files 169 169 Lines 21898 21897 -1 ==========================================- Hits 21580 21579 -1 Misses 318 318 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code size report:
|
Josverl commentedMay 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think this is a good improvement to make I notice that you have not added or changed any tests. |
Good point! I've been trying to get better at test coverage lately but yeah I'm not sure how to test a feature like this without hardware in the loop. |
Summary
Improves device disconnection handling in mpremote to show a clean "device disconnected" message instead of stack traces on Windows and fixes terminal formatting issues on Linux.
Problem
When a device disconnects during an mpremote session:
Solution
This PR fixes disconnect handling to:
File Changes
tools/mpremote/mpremote/console.py
:tools/mpremote/mpremote/repl.py
:tools/mpremote/mpremote/main.py
:Testing
Before/After Examples - I connected to ESP32S2 (usb serial) and once confirmed the repl is working, physically unplug the devices.
Windows (Before)
Windows (After)
Linux (Before)
Linux (After)