5
5
"fmt"
6
6
"github.com/mattn/go-shellwords"
7
7
"io"
8
- "io/ioutil"
9
8
"os"
10
9
"os/exec"
11
10
"path/filepath"
@@ -65,26 +64,24 @@ func main_load(args []string) {
65
64
}
66
65
}
67
66
68
- tmpfile , err := ioutil .TempFile (os .TempDir (), "dfu" )
69
- dfu_search_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "4" }
70
- tmpfile .Close ()
71
- os .Remove (tmpfile .Name ())
72
-
73
- fmt .Println (dfu_search_command )
67
+ dfu_search_command := []string {dfu , dfu_flags , "-l" }
74
68
75
69
for counter < 100 && board_found == false {
76
70
if counter % 10 == 0 {
77
71
PrintlnVerbose ("Waiting for device..." )
78
72
}
79
- err , _ := launchCommandAndWaitForOutput (dfu_search_command , "" , false )
73
+ err , found := launchCommandAndWaitForOutput (dfu_search_command , "sensor_core" , false )
74
+ if err != nil {
75
+ fmt .Println (err )
76
+ os .Exit (1 )
77
+ }
80
78
if counter == 40 {
81
79
fmt .Println ("Flashing is taking longer than expected" )
82
80
fmt .Println ("Try pressing MASTER_RESET button" )
83
81
}
84
- if err == nil {
82
+ if found == true {
85
83
board_found = true
86
84
PrintlnVerbose ("Device found!" )
87
- os .Remove (tmpfile .Name ())
88
85
break
89
86
}
90
87
time .Sleep (100 * time .Millisecond )
@@ -97,7 +94,7 @@ func main_load(args []string) {
97
94
}
98
95
99
96
dfu_download := []string {dfu , dfu_flags , "-D" , bin_file_name , "-v" , "--alt" , "7" , "-R" }
100
- err , _ = launchCommandAndWaitForOutput (dfu_download , "" , true )
97
+ err , _ : = launchCommandAndWaitForOutput (dfu_download , "" , true )
101
98
102
99
if err == nil {
103
100
fmt .Println ("SUCCESS: Sketch will execute in about 5 seconds." )
0 commit comments