-
Notifications
You must be signed in to change notification settings - Fork 122
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
Client: how to identify Modbus exception code sent by server in response #169
Comments
Hey 👋 I'm really in the need of finding out what Modbus error I got from a slave for my application. After looking through the code. I found a fast, simple way to get access to the exception from a modbus server. You just have to make the |
This issue is resolved, verified working now in tokio-modbus v0.14.0. Example of issuing a command like: let values = read_registers(connection, start, count)
.await
.context("communication error")?
.context("received a Modbus exception response")?; and then the program might produce either a Modbus exception response:
or some other I/O error (in this case simulated by connecting to a server that sends random bytes instead of Modbus frames back):
Thanks for getting this working! |
How can user code using tokio-modbus as a Modbus client detect what specific exception code a server returned?
Two interrelated parts of this question:
In the case of Modbus exception responses, we don't want to close the Modbus connection. But if the network connection was lost, then user code needs to re-create a new tokio-modbus connection and start over.
Related:
The text was updated successfully, but these errors were encountered: