File tree 1 file changed +4
-0
lines changed
1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
23
23
"io"
24
24
"os/exec"
25
25
"strings"
26
+ "sync"
26
27
"time"
27
28
28
29
"github.com/arduino/arduino-cli/arduino/cores"
@@ -33,6 +34,7 @@ import (
33
34
34
35
// Discovery is an instance of a discovery tool
35
36
type Discovery struct {
37
+ sync.Mutex
36
38
ID string
37
39
in io.WriteCloser
38
40
out io.ReadCloser
@@ -88,6 +90,7 @@ func (d *Discovery) Start() error {
88
90
89
91
// List retrieve the port list from this discovery
90
92
func (d * Discovery ) List () ([]* BoardPort , error ) {
93
+ d .Lock ()
91
94
if _ , err := d .in .Write ([]byte ("LIST\n " )); err != nil {
92
95
return nil , fmt .Errorf ("sending LIST command to discovery: %s" , err )
93
96
}
@@ -109,6 +112,7 @@ func (d *Discovery) List() ([]*BoardPort, error) {
109
112
return nil , fmt .Errorf ("decoding LIST command: %s" , err )
110
113
}
111
114
done <- true
115
+ d .Unlock ()
112
116
return event .Ports , nil
113
117
}
114
118
You can’t perform that action at this time.
0 commit comments