Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening Serial Monitor during upload causes it to fail #581

Closed
3 tasks done
per1234 opened this issue Oct 28, 2021 · 3 comments
Closed
3 tasks done

Opening Serial Monitor during upload causes it to fail #581

per1234 opened this issue Oct 28, 2021 · 3 comments
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 28, 2021

Describe the problem

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

🐛 It does not currently handle the reverse, where the Serial Monitor is opened while an upload is in progress. This results in a confusing upload failure.

To reproduce

  1. Close Serial Monitor if it is already open.
  2. Start an upload to an Arduino board.
    NOTE: because it is timing sensitive, the issue will be difficult to reproduce with a minimal sketch that compiles very quickly, especially on a subsequent compilation when the libraries have already been cached. Use a larger sketch to accurately simulate real world conditions.
  3. While the compilation process that occurs before the actual upload starts is still in progress, select Tools > Serial Monitor from the Arduino IDE windows.
    The board's port is now opened in Serial Monitor.
  4. Wait for the upload process to finish.
    🐛 Note that the upload has failed with an error something like:
    avrdude: ser_open(): can't open device "\\.\COM7": Access is denied.
    

Expected behavior

Don't allow user to break upload by opening Serial Monitor.

Arduino IDE 1.x allows Serial Monitor to be opened during upload, but it is in a disabled state where the opening of the port is deferred until after the upload finishes, behaving just the same as when an upload is started with Serial Monitor already open:

image

Arduino IDE version

2.0.0-beta.12-nightly.20211028

Operating system

Windows

Operating system version

10

Additional context

Originally reported at #271 (comment)

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
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: serial monitor Related to the Serial Monitor labels Oct 28, 2021
@tigoe
Copy link
Member

tigoe commented Mar 11, 2022

This error is still present in 2.0.0-rc3. And here's a fun new variation:

If you open the serial port after compile but before upload, you'll get the error

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

This persists even if you have a board and port selected.

Same steps to reproduce as above. Only difference is in the timing of the opening.

@tigoe
Copy link
Member

tigoe commented Aug 2, 2022

Sorry to report this problem is back in Version: 2.0.0-rc9.1
Date: 2022-08-02T13:31:56.030Z
CLI Version: 0.25.1 [436f0bb9]

Steps to reproduce it:

  1. open a sketch
  2. select board
  3. upload
  4. open serial monitor
  5. open a second sketch
  6. select same board
  7. upload
    You'll get
Failed uploading: uploading error: exit status 1No device found on cu.usbmodem143301

In the previous version, two windows could play nicely with the same port. You could have the serial monitor open in one or both, and the serial messages would show up in whichever window was open. If you uploaded from either window, that window took precedence and uploaded the code.

In the current version, you have to close the serial monitor in ALL WINDOWS to upload code. It's as if you went back to the serial configuration from several versions ago.

Tested with a Nano 33 IoT.

@per1234
Copy link
Contributor Author

per1234 commented Aug 3, 2022

Thanks so much for your report @tigoe. The bug you are experiencing is completely different from the one tracked by this issue. This issue is specifically about about the upload being caused to by the user opening Serial Monitor during an "Upload" operation.

I thank you for reminding me of this issue though because it cause me to test it and discover that it was fixed last November by #597 but the developers didn't bother to close the issue at that time.

The newly introduced bug you reported here, which causes uploads to fail whenever Serial Monitor is open (even when it was opened before the "Upload" operation was initiated) is now being tracked in a dedicated issue here:

#1278

If you end up with additional information to share, feel free to comment in the other thread.

@per1234 per1234 closed this as completed Aug 3, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Aug 3, 2022
@per1234 per1234 assigned per1234 and unassigned fstasi Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants