Description
Describe the problem
Serial Monitor is the primary tool for Arduino IDE users to get runtime feedback from a sketch program. Since it is not intrusive and does not interfere with the usability of the other Arduino IDE UI components, the average user likely has the Serial Monitor open most of the time.
Putting the computer through a sleep/wake cycle while Serial Monitor is open causes loss of connection to the port.
🐛 When in this state, Serial Monitor does not show data sent by the board and does not transmit messages the user sends from the message field. It does not give any indication of the lost connection to the user.
To reproduce
- Upload a sketch that produces periodic serial output and also has an observable response to serial input:
unsigned long previousMillis; void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { while (Serial.available() > 0) { Serial.write(Serial.read()); delay(10); } } else if (millis() - previousMillis >= 1000) { previousMillis = millis(); Serial.println("hello"); } }
- Open the Serial Monitor view.
- Select "9600" from the baud rate menu.
🙂hello
is printed in the Serial Monitor output field at 1 Hz. - Type
foo
in the Serial Monitor message field. - Press the Enter key.
🙂foo
is echoed in the Serial Monitor output field. - Put the computer to sleep.
- Wake the computer.
🐛hello
is no longer printed in the Serial Monitor output field at 1 Hz, even though the TX LED on the Arduino board shows it is transmitting serial data.
🐛 There is no indication of a lost connection in the Serial Monitor UI. - Type
foo
in the Serial Monitor message field. - Press the Enter key.
🐛 The RX LED does not blink on the Arduino board to indicate serial data was received.
🐛foo
is not echoed in the Serial Monitor output field.
Expected behavior
Putting computer through a sleep/wake cycle does not cause the loss of Serial Monitor's connection to the port.
-OR-
The loss of the connection is clearly communicated to the user (related issue: #1508).
Arduino IDE version
Original report
d68bc4a (with serial-monitor 0.13.0)
Last verified with
8f8b46f (with serial-monitor 0.13.0)
Operating system
- Windows
- macOS
Operating system version
- Windows 11
- macOS Ventura
Additional context
I was not able to reproduce the issue on my Linux (Ubuntu 22.04) machine.
The fault does not occur under the same conditions when using arduino-cli monitor
, the Arduino CLI gRPC interface with grpcurl, or Arduino IDE 1.8.19
When the arduino.cli.daemon.debug
setting is enabled, I see this in the logs from the time the PC is put to sleep:
2023-02-19 19:07:01 2023-02-20T03:07:01.601Z monitor-service INFO stopped monitor to COM34 using serial
2023-02-19 19:07:01 2023-02-20T03:07:01.603Z daemon INFO 51 | ERROR: EOF
51 | REQ: {}
�[36mINFO�[0m[0036] sending command �[36mcommand�[0m=CLOSE �[36mmonitor�[0m=serial-monitor
2023-02-19 19:07:01 2023-02-20T03:07:01.609Z daemon INFO �[36mINFO�[0m[0036] received message �[36merror�[0m=false �[36mevent_type�[0m=close �[36mmessage�[0m=OK �[36mmonitor�[0m=serial-monitor
�[36mINFO�[0m[0036] sending command �[36mcommand�[0m=QUIT �[36mmonitor�[0m=serial-monitor
�[36mINFO�[0m[0036] received message �[36merror�[0m=false �[36mevent_type�[0m=quit �[36mmessage�[0m=OK �[36mmonitor�[0m=serial-monitor
�[36mINFO�[0m[0036] Killing monitor process �[36mmonitor�[0m=serial-monitor
�[31mERRO�[0m[0036] stopped decode loop: EOF �[31mmonitor�[0m=serial-monitor
2023-02-19 19:07:01 2023-02-20T03:07:01.614Z daemon INFO �[31mERRO�[0m[0036] Waiting for process end �[31merror�[0m="exit status 1" �[31mmonitor�[0m=serial-monitor
�[36mINFO�[0m[0036] Monitor process killed �[36mmonitor�[0m=serial-monitor
51 STREAM CLOSED
But there is no equivalent log output to indicate an attempt to start the monitor process again after the PC wakes.
The fault occurs both with boards that have a dedicated USB chip (e.g., Uno) and boards with native USB (e.g., Leonardo).
Originally reported at: https://forum.arduino.cc/t/ide-disconnect-form-the-board-after-pc-suspension/1092323
Additional reports
Workaround
- Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
- Open Serial Monitor again by clicking the icon on the IDE toolbar or selecting Tools > Serial Monitor from the Arduino IDE menus.
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