Skip to content

Allow specifying FQBN *and* port in board attach #1073

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

Closed
matthijskooijman opened this issue Nov 14, 2020 · 4 comments · Fixed by #1930
Closed

Allow specifying FQBN *and* port in board attach #1073

matthijskooijman opened this issue Nov 14, 2020 · 4 comments · Fixed by #1930
Labels
topic: CLI Related to the command line interface type: enhancement Proposed improvement

Comments

@matthijskooijman
Copy link
Collaborator

matthijskooijman commented Nov 14, 2020

Bug Report

Current behavior

The board attach command allows specifying a port or FQBN. If you specify a port, the FQBN is autodetected from the board (if possible) and the resulting sketch.json has both the port and fqbn set. If you specify just the FQBN, only that is set in sketch.json.

For boards that can be autodetected, it is sufficient to specify the port. But for boards that cannot be autodetected (i.e. that use a common USB-to-serial chip without their own VIDPID), specifying the serial port is now not possible (since that triggers autodetection, which fails).

As a workaround, you can just edit sketch.json manually, of course.

Maybe it would be useful to add a --fqbn option to board attach, to allow specifying the FQBN in addition to the serial port and override autodetection? The interface might get a little messy, though. Maybe it would be better to then also add --port and stop support the <port>|<FQBN> non-option argument? i.e. change:

Usage:
  arduino-cli board attach <port>|<FQBN> [sketchPath] [flags]

Examples:
  arduino-cli board attach serial:///dev/ttyACM0
  arduino-cli board attach serial:///dev/ttyACM0 HelloWorld
  arduino-cli board attach arduino:samd:mkr1000

to:

Usage:
  arduino-cli board attach [sketchPath] [flags]

Examples:
  arduino-cli board attach --port serial:///dev/ttyACM0
  arduino-cli board attach --port serial:///dev/ttyACM0 HelloWorld
  arduino-cli board attach --fqbn arduino:samd:mkr1000
  arduino-cli board attach --fqbn arduino:samd:mkr1000 --port serial:///dev/ttyACM0

This would break compatibility, though...

  • CLI version (output of arduino-cli version): Current git master 1855b53
  • OS and platform: Linux amd64
@matthijskooijman
Copy link
Collaborator Author

A slightly related issue is that when specifying a port and doing autodetection, the "name" is set in sketch.json, but when specifying just the FQBN, this does not happen (even though, I think, the name could be looked up from the FQBN as well). See

if fqbn != nil {
sketch.Metadata.CPU = sketches.BoardMetadata{
Fqbn: fqbn.String(),
}

and

sketch.Metadata.CPU = sketches.BoardMetadata{
Fqbn: board.FQBN(),
Name: board.Name(),
Port: deviceURI.String(),
}

@ubidefeo
Copy link

@matthijskooijman
I have noticed some odd behaviour in the board attach command, it definitely needs some love but it's a lower priority right now.

I have started reviewing this kind of workflows because in my opinion every time you need to pass a board model you should prefix it with the -b | --fqbn flag.
I think it makes up for greater consistency and better API

@ubidefeo
Copy link

@matthijskooijman
saw you linked this issue in another one
a reworked behaviour is part of the current sprint, but because of the holidays this sprint is gonna be longer than expected

@cmaglie
Copy link
Member

cmaglie commented Nov 21, 2022

This problem has been resolved by the complete reworking of the board attach command in #1930. The user preferences are now saved in the sketch.yaml file (that is the official Arduino CLI sketch project file) instead of the sketch.json file (that is the file used by the Arduino Web Editor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants