We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a6fdfea commit 87780d7Copy full SHA for 87780d7
arduino/discovery/discovery.go
@@ -23,6 +23,7 @@ import (
23
"io"
24
"os/exec"
25
"strings"
26
+ "sync"
27
"time"
28
29
"github.com/arduino/arduino-cli/arduino/cores"
@@ -33,6 +34,7 @@ import (
33
34
35
// Discovery is an instance of a discovery tool
36
type Discovery struct {
37
+ sync.Mutex
38
ID string
39
in io.WriteCloser
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
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
+
98
if _, err := d.in.Write([]byte("LIST\n")); err != nil {
99
return nil, fmt.Errorf("sending LIST command to discovery: %s", err)
100
}
0 commit comments