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

Identify final board port address in machine readable upload command response #2245

Closed
3 tasks done
per1234 opened this issue Jul 18, 2023 · 1 comment · Fixed by #2253
Closed
3 tasks done

Identify final board port address in machine readable upload command response #2245

per1234 opened this issue Jul 18, 2023 · 1 comment · Fixed by #2253
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@per1234
Copy link
Contributor

per1234 commented Jul 18, 2023

Describe the request

In some cases, it is possible that the address of the board's port is different at the end of an upload operation. Arduino CLI should identify the final address of the target board's port and provide this information in the machine readable upload command responses:

🙂 This information will be useful to consumers of Arduino CLI such as development tools and scripts.

Describe the current behavior

A common scenario under which the port address can change through an upload operation is uploading to a "native USB" board, where the primary microcontroller produces the USB CDC serial port. The typical upload procedure for these boards:

  1. Arduino CLI signals to the target board that it should activate the bootloader.
  2. The board switches from application into bootloader mode, which causes its CDC serial port to disappear for a short time.
  3. Arduino CLI watches for a new port to be discovered.
  4. Arduino CLI determines the port to use for the upload and provides it for use in the upload pattern via the upload.port.address property.
    • If a new port was discovered, that port is used.
    • If the timeout was reached without a new discovery, the original port is used as a fallback.
  5. Arduino CLI invokes the upload command.
  6. The board switches from bootloader to application mode, which causes its CDC serial port to disappear for a short time.

The port address may change following steps (2) and (6) in the above procedure. A system has already been implemented for Arduino CLI to effectively follow the address change after step (2), but there is no such following of the port after step (6). The reason for this is that, unlike the address change at step (2), Arduino CLI itself doesn't have a need to know the final address.

🙁 A final address identification system (which is fairly complex) must be implemented separately in each of the tools that do need this information.

Arduino CLI version

df12786

Operating system

All

Operating system version

Any

Additional context

This is somewhat related to arduino/arduino-ide#1319 in that it would enable the complete removal of automatic port selection code from the Arduino IDE codebase rather than only the partial removal that is required for the resolution of arduino/arduino-ide#1319.

Examples of tools not correctly determining the final port address:

These issues highlight the value of maintaining a single reliable final port identification system instead of duplicating the effort of implementing the system in each individual downstream project.

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest nightly build
  • My request contains all necessary details
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jul 18, 2023
@kittaakos
Copy link
Contributor

Once the feature is available and the CLI can provide the new port (if it has changed) after the upload, I propose eliminating the hardwareId from the gRPC API before the 1.0 release. I do not see why this should be exposed to the public. See the downstream change at arduino/arduino-ide#1913:

From here:

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.

Related API:

// The hardware ID (serial number) of the board attached to the port
string hardware_id = 6;

I can open a separate issue if it's needed.

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

Successfully merging a pull request may close this issue.

4 participants