Skip to content

Commit 6ec3edd

Browse files
committed
use -U method on all platforms
1 parent 187af3d commit 6ec3edd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

main.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"fmt"
66
"io"
7+
"io/ioutil"
78
"os"
89
"os/exec"
910
"path/filepath"
@@ -61,24 +62,26 @@ func main() {
6162
}
6263
}
6364

64-
dfu_search_command := []string{dfu, dfu_flags, "-l"}
65+
tmpfile, err := ioutil.TempFile(os.TempDir(), "dfu")
66+
dfu_search_command := []string{dfu, dfu_flags, "-U", tmpfile.Name(), "--alt", "4"}
67+
tmpfile.Close()
68+
os.Remove(tmpfile.Name())
69+
70+
fmt.Println(dfu_search_command)
6571

6672
for counter < 100 && board_found == false {
6773
if counter%10 == 0 {
6874
PrintlnVerbose("Waiting for device...")
6975
}
70-
err, found := launchCommandAndWaitForOutput(dfu_search_command, "sensor_core", false)
71-
if err != nil {
72-
fmt.Println(err)
73-
os.Exit(1)
74-
}
76+
err, _ := launchCommandAndWaitForOutput(dfu_search_command, "", false)
7577
if counter == 40 {
7678
fmt.Println("Flashing is taking longer than expected")
7779
fmt.Println("Try pressing MASTER_RESET button")
7880
}
79-
if found == true {
81+
if err == nil {
8082
board_found = true
8183
PrintlnVerbose("Device found!")
84+
os.Remove(tmpfile.Name())
8285
break
8386
}
8487
time.Sleep(100 * time.Millisecond)
@@ -91,7 +94,7 @@ func main() {
9194
}
9295

9396
dfu_download := []string{dfu, dfu_flags, "-D", bin_file_name, "-v", "--alt", "7", "-R"}
94-
err, _ := launchCommandAndWaitForOutput(dfu_download, "", true)
97+
err, _ = launchCommandAndWaitForOutput(dfu_download, "", true)
9598

9699
if err == nil {
97100
fmt.Println("SUCCESS: Sketch will execute in about 5 seconds.")

0 commit comments

Comments
 (0)