Skip to content

Commit 9500a01

Browse files
committed
Readded timeouts
1 parent 9e5cd1e commit 9500a01

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ module github.com/arduino/FirmwareUpdater
22

33
go 1.14
44

5+
// branch with support for serial timeouts
6+
replace go.bug.st/serial => github.com/cmaglie/go-serial v0.0.0-20200923162623-b214c147e37e
7+
58
require go.bug.st/serial v1.1.1

go.sum

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
2+
github.com/arduino/go-properties-orderedmap v1.1.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
3+
github.com/cmaglie/go-serial v0.0.0-20200923162623-b214c147e37e h1:XETkjcWmNrh5M9hIpkgI0uANZsdD8zg2wjDzspe3bRw=
4+
github.com/cmaglie/go-serial v0.0.0-20200923162623-b214c147e37e/go.mod h1:k7j3AWnS4CLHK94Z32+qkukjlSyASt1YYrbWcnr9r4E=
15
github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0=
26
github.com/creack/goselect v0.1.1/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
37
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
48
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
59
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
610
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
711
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
12+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
813
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
914
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
10-
go.bug.st/serial v1.1.1 h1:5J1DpaIaSIruBi7jVnKXnhRS+YQ9+2PLJMtIZKoIgnc=
11-
go.bug.st/serial v1.1.1/go.mod h1:VmYBeyJWp5BnJ0tw2NUJHZdJTGl2ecBGABHlzRK1knY=
1215
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM=
1316
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1417
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

utils/flasher.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"log"
5+
"time"
56

67
"go.bug.st/serial"
78
)
@@ -21,14 +22,16 @@ func OpenSerial(portName string) (serial.Port, error) {
2122
for _, baudRate := range baudRates {
2223
mode := &serial.Mode{
2324
BaudRate: baudRate,
24-
// Vtimeout: 255,
25-
// Vmin: 0,
2625
}
2726
port, err := serial.Open(portName, mode)
2827
if err == nil {
2928
log.Printf("Open the serial port with baud rate %d", baudRate)
3029
return port, nil
3130
}
31+
if err := port.SetReadTimeout(5 * time.Second); err != nil {
32+
log.Fatalf("Could not set timeout on serial port: %s", err)
33+
return nil, err
34+
}
3235
}
3336
return port, err
3437

0 commit comments

Comments
 (0)