Skip to content

Commit ec5c3ed

Browse files
author
Roberto Sora
committed
Fix serial port URI parsing in board attach command (#661)
1 parent ad9d5f6 commit ec5c3ed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: commands/board/attach.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ func Attach(ctx context.Context, req *rpc.BoardAttachReq, taskCB commands.TaskPr
112112
// for the matching.
113113
func findSerialConnectedBoard(pm *packagemanager.PackageManager, monitor *discovery.Monitor, deviceURI *url.URL) *cores.Board {
114114
found := false
115-
location := deviceURI.Path
115+
// to support both cases:
116+
// serial:///dev/ttyACM2 parsing gives: deviceURI.Host = "" and deviceURI.Path = /dev/ttyACM2
117+
// serial://COM3 parsing gives: deviceURI.Host = "COM3" and deviceURI.Path = ""
118+
location := deviceURI.Host + deviceURI.Path
116119
var serialDevice discovery.SerialDevice
117120
for _, device := range monitor.Serial() {
118121
if device.Port == location {

0 commit comments

Comments
 (0)