File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,7 @@ module github.com/arduino/FirmwareUpdater
22
33go 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+
58require go.bug.st/serial v1.1.1
Original file line number Diff line number Diff line change 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 =
15github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0 =
26github.com/creack/goselect v0.1.1 /go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY =
37github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
48github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
59github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
610github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
711github.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 =
813github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk =
914github.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 =
1215golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM =
1316golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
1417gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM =
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package utils
22
33import (
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
You can’t perform that action at this time.
0 commit comments