Skip to content

Commit 8bde36f

Browse files
committed
Inlined discovery loop
1 parent 5946a68 commit 8bde36f

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/arduino/arduino-create-agent/systray"
4141
"github.com/arduino/arduino-create-agent/tools"
4242
"github.com/arduino/arduino-create-agent/updater"
43+
"github.com/arduino/arduino-create-agent/upload"
4344
v2 "github.com/arduino/arduino-create-agent/v2"
4445
paths "github.com/arduino/go-paths-helper"
4546
cors "github.com/gin-contrib/cors"
@@ -360,7 +361,14 @@ func loop() {
360361
// launch our dummy data routine
361362
//go d.run()
362363

363-
go discoverLoop()
364+
go func() {
365+
for {
366+
if !upload.Busy {
367+
updateSerialPortList()
368+
}
369+
time.Sleep(2 * time.Second)
370+
}
371+
}()
364372

365373
r := gin.New()
366374

serial.go

-15
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import (
2222
"strconv"
2323
"strings"
2424
"sync"
25-
"time"
26-
27-
"github.com/arduino/arduino-create-agent/upload"
2825
)
2926

3027
type writeRequest struct {
@@ -135,18 +132,6 @@ func (sp *SerialPortList) List() {
135132
}
136133
}
137134

138-
// discoverLoop periodically update the list of ports found
139-
func discoverLoop() {
140-
go func() {
141-
for {
142-
if !upload.Busy {
143-
updateSerialPortList()
144-
}
145-
time.Sleep(2 * time.Second)
146-
}
147-
}()
148-
}
149-
150135
var serialEnumeratorLock sync.Mutex
151136

152137
func updateSerialPortList() {

0 commit comments

Comments
 (0)