-
Notifications
You must be signed in to change notification settings - Fork 369
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
Found a bug when slave device return error code #20
Comments
Thanks for your report, I'll take a look this weekend |
I'm running into the same problem with the Modbus RTU client. The full stacktrace looks like this:
This occurs when the RTU connection is faulty, i.e. the line corrupts error messages. The corrupted messages are then shorter/longer as expected by the functionFail code. A length check before assuming 5 bytes to read should solve this. I tried to capture more debug information (bytes on the wire), but so far I wasn't able to record a sample for this. Sorry! |
Thanks, I will fix this issue very soon. |
I just updated my project with your latest release, and connected my faulty device. I do not see the error, so in my case, your fix worked. Thank you! |
Modbus RTU Client:
"panic: runtime error: slice bounds out of range"
This panic occurs when slave device return an error code, and the frame return may be not standard.
source: rtuclient.go, n1
line: err = io.ReadFull(mb.port, data[n:5])
I changed for temporary:
err = fmt.Errorf("modbus: return error code")
n1 = 0
Maybe you could check code for similar problems.
Thank you for your product.
ggenien
The text was updated successfully, but these errors were encountered: