@@ -94,7 +94,7 @@ func main_load() {
94
94
if counter % 10 == 0 {
95
95
PrintlnVerbose ("Waiting for device..." )
96
96
}
97
- err , found , _ := launchCommandAndWaitForOutput (dfu_search_command , "sensor_core" , false )
97
+ err , found , _ := launchCommandAndWaitForOutput (dfu_search_command , "sensor_core" , false , false )
98
98
if err != nil {
99
99
fmt .Println (err )
100
100
os .Exit (1 )
@@ -130,7 +130,7 @@ func main_load() {
130
130
// reset DFU interface counter
131
131
dfu_reset_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "8" , "-K" , "1" }
132
132
133
- err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false )
133
+ err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false , false )
134
134
if err != nil {
135
135
fmt .Println (err )
136
136
os .Exit (1 )
@@ -141,7 +141,7 @@ func main_load() {
141
141
// download a piece of BLE firmware
142
142
dfu_ble_dump_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "8" , "-K" , strconv .Itoa (* ble_compliance_offset )}
143
143
144
- err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_dump_command , "" , false )
144
+ err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_dump_command , "" , false , false )
145
145
if err != nil {
146
146
fmt .Println (err )
147
147
os .Exit (1 )
@@ -171,7 +171,7 @@ func main_load() {
171
171
// reset DFU interface counter
172
172
dfu_reset_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "2" , "-K" , "1" }
173
173
174
- err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false )
174
+ err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false , false )
175
175
if err != nil {
176
176
fmt .Println (err )
177
177
os .Exit (1 )
@@ -182,7 +182,7 @@ func main_load() {
182
182
// download a piece of RTOS firmware
183
183
dfu_rtos_dump_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "2" , "-K" , strconv .Itoa (* rtos_compliance_offset )}
184
184
185
- err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_dump_command , "" , false )
185
+ err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_dump_command , "" , false , false )
186
186
if err != nil {
187
187
fmt .Println (err )
188
188
os .Exit (1 )
@@ -213,7 +213,7 @@ func main_load() {
213
213
fmt .Println ("ATTENTION: BLE firmware is being flashed" )
214
214
fmt .Println ("DO NOT DISCONNECT THE BOARD" )
215
215
216
- err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_flash_command , "" , true )
216
+ err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_flash_command , "" , true , true )
217
217
if err != nil {
218
218
fmt .Println (err )
219
219
os .Exit (1 )
@@ -228,7 +228,7 @@ func main_load() {
228
228
fmt .Println ("ATTENTION: RTOS firmware is being flashed" )
229
229
fmt .Println ("DO NOT DISCONNECT THE BOARD" )
230
230
231
- err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_flash_command , "" , true )
231
+ err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_flash_command , "" , true , true )
232
232
if err != nil {
233
233
fmt .Println (err )
234
234
os .Exit (1 )
@@ -242,7 +242,7 @@ func main_load() {
242
242
}
243
243
244
244
dfu_download := []string {dfu , dfu_flags , "-D" , * bin_file_name , "-v" , "--alt" , "7" , "-R" }
245
- err , _ , _ = launchCommandAndWaitForOutput (dfu_download , "" , true )
245
+ err , _ , _ = launchCommandAndWaitForOutput (dfu_download , "" , true , false )
246
246
247
247
if err == nil {
248
248
fmt .Println ("SUCCESS: Sketch will execute in about 5 seconds." )
@@ -288,7 +288,7 @@ func main_debug(args []string) {
288
288
cmd , _ := shellwords .Parse (command .command )
289
289
fmt .Println (cmd )
290
290
if command .background == false {
291
- err , _ , _ = launchCommandAndWaitForOutput (cmd , "" , true )
291
+ err , _ , _ = launchCommandAndWaitForOutput (cmd , "" , true , false )
292
292
} else {
293
293
err , _ = launchCommandBackground (cmd , "" , true )
294
294
}
@@ -367,7 +367,7 @@ func searchVersionInDFU(file string, string_to_search string) bool {
367
367
return strings .Contains (string (read ), string_to_search )
368
368
}
369
369
370
- func launchCommandAndWaitForOutput (command []string , stringToSearch string , print_output bool ) (error , bool , string ) {
370
+ func launchCommandAndWaitForOutput (command []string , stringToSearch string , print_output bool , show_spinner bool ) (error , bool , string ) {
371
371
oscmd := exec .Command (command [0 ], command [1 :]... )
372
372
tellCommandNotToSpawnShell (oscmd )
373
373
stdout , _ := oscmd .StdoutPipe ()
@@ -376,15 +376,10 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
376
376
377
377
s := spin .New ()
378
378
s .Set (spin .Spin1 )
379
- showSpinner := false
380
379
381
- if print_output {
382
- if * verbose {
383
- oscmd .Stdout = os .Stdout
384
- oscmd .Stderr = os .Stderr
385
- } else {
386
- showSpinner = true
387
- }
380
+ if print_output && * verbose {
381
+ oscmd .Stdout = os .Stdout
382
+ oscmd .Stderr = os .Stderr
388
383
}
389
384
err := oscmd .Start ()
390
385
in := bufio .NewScanner (multi )
@@ -393,7 +388,7 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
393
388
out := ""
394
389
for in .Scan () {
395
390
396
- if showSpinner {
391
+ if show_spinner {
397
392
fmt .Printf ("\r %s" , s .Next ())
398
393
}
399
394
@@ -405,7 +400,7 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
405
400
}
406
401
}
407
402
err = oscmd .Wait ()
408
- if showSpinner {
403
+ if show_spinner {
409
404
fmt .Println ("" )
410
405
}
411
406
return err , found , out
0 commit comments