-
-
Notifications
You must be signed in to change notification settings - Fork 799
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serial Monitor should handle disconnects more gracefully #3939
Comments
For references, here is the slightly different traceback on MacOS:
|
This is a basic thing (e.g. done by the Arduino IDE monitor), so I'd like to see it. Most UI's would use some connection status indicator (Arduino IDE uses backgroud color), but for a simple text terminal it should be enough to print Maybe this is complicated by device / port autodetection by |
pyserial itself doesn't have any special reconnect support: pyserial/pyserial#558 if |
options for implementing reconnect:
|
I implemented |
@belm0, thank you so much for your contribution to the OSS. How about having a separate PR that just catches exceptions or exits gracefully without reconnecting? Typically, this issue arises when a user does not close the serial terminal but unplugs the board. |
I think a common case is uploading to a device. It will reset the device and cause a lost connection. This means that the monitor must be restarted after each upload. Since I now have the enhanced miniterm written anyway, I'll try a PR that adds that code locally to platformio. |
You can't upload to the device if you don't close the serial monitor. Otherwise, you will receive |
I see-- it's my misunderstanding. Uploading and monitoring have to be coordinated.
It's not possible to suppress the exception trace with the current miniterm, unless the stderr is filtered somehow. So this too would need a miniterm fork. |
Is it possible to refactor your PR to suppress unhandled exceptions? |
It depends ... with ST-Link, a uC reset does not generate a USB reset/re-enumerate condition, so re-flashing will keep a terminal session intact if it's running in a separate window. I'm not sure this applies here, just wanted to flag this case. |
😢 My very very humble outsider 🪙🪙 would be-- miniterm is not magical, it's got a bunch of weird warts/bugs, and most of its features (menus that let you dynamically change settings and switch to new ports and such) aren't particularly interesting in this use case. Replacing it with something solid that just shuffles data between the serial port and the terminal (without blocking), handles disconnection gracefully, and allows robust cancellation would seem like a decent move to me. |
Agree with you. We will work on this. |
Agreed that miniterm is not magical. It's just an example use of the pyserial library, and they added it to the public API for better or worse. While it's a noble intention to replace it with something simple (and perhaps remove pyserial dependency altogether), it's not necessary. There are probably more important places for platformio developers to invest their time. Forking the miniterm example for our own purposes seems fine (as it uses the public pyserial API). Ivan, please consider again this #4268 (comment). |
@ivankravets The suggested "advanced" serial monitor leaves a lot to be desired. The main feature of |
Hi All! Great news! Huge refactoring to the device monitor logic and it seems this issue has been solved. Also, automatic reconnection has been implemented. Please re-test with Does it work as expected now? |
@ivankravets Thank you very much for this correction! |
Hello, I still have the issue on my ESP32-S3 using Windows 11 computer.
I tried pio upgrade --dev, it did update but the problem is still there. |
Same problem here. When I reset the board, the output is just gone. It doesn't auto reconnect. Manually entering something will cause this message and the device works again. Also WIN11 if that matters. |
Also same behaviour on an Adafruit MatrixPortal S3, if I use ESP.restart() in my script, the Serial Monitor disconnects when the ESP32S3 reboots. Also have to manually reset after uploading code for program to start.
|
Edit from maintainers - Temporary solution: https://docs.platformio.org/en/latest/faq/advanced-serial-monitor.html
Serial Monitor should handle disconnects more gracefully
This is a bug report/feature request to improve the serial port functionality in Platform IO.
Configuration
Operating system: Windows 10 x64
PlatformIO Version (
platformio --version
):PlatformIO Core, version 5.1.1
Description of problem
Using serial monitor on a USB based serial port crashes with Exception
Steps to Reproduce
pio device monitor
Actual Results
Expected Results
An error message designed for a novice user to understand.
Ideally also (optional) automatic reconnect when the device comes back.
The text was updated successfully, but these errors were encountered: