`pio device monitor` doesn't reconnect proactively when resetting ESP32
#5231 opened on Aug 16, 2025
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.