File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ import (
22
22
"fmt"
23
23
"io"
24
24
"os/exec"
25
+ "time"
26
+
27
+ "github.com/arduino/arduino-cli/arduino/cores/packagemanager"
25
28
26
29
properties "github.com/arduino/go-properties-orderedmap"
27
30
@@ -87,9 +90,23 @@ func (d *Discovery) List() ([]*BoardPort, error) {
87
90
return nil , fmt .Errorf ("sending LIST command to discovery: %s" , err )
88
91
}
89
92
var event eventJSON
93
+ done := make (chan bool )
94
+ timeout := false
95
+ go func () {
96
+ select {
97
+ case <- done :
98
+ case <- time .After (5 * time .Second ):
99
+ timeout = true
100
+ d .Close ()
101
+ }
102
+ }()
90
103
if err := d .outJSON .Decode (& event ); err != nil {
104
+ if timeout {
105
+ return nil , fmt .Errorf ("decoding LIST command: timeout" )
106
+ }
91
107
return nil , fmt .Errorf ("decoding LIST command: %s" , err )
92
108
}
109
+ done <- true
93
110
return event .Ports , nil
94
111
}
95
112
You can’t perform that action at this time.
0 commit comments