File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "io"
2424 "os/exec"
2525 "strings"
26+ "sync"
2627 "time"
2728
2829 "github.com/arduino/arduino-cli/arduino/cores"
@@ -33,6 +34,7 @@ import (
3334
3435// Discovery is an instance of a discovery tool
3536type Discovery struct {
37+ sync.Mutex
3638 ID string
3739 in io.WriteCloser
3840 out io.ReadCloser
@@ -88,6 +90,11 @@ func (d *Discovery) Start() error {
8890
8991// List retrieve the port list from this discovery
9092func (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+
9198 if _ , err := d .in .Write ([]byte ("LIST\n " )); err != nil {
9299 return nil , fmt .Errorf ("sending LIST command to discovery: %s" , err )
93100 }
You can’t perform that action at this time.
0 commit comments