Skip to content

Port left open after closing Serial Plotter #1423

Open
@per1234

Description

@per1234

Describe the problem

If one process has a serial port open, another can not access it. Arduino IDE is designed to automatically manage access to ports by the various operations and components that use them:

  • Uploading sketches
  • Serial Monitor
  • Serial Plotter
  • Updating radio module firmware
  • Uploading SSL certificates to radio module

The user may also use the port from an external application during sketch development in Arduino IDE. They will be responsible for managing the access of the port by the IDE and the external application. This means that the IDE must always relinquish port access when the user closes a component using the port

🐛 The port is left open after closing the Serial Plotter window.

To reproduce

  1. Select a serial port in the Arduino IDE.
  2. Select Tools > Serial Plotter from the Arduino IDE menus to open the "Serial Plotter".
  3. Close the "Serial Plotter" window.
  4. Open the port in an external application.

🐛 Opening the port fails.

Expected behavior

Port is closed when Serial Plotter window is closed.

Arduino IDE version

2.0.0-rc9.4

Operating system

Windows, Linux

Operating system version

Windows 10, Ubuntu 20.04

Additional context

From Windows Task Manager and GNOME System Monitor, I can see that the serial-monitor process is not being closed when the Serial Plotter window is closed.


I bisected the introduction of the issue to df8658e


The problem does not occur if the procedure described above is performed using Serial Monitor instead of Serial Plotter (in fact cycling Serial Monitor open and then closed again closes the port after it was left open by Serial Plotter).


The issue does not occur when using Arduino IDE 1.8.19 Serial Monitor


Some options for external applications that can be used for the final step in the demo:

$ arduino-cli upload --fqbn arduino:avr:uno --port COM7
avrdude: ser_open(): can't open device "\\.\COM7": Access is denied.
$ arduino-cli upload --fqbn arduino:samd:mkrzero --port COM47
TOUCH: error during reset: opening port at 1200bps: Serial port busy
No device found on COM47
Error during Upload: Failed uploading: uploading error: exit status 1
$ arduino-cli monitor --port COM7
Port monitor error: command 'open' failed: Serial port busy

Opening the port in Arduino IDE 1.x Serial Monitor

Error opening serial port 'COM7'. (Port busy)

Additional reports

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

Labels

criticality: mediumOf moderate impacttopic: codeRelated to content of the project itselftype: imperfectionPerceived 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