Skip to content

Upload fails in subsequent windows with Serial Monitor open #726

Closed
@per1234

Description

@per1234

Describe the bug

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:

  1. Close port in Serial Monitor
  2. Complete upload process
  3. Reopen port in Serial Monitor

🐛 This works as expected in the first IDE window you open, but it no longer works in subsequent windows.

NOTE: although similar, this is different from #586 because it occurs even when the port is not open in a Serial Monitor/Serial Plotter of another IDE window.

To Reproduce

  1. Connect an Arduino board to your computer.
  2. Select the appropriate board and port.
  3. Select Tools > Serial Monitor from the Arduino IDE menus to open Serial Monitor.
  4. Select Sketch > Upload from the Arduino IDE menus.
    🙂 Upload succeeds as expected.
  5. Select Tools > Serial Monitor from the Arduino IDE menus to close Serial Monitor.
    This is necessary to avoid Upload fails if port is open in Serial Monitor of another window #586
  6. Select File > New from the Arduino IDE menus.
  7. Select Tools > Serial Monitor from the Arduino IDE menus in the new window.
    🐛 Note that there is an unexpected banner in Serial Monitor:

    Not connected. Select a board and a port to connect automatically.

  8. Select Sketch > Upload from the Arduino IDE menus.
    🐛 Upload fails with an error something like "avrdude: ser_open(): can't open device "\.\COM7": Access is denied."

Expected behavior

Upload with Serial Monitor open in the same IDE window to always be handled automagically.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-rc3
    Date: 2021-12-22T15:46:56.004Z
    CLI Version: 0.20.2 [13783819]

Additional context

It is not necessary to leave the original window open to reproduce the bug. It occurs even if that window is closed.


I bisected the issue to 767b09d (it does not occur at 8839793).


Originally reported at https://forum.arduino.cc/t/upload-failed-when-serial-monitor-is-open/940255

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions