File tree 3 files changed +13
-4
lines changed
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
2
2
3
3
go 1.14
4
4
5
+ // branch with support for serial timeouts
6
+ replace go.bug.st/serial => github.com/cmaglie/go-serial v0.0.0-20200923162623-b214c147e37e
7
+
5
8
require 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 =
1
5
github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0 =
2
6
github.com/creack/goselect v0.1.1 /go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY =
3
7
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
4
8
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
5
9
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
6
10
github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
7
11
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 =
8
13
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk =
9
14
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 =
12
15
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM =
13
16
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
14
17
gopkg.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
2
2
3
3
import (
4
4
"log"
5
+ "time"
5
6
6
7
"go.bug.st/serial"
7
8
)
@@ -21,14 +22,16 @@ func OpenSerial(portName string) (serial.Port, error) {
21
22
for _ , baudRate := range baudRates {
22
23
mode := & serial.Mode {
23
24
BaudRate : baudRate ,
24
- // Vtimeout: 255,
25
- // Vmin: 0,
26
25
}
27
26
port , err := serial .Open (portName , mode )
28
27
if err == nil {
29
28
log .Printf ("Open the serial port with baud rate %d" , baudRate )
30
29
return port , nil
31
30
}
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
+ }
32
35
}
33
36
return port , err
34
37
You can’t perform that action at this time.
0 commit comments