Description
Describe the problem
When connection to a port is lost while it was open in Serial Monitor, Arduino IDE 2.x attempts to reconnect and displays warning notifications when that fails:
This is a reasonable behavior when the port is disconnected from Serial Monitor unexpectedly. However, there is also a common case where disconnection of the port is expected: during uploads. These warnings are occasionally displayed during that process, which can cause unnecessary confusion or annoyance to the users.
The Arduino IDE uses the serial ports of Arduino boards in two different ways:
- Uploading sketches
- Communication via Serial Monitor
The port can not be used for both of these things simultaneously. The IDE handles the condition of Serial Monitor being open when an upload is started automagically like so:
- Disconnect port from Serial Monitor
- Complete upload process
- Reconnect port in Serial Monitor
🐛 It seems that the third step is sometimes attempted while the upload is still in progress, resulting in these unhelpful notifications:
To reproduce
- Connect a MKR or Nano 33 IoT board to your computer.
- Open the port of the board in Serial Monitor.
- Upload to the board.
- Wait for the upload to finish, watching the notifications that are displayed at the bottom right corner of the Arduino IDE window.
If the only notification is "Done uploading", repeat from step (3) until you see the unhelpful additional notifications during the upload.
Expected behavior
Warning notifications should only be displayed if there is a problem that needs to be brought to the user's attention.
Serial Monitor should not attempt any reconnects until the upload process has finished.
Arduino IDE version
2.0.0-beta.12-nightly.20211115
Operating system
Windows
Operating system version
10
Additional context
Originally reported at #271 (comment):
There are a series of pop-up toasts that pop up when you upload a changed sketch while the serial monitor is open warning that the port's not available, etc. These are distracting, and not useful if you're handling the closing of the port, the upload, and the re-opening in the background. They should be kept in the error log, not in pop-up toasts.
The issue is intermittent for me. It occurs approximately once in five uploads.
I was not able to reproduce the issue with Leonardo, Mega, or Nano 33 BLE.
I have never encountered the issue when Serial Monitor was not open.
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details