File tree 1 file changed +7
-0
lines changed
1 file changed +7
-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,11 @@ 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
+ // ensure the connection to the discoverer is unique to avoid messing up
94
+ // the messages exchanged
95
+ d .Lock ()
96
+ defer d .Unlock ()
97
+
91
98
if _ , err := d .in .Write ([]byte ("LIST\n " )); err != nil {
92
99
return nil , fmt .Errorf ("sending LIST command to discovery: %s" , err )
93
100
}
You can’t perform that action at this time.
0 commit comments