Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Serial Monitor loses connection after PC sleeps #1895

Copy link
Copy link
Open
@per1234

Description

@per1234
Issue body actions

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

  1. 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");
      }
    }
  2. Open the Serial Monitor view.
  3. Select "9600" from the baud rate menu.
    🙂 hello is printed in the Serial Monitor output field at 1 Hz.
  4. Type foo in the Serial Monitor message field.
  5. Press the Enter key.
    🙂 foo is echoed in the Serial Monitor output field.
  6. Put the computer to sleep.
  7. 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.
  8. Type foo in the Serial Monitor message field.
  9. 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

  1. Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
    image
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselfRelated to content of the project itselftopic: serial monitorRelated to the Serial MonitorRelated to the Serial Monitortype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.