-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why read timeout return a nil error? #148
Comments
Unfortunately, this is a breaking change. I'm collecting all the breaking changes to be implemented in a future 2.0 release, BTW it's a low priority, for now, no estimates for when it will be done. |
This is a simple workaround: var errTimeout = errors.New("timeout")
type timeoutReader struct {
r io.Reader
}
func NewTimeoutReader(r io.Reader) timeoutReader {
return timeoutReader{r}
}
func (t timeoutReader) Read(p []byte) (n int, err error) {
n, err = t.r.Read(p)
if n == 0 {
err = errTimeout
}
return
} You only have to wrap your port in a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when i write a command, then i use io.ReadFull to read an response. But if the device do not response, it will STW.
whether to return a read timeout error?
The text was updated successfully, but these errors were encountered: