arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Board attach should support serial symlinks

Open matthijskooijman opened this issue 5 years ago • 0 comments
trafficstars

Bug Report

Current behavior

On Linux, /dev/serial/... has useful symlinks to serial ports, that allow more persistent references to specific boards, or boards plugged into specific USB ports. However, specifying such a symlink to board attach fails:

$ arduino-cli  board attach /dev/ttyACM0
[arduino-git:avr:uno]
Board found: Arduino Uno...
Selected fqbn: arduino-git:avr:uno

$ arduino-cli  board attach /dev/serial/by-id/usb-Arduino_Srl_Arduino_Uno_95530343434351A0B2B1-if00 
Attach board error: no supported board found at serial:///dev/serial/by-id/usb-Arduino_Srl_Arduino_Uno_95530343434351A0B2B1-if00

Expected behavior

The second command should find the Arduino, just like the first one.

Environment

  • CLI version (output of arduino-cli version): current git master 1855b531766056c9014df6f3e0aacad63d30ddc4
  • OS and platform: Linux amd64

Additional context

The relevant code is here: https://github.com/arduino/arduino-cli/blob/1855b531766056c9014df6f3e0aacad63d30ddc4/commands/board/attach.go#L120-L126

This matches the given port URI/name to the list of ports verbatim, failing if the port is not among the autodetected list of ports.

A simple fix could be to canonicalize the path and resolving the symlinks.

I also tried upload --port ... which does seem to accept the symlink (probably because it just opens the port and/or forwards it to the upload tool directly and does not need to get the vidpid for the port). I haven't checked if there's other commands that do suffer from the same problem.

matthijskooijman avatar Nov 14 '20 14:11 matthijskooijman