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

Enhance board config auto-selection with hardwareId #1913

Merged
merged 15 commits into from
Feb 27, 2023

Conversation

davegarthsimpson
Copy link
Contributor

@davegarthsimpson davegarthsimpson commented Feb 22, 2023

Note

This PR builds on 1885, but its considered fundamentally different as it changes the UX for many other boards.

Motivation

It may be convenient for users if the IDE2 were to "auto-select" a "new" port on their behalf in the following scenario: when they select a board and port, unplug that board from its port, and plug it into a "new" port.

Now that we receive hardwareIds from the CLI for boards that expose them, we can reliably "auto-select" a board/port in the above scenario, as we can distinguish between two boards with the same fqbn.

At present in the unplug/replug scenario we only auto-select a board-port combo when it's unplugged/plugged from/into the same port, or if a port change occur during upload.

Change description

If a specific board's port changes to a "new" port, and that board exposes a hardwareId, its "new" port should always be selected automatically.

These changes are expected to enhance the UX for boards that expose a hardwareId, the UX will not change for boards that do not, for example in my (@davegarthsimpson) testing the Arduino Leonardo does not expose one.

Acceptance Criteria

Boards with hardwareId

-Their port should be automatically re-selected when it changes (while the board remains selected),

  1. due to unplugging it from a port and replugging it into a different port;
  2. due to unplugging it from and replugging it into the same port;
  3. due to an upload, after upload is complete;

Board without hardwareId

-Their port will only be re-selected when it changes (while the board remains selected),

  1. due to unplugging it from and replugging it into the same port;
  2. due to an upload, after upload is complete;

Example boards with hardwareId (to the authors knowledge): Arduino Zero, Arduino Uno
Example boards without hardwareId (to the authors knowledge): Arduino Leonardo, Arduino Due (Native USB Port)

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 type: enhancement Proposed improvement topic: code Related to content of the project itself labels Feb 22, 2023
@kittaakos
Copy link
Contributor

This PR builds on #1885,

If anybody is wondering what's the effective code change: include-hardwareId-in-auto-selection...enhance-auto-selection-with-hardwareId

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

I had one remark regarding the name fallback. The rest look OK to me. Thanks

@davegarthsimpson davegarthsimpson force-pushed the enhance-auto-selection-with-hardwareId branch from 0cee491 to 2fb1757 Compare February 23, 2023 16:44
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. Thanks Dave!

To anyone interested in testing this: I'll share the procedure I found:

Required Equipment

  • A board with the following characteristics:
    • Persistent bootloader mode activated by a double reset
    • Both the application port and the bootloader port have the same hardware ID (usually a serial number)
  • A Windows or macOS PC
    • Linux is not suitable because it doesn't assign different addresses to the application and bootloader ports.

I found that the Portenta H7 was the only board I had on hand with the required characteristics.

Steps

  1. Connect the board to your computer.
  2. Select the board's port in Arduino IDE.
  3. Press and release the reset button on the board twice quickly to put it in bootloader mode.

Before the change made by this PR, no port would be selected after the board's port address changed when it went into bootloader mode.

After the change made by this PR, the port selection automatically follows the board to the address of the bootloader port.

@davegarthsimpson davegarthsimpson requested review from ubidefeo and removed request for ubidefeo February 24, 2023 08:42
Copy link
Contributor Author

@davegarthsimpson davegarthsimpson left a comment

Choose a reason for hiding this comment

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

I have also done manual tests of this PR, involving some testing some hard-coded changes to simulate everything "working as it should" in the process chain.

From my tests, the board selector correctly auto-selects the correct port with hardwareId, when a board exposing a hardwareId disappears from a port and reappears on a different port in a different app state.

@davegarthsimpson davegarthsimpson merged commit 43b5d4e into main Feb 27, 2023
@davegarthsimpson davegarthsimpson deleted the enhance-auto-selection-with-hardwareId branch February 27, 2023 09:35
@kittaakos
Copy link
Contributor

This PR has been created to support the "auto-reconnecting" to a board in DFU mode, which the R4 Minima goes into during upload and reset. The primary motivation was to make IDE2 compatible with the Uno R4 board.

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 type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants