platformio / platformio/platformio-core

`pio device monitor` doesn't reconnect proactively when resetting ESP32

Open
#5,231 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

device management help wanted
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

Original post to the community: https://community.platformio.org/t/how-can-pio-device-monitor-detect-disconnection/48477?u=riywo


I’m looking for a way to reconnect serial monitor automatically when the device is unplugged then plugged, or pushed the RST. Especially because I want to capture logs from setup(). I’m using Seeed XIAO ESP32 S3 from Windows 11.

Although pio device monitor has auto reconnection by default (#3939), it doesn’t recognize the disconnection itself until I hit any key. Once I hit a key, it tries to send the key and raises an exception, thus reconnects:

(I hit a key)
Disconnected (ClearCommError failed (PermissionError(13, 'The device does not recognize the command.', None, 22)))
Reconnecting to COM14    Connected!

I wonder whether we have a workaround or we can add a new feature to do some keepalive check proactively so that it can reconnect immediately?

I'll try to create a PR when I have a time, but please let me know if someone has already solved this problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pio device monitor entry point and reproduce the reset or unplug/replug behavior on Windows 11 with the Seeed XIAO ESP32 S3. Check how disconnection is detected without keyboard input; done means the monitor notices the disconnect and reconnects automatically so logs from setup() can be captured.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.