Description
Describe the problem
When the Arduino IDE Serial Monitor is opened, a pluggable monitor tool process is started. This process may error if the port can't be opened. Inability to open a port is a common problem for Arduino users, usually caused by already having it open in another application, not having set up system permissions for access, or the port being stuck in a glitched state.
The Arduino IDE Serial Monitor does not communicate in any way to the user that there is a problem, nor what the nature of that problem might be when starting monitor process fails after Serial Monitor is opened.
🐛 The user will not understand why the expected output is not being sent or received from Serial Monitor. They, and those supporting them, may waste quite some time studying their code and hardware for problems.
To reproduce
Equipment
- Any Arduino board that produces a serial port.
Steps
- Upload a sketch to your Arduino board that uses serial input and output:
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"); } }
- Close the Arduino IDE 2.x Serial Monitor view if it is open.
- Open the serial port of the Arduino board in any other application.
e.g., Arduino IDE 1.x Serial Monitor,arduino-cli monitor
- Select the port of the Arduino board in the Arduino IDE 2.x Tools > Port menu.
- Select Tools > Serial Monitor from the Arduino IDE 2.x menus to open the Serial Monitor view.
🐛 There is no indication of any problem other than the lack of a baud rate menu:
🐛 The expected "hello" output is not printed.
🐛 Any data sent via the "Message" field is not received by the board.
Expected behavior
Clear communication of the problem when starting a monitor process fails.
Arduino IDE version
2.0.1-snapshot-6f07717
Operating system
Windows
Operating system version
10
Additional context
The logs show the Arduino CLI daemon is communicating the problem to the IDE:
daemon INFO {"level":"info","monitor":"serial-monitor","msg":"Starting monitor process","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"level":"info","monitor":"serial-monitor","msg":"Monitor process started successfully!","time":"2022-09-30T04:07:41-07:00"}
{"command":"HELLO 1 \"arduino-cli 0.27.1\"","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"error":false,"event_type":"hello","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"command":"DESCRIBE","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
{"error":false,"event_type":"describe","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"CONFIGURE dtr on","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"CONFIGURE parity none","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
{"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"CONFIGURE rts on","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"CONFIGURE stop_bits 1","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
{"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"command":"CONFIGURE baudrate 9600","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
{"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"CONFIGURE bits 8","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"error":false,"event_type":"configure","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"command":"OPEN 127.0.0.1:17515 COM7","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"error":true,"event_type":"open","level":"info","message":"Serial port busy","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
{"command":"QUIT","level":"info","monitor":"serial-monitor","msg":"sending command","time":"2022-09-30T04:07:41-07:00"}
{"error":false,"event_type":"quit","level":"info","message":"OK","monitor":"serial-monitor","msg":"received message","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"level":"info","monitor":"serial-monitor","msg":"Killing monitor process","time":"2022-09-30T04:07:41-07:00"}
{"error":"TerminateProcess: Access is denied.","level":"error","monitor":"serial-monitor","msg":"Sent kill signal","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"level":"error","monitor":"serial-monitor","msg":"stopped decode loop: EOF","time":"2022-09-30T04:07:41-07:00"}
daemon INFO {"level":"info","monitor":"serial-monitor","msg":"Monitor process killed","time":"2022-09-30T04:07:41-07:00"}
monitor-service ERROR Error: 2 UNKNOWN: Port monitor error: command 'open' failed: Serial port busy
at Object.callErrorFromStatus (C:\ide 2\tip\135-6f07717\resources\app\node_modules\@grpc\grpc-js\build\src\call.js:31:26)
at Object.onReceiveStatus (C:\ide 2\tip\135-6f07717\resources\app\node_modules\@grpc\grpc-js\build\src\client.js:409:49)
at Object.onReceiveStatus (C:\ide 2\tip\135-6f07717\resources\app\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:328:181)
at C:\ide 2\tip\135-6f07717\resources\app\node_modules\@grpc\grpc-js\build\src\call-stream.js:187:78
at processTicksAndRejections (node:internal/process/task_queues:78:11)
monitor-service INFO monitor to COM7 using serial closed by server
Prior to #982, there was a (misleading) indication of a problem under these conditions:
Arduino IDE 1.x clearly communicates the problem to the user:
Arduino CLI clearly communicates the problem to the command line interface user:
$ arduino-cli monitor --port COM7
Port monitor error: command 'open' failed: Serial port busy
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