Skip to content

Commit 18e4465

Browse files
deadprogramaykevl
authored andcommitted
flash: use more precise searches for correct volume/port with default Windows matching
Signed-off-by: Ron Evans <ron@hybridgroup.com>
1 parent 447537a commit 18e4465

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func flashUF2UsingMSD(volume, tmppath string) error {
457457
case "darwin":
458458
infoPath = "/Volumes/" + volume + "/INFO_UF2.TXT"
459459
case "windows":
460-
path, err := windowsFindUSBDrive()
460+
path, err := windowsFindUSBDrive(volume)
461461
if err != nil {
462462
return err
463463
}
@@ -484,7 +484,7 @@ func flashHexUsingMSD(volume, tmppath string) error {
484484
case "darwin":
485485
destPath = "/Volumes/" + volume
486486
case "windows":
487-
path, err := windowsFindUSBDrive()
487+
path, err := windowsFindUSBDrive(volume)
488488
if err != nil {
489489
return err
490490
}
@@ -502,10 +502,10 @@ func flashHexUsingMSD(volume, tmppath string) error {
502502
return moveFile(tmppath, d[0]+"/flash.hex")
503503
}
504504

505-
func windowsFindUSBDrive() (string, error) {
506-
cmd := exec.Command("wmic", "PATH", "Win32_LogicalDisk",
507-
"get", "DeviceID,", "VolumeName,",
508-
"FileSystem,", "DriveType")
505+
func windowsFindUSBDrive(volume string) (string, error) {
506+
cmd := exec.Command("wmic",
507+
"PATH", "Win32_LogicalDisk", "WHERE", "VolumeName = '"+volume+"'",
508+
"get", "DeviceID,VolumeName,FileSystem,DriveType")
509509

510510
var out bytes.Buffer
511511
cmd.Stdout = &out
@@ -559,8 +559,8 @@ func getDefaultPort() (port string, err error) {
559559
case "linux":
560560
portPath = "/dev/ttyACM*"
561561
case "windows":
562-
cmd := exec.Command("wmic", "PATH", "Win32_SerialPort",
563-
"get", "DeviceID")
562+
cmd := exec.Command("wmic",
563+
"PATH", "Win32_SerialPort", "WHERE", "Caption LIKE 'USB Serial%'", "GET", "DeviceID")
564564

565565
var out bytes.Buffer
566566
cmd.Stdout = &out

0 commit comments

Comments
 (0)