Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/arduino/go-properties-orderedmap v1.6.0
github.com/arduino/pluggable-discovery-protocol-handler/v2 v2.0.1
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/s-urbaniak/uevent v1.0.0
github.com/s-urbaniak/uevent v1.0.1
go.bug.st/serial v1.3.1
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/s-urbaniak/uevent v1.0.0 h1:y1e40TmDfCU0l1o/MBpimGJgo2UzTTqBl/0GF6vx/io=
github.com/s-urbaniak/uevent v1.0.0/go.mod h1:h83SVc1NQj/EubPaK4hWyiG217xLYr+fS+Jf10COrG0=
github.com/s-urbaniak/uevent v1.0.1 h1:Zy6g16gR1m6iRB+scDtyExP9KRYnuSdTWOYhBE5O620=
github.com/s-urbaniak/uevent v1.0.1/go.mod h1:h83SVc1NQj/EubPaK4hWyiG217xLYr+fS+Jf10COrG0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
Expand Down
13 changes: 6 additions & 7 deletions sync/sync_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package sync

import (
"fmt"
"io"

discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
"github.com/s-urbaniak/uevent"
Expand Down Expand Up @@ -49,12 +50,6 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch

// Run synchronous event emitter
go func() {
defer func() {
recover()
// This recovers from "bufio: reader returned negative count from Read" panic
// when the underlying stream is closed
}()

// Output initial port state
for _, port := range current {
eventCB("add", toDiscoveryPort(port))
Expand All @@ -63,7 +58,11 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
dec := uevent.NewDecoder(syncReader)
for {
evt, err := dec.Decode()
if err != nil {
if err == io.EOF {
// The underlying syncReader has been closed
// so there's nothing else to read
return
} else if err != nil {
errorCB(fmt.Sprintf("Error decoding serial event: %s", err))
return
}
Expand Down