We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 92b0c4b commit f26c453Copy full SHA for f26c453
arduino/discovery/discovery.go
@@ -90,7 +90,11 @@ func (d *Discovery) Start() error {
90
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
}
@@ -112,7 +116,6 @@ func (d *Discovery) List() ([]*BoardPort, error) {
112
116
return nil, fmt.Errorf("decoding LIST command: %s", err)
113
117
114
118
done <- true
115
- d.Unlock()
119
return event.Ports, nil
120
121
0 commit comments