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

#1032 failing upload flag for monitor mgr #1040

Merged
merged 28 commits into from
Jun 22, 2022

Conversation

davegarthsimpson
Copy link
Contributor

@davegarthsimpson davegarthsimpson commented Jun 10, 2022

Motivation

Users have reported that with some boards our core upload functionality breaks if attempted with a Serial Monitor open.

Change description

Ensures that when we upload to a board that has an open Serial Monitor, we pause the related serial monitor process. We also prevent new monitor services from starting during upload, and use a "queue & reconcile later" mechanism to deal with start attempts during upload.

Additional Important Info

During investigation we found that changes were also needed in the arduino-cli in order to ensure correct flow of events during upload with a Serial Monitor open. CLI PR.

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@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 Jun 11, 2022
@davegarthsimpson davegarthsimpson changed the title 1032 failing upload flag for monitor mgr #1032 failing upload flag for monitor mgr Jun 13, 2022
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE: Resolved by 5260a07 / arduino/arduino-cli#1771

I am still able to reproduce #1032 using the tester build from https://github.com//pull/1040/commits/fff607551fba7f1ec2aca5ba2abeba9ee4af072e

Same procedure and symptoms as reported on the issue: upload to the "1200 bps touch" boards (I tested with MKR Zero, Leonardo, Micro) fails on Windows with Serial Monitor open. Uploading works just fine with Serial Monitor closed.

@per1234
Copy link
Contributor

per1234 commented Jun 14, 2022

An update on my previous report: After further experimentation I discovered that I was able to get a successful upload with the Serial Monitor open after plugging my Arduino board into specific USB ports of my computer. I also discovered that the upload error would occur even on my other computer when the board was connected to an otherwise usable USB port through a specific USB hub (but not when using other hubs). So it seems the ability to reproduce the error I reported is dependent on specific hardware configurations of how the board is connected to the PC.

This seems to be a different situation from #1032, which I have found to occur consistently on my Windows machines even when using the USB connection configuration that produces a successful upload when using the test build from this PR.

@AlbyIanna AlbyIanna force-pushed the 1032-uploads-failing-with-monitor-open branch from cc12bc0 to 209ac69 Compare June 14, 2022 13:08
@davegarthsimpson davegarthsimpson marked this pull request as draft June 15, 2022 17:01
@davegarthsimpson davegarthsimpson self-assigned this Jun 17, 2022
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE: fixed by c892ce3 or a7c8806

Describe the problem

Using the build from 6e264a6, uploading to a native USB board with Serial Monitor open causes Serial Monitor to go into a permanently disconnected state:

image

To reproduce

  1. Connect a native USB board (e.g., Leonardo) to your computer.
  2. Select the board and port.
  3. Open the "Serial Monitor" View.
  4. Click the "Upload" button.
  5. Wait for the upload to finish successfully.
  6. Select the "Serial Monitor" View.

🐛 The Serial Monitor is not connected to the board's port:

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

Arduino IDE version

2.0.0-rc7-snapshot-6e9c8af (the build from 6e264a6)

Operating system

Windows, Linux

Operating system version

Windows 10, Ubuntu 20.04

Additional context

After it gets into this state, the Serial Monitor remains this way even after closing and reopening the view, unplugging/replugging the board, attempting to use the monitor with another board and port. The only way to recover it is by opening an new Arduino IDE window or restarting the Arduino IDE.


The issue does not occur when using a board with a dedicated USB chip (e.g., Uno, Mega).

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe the problem

When uploading to a native USB board with Serial Monitor open, the "Serial Monitor" view takes visibility from the "Output" view twice during the upload:

sm-focus

🐛 Users who want to monitor the upload process via the "Output" view will find it inconvenient to lose sight of it in the middle of the process, and then have to select the view once more after every upload.

To reproduce

  1. Connect a native USB board (e.g., Leonardo) to your computer.
  2. Select the board and port in the Arduino IDE.
  3. Open the "Serial Monitor" view.
  4. Select the "Output" view.
  5. Click the "Upload" button.

🐛 The view visible in the bottom panel is switched multiple times, as follows:

  1. "Output" view
  2. "Serial Monitor" view
  3. "Output" view
  4. "Serial Monitor" view

Note that the view that is visible after the process finishes does not match the user's selected focus.

Expected behavior

The "Output" view retains visibility throughout and after the upload process.

Arduino IDE version

2.0.0-rc7-snapshot-b1c06fa (The build from a7c8806)

Operating system

Windows 10

I am not able to reproduce the issue on my Linux machine.

@davegarthsimpson
Copy link
Contributor Author

davegarthsimpson commented Jun 20, 2022

Hi @per1234 with regards to the panels changing focus, this is a known issue from the original feature PR, and actually something I was looking to improve today, though I'm not sure if it's in the scope of this PR (as it's not related to the upload failing...what do you think?).

Essentially whenever a user unplugs and plugs a board back in we reset (close and reopen) the serial monitor & plotter. Windows changes ports during upload with USB native, which looks to the IDE like a user unplugging and then plugging back in a board, hence a reset is triggered. In this case it'd definitely be a nicer UX to maintain focus on the output during upload. This is not so complicated as we know when we're uploading.

However, when the upload finishes in this scenario Windows often switches back the port, again this seems like a user plugging in a board so the focus goes to the monitor. As this happens after upload we don't have a reliable way of knowing if the "port change" was due to the upload finishing, or a user plugging in a board.

In short we can maintain focus during upload but switching back to the monitor afterwards may be unavoidable in some cases.

@davegarthsimpson davegarthsimpson marked this pull request as ready for review June 21, 2022 15:23
@fstasi fstasi self-requested a review June 21, 2022 15:59
Copy link
Contributor

@fstasi fstasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: approving this PR as we need to address issues users are experiencing quickly. A new refactor is due before stable release

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is working perfectly for me now.

Thanks Dave!

@davegarthsimpson davegarthsimpson merged commit a54d7c8 into main Jun 22, 2022
@davegarthsimpson davegarthsimpson deleted the 1032-uploads-failing-with-monitor-open branch June 22, 2022 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging this pull request may close these issues.

Uploads to native USB boards fail when Serial Monitor or Plotter is open
4 participants