You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modbus is based on a
master/slave
communication pattern. To avoid confusion with the Tokio terminology the
master is called client and the slave is called server in this library.
Features
Pure Rust library
Modbus TCP or RTU at your choice
Both async (non-blocking, default) and sync (blocking, optional)
Client API
Server implementations
for out-of-the-box usage or
as a starting point for a customized implementation
Open source (MIT/Apache-2.0)
Installation
Add this to your Cargo.toml:
[dependencies]
tokio-modbus = "*"
Cargo Features
"rtu": Asynchronous RTU client (default)
"tcp": Asynchronous TCP client (default)
"rtu-sync: Synchronous RTU client
"tcp-sync": Synchronous TCP client
"rtu-server": (Asynchronous) RTU server
"tcp-server": (Asynchronous) TCP server
"rtu-over-tcp-server": (Asynchronous) RTU over TCP server
Examples
If you only need an asynchronous TCP client add the following line to your
Cargo.toml file:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp"] }
For an asynchronous RTU client:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu"] }
For an RTU server:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu-server"] }
For a TCP server:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp-server"] }
Examples
Various examples for Modbus RTU and TCP using either the asynchronous or
synchronous API can be found in the
examples folder.
Testing
The workspace contains documentation, tests, and examples for all available
features.
cargo test --workspace
cargo test --workspace --all-features