4
4
"bufio"
5
5
"fmt"
6
6
"io"
7
+ "io/ioutil"
7
8
"os"
8
9
"os/exec"
9
10
"path/filepath"
@@ -61,24 +62,26 @@ func main() {
61
62
}
62
63
}
63
64
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 )
65
71
66
72
for counter < 100 && board_found == false {
67
73
if counter % 10 == 0 {
68
74
PrintlnVerbose ("Waiting for device..." )
69
75
}
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 )
75
77
if counter == 40 {
76
78
fmt .Println ("Flashing is taking longer than expected" )
77
79
fmt .Println ("Try pressing MASTER_RESET button" )
78
80
}
79
- if found == true {
81
+ if err == nil {
80
82
board_found = true
81
83
PrintlnVerbose ("Device found!" )
84
+ os .Remove (tmpfile .Name ())
82
85
break
83
86
}
84
87
time .Sleep (100 * time .Millisecond )
@@ -91,7 +94,7 @@ func main() {
91
94
}
92
95
93
96
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 )
95
98
96
99
if err == nil {
97
100
fmt .Println ("SUCCESS: Sketch will execute in about 5 seconds." )
0 commit comments