@@ -94,7 +94,7 @@ func main_load() {
9494 if counter % 10 == 0 {
9595 PrintlnVerbose ("Waiting for device..." )
9696 }
97- err , found , _ := launchCommandAndWaitForOutput (dfu_search_command , "sensor_core" , false )
97+ err , found , _ := launchCommandAndWaitForOutput (dfu_search_command , "sensor_core" , false , false )
9898 if err != nil {
9999 fmt .Println (err )
100100 os .Exit (1 )
@@ -130,7 +130,7 @@ func main_load() {
130130 // reset DFU interface counter
131131 dfu_reset_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "8" , "-K" , "1" }
132132
133- err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false )
133+ err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false , false )
134134 if err != nil {
135135 fmt .Println (err )
136136 os .Exit (1 )
@@ -141,7 +141,7 @@ func main_load() {
141141 // download a piece of BLE firmware
142142 dfu_ble_dump_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "8" , "-K" , strconv .Itoa (* ble_compliance_offset )}
143143
144- err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_dump_command , "" , false )
144+ err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_dump_command , "" , false , false )
145145 if err != nil {
146146 fmt .Println (err )
147147 os .Exit (1 )
@@ -171,7 +171,7 @@ func main_load() {
171171 // reset DFU interface counter
172172 dfu_reset_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "2" , "-K" , "1" }
173173
174- err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false )
174+ err , _ , _ := launchCommandAndWaitForOutput (dfu_reset_command , "" , false , false )
175175 if err != nil {
176176 fmt .Println (err )
177177 os .Exit (1 )
@@ -182,7 +182,7 @@ func main_load() {
182182 // download a piece of RTOS firmware
183183 dfu_rtos_dump_command := []string {dfu , dfu_flags , "-U" , tmpfile .Name (), "--alt" , "2" , "-K" , strconv .Itoa (* rtos_compliance_offset )}
184184
185- err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_dump_command , "" , false )
185+ err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_dump_command , "" , false , false )
186186 if err != nil {
187187 fmt .Println (err )
188188 os .Exit (1 )
@@ -213,7 +213,7 @@ func main_load() {
213213 fmt .Println ("ATTENTION: BLE firmware is being flashed" )
214214 fmt .Println ("DO NOT DISCONNECT THE BOARD" )
215215
216- err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_flash_command , "" , true )
216+ err , _ , _ = launchCommandAndWaitForOutput (dfu_ble_flash_command , "" , true , true )
217217 if err != nil {
218218 fmt .Println (err )
219219 os .Exit (1 )
@@ -228,7 +228,7 @@ func main_load() {
228228 fmt .Println ("ATTENTION: RTOS firmware is being flashed" )
229229 fmt .Println ("DO NOT DISCONNECT THE BOARD" )
230230
231- err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_flash_command , "" , true )
231+ err , _ , _ = launchCommandAndWaitForOutput (dfu_rtos_flash_command , "" , true , true )
232232 if err != nil {
233233 fmt .Println (err )
234234 os .Exit (1 )
@@ -242,7 +242,7 @@ func main_load() {
242242 }
243243
244244 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 )
246246
247247 if err == nil {
248248 fmt .Println ("SUCCESS: Sketch will execute in about 5 seconds." )
@@ -288,7 +288,7 @@ func main_debug(args []string) {
288288 cmd , _ := shellwords .Parse (command .command )
289289 fmt .Println (cmd )
290290 if command .background == false {
291- err , _ , _ = launchCommandAndWaitForOutput (cmd , "" , true )
291+ err , _ , _ = launchCommandAndWaitForOutput (cmd , "" , true , false )
292292 } else {
293293 err , _ = launchCommandBackground (cmd , "" , true )
294294 }
@@ -367,7 +367,7 @@ func searchVersionInDFU(file string, string_to_search string) bool {
367367 return strings .Contains (string (read ), string_to_search )
368368}
369369
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 ) {
371371 oscmd := exec .Command (command [0 ], command [1 :]... )
372372 tellCommandNotToSpawnShell (oscmd )
373373 stdout , _ := oscmd .StdoutPipe ()
@@ -376,15 +376,10 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
376376
377377 s := spin .New ()
378378 s .Set (spin .Spin1 )
379- showSpinner := false
380379
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
388383 }
389384 err := oscmd .Start ()
390385 in := bufio .NewScanner (multi )
@@ -393,7 +388,7 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
393388 out := ""
394389 for in .Scan () {
395390
396- if showSpinner {
391+ if show_spinner {
397392 fmt .Printf ("\r %s" , s .Next ())
398393 }
399394
@@ -405,7 +400,7 @@ func launchCommandAndWaitForOutput(command []string, stringToSearch string, prin
405400 }
406401 }
407402 err = oscmd .Wait ()
408- if showSpinner {
403+ if show_spinner {
409404 fmt .Println ("" )
410405 }
411406 return err , found , out
0 commit comments