Skip to content

Commit bcd90ce

Browse files
committed
resolve serial port serial number in commandline
1 parent 8b7ca9f commit bcd90ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

upload/upload.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/pkg/errors"
2424
"github.com/sfreiberg/simplessh"
2525
serial "go.bug.st/serial.v1"
26+
"go.bug.st/serial.v1/enumerator"
2627
)
2728

2829
// Busy tells wether the programmer is doing something
@@ -81,6 +82,14 @@ func PartiallyResolve(board, file, commandline string, extra Extra, t Locater) (
8182
func fixupPort(port, commandline string) string {
8283
commandline = strings.Replace(commandline, "{serial.port}", port, -1)
8384
commandline = strings.Replace(commandline, "{serial.port.file}", filepath.Base(port), -1)
85+
ports, err := enumerator.GetDetailedPortsList()
86+
if err == nil {
87+
for _, p := range ports {
88+
if p.Name == port {
89+
commandline = strings.Replace(commandline, "{serial.port.iserial}", p.SerialNumber, -1)
90+
}
91+
}
92+
}
8493
return commandline
8594
}
8695

0 commit comments

Comments
 (0)