A pure Rust Modbus library based on tokio.
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.
async
(non-blocking, default) and sync
(blocking, optional)Add this to your Cargo.toml
:
toml
[dependencies]
tokio-modbus = "*"
If you like to use Modbus TCP only:
toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp"] }
If you like to use Modbus RTU only:
toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu"] }
If you like to build a TCP server:
toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp", "server"] }
Various examples for Modbus RTU and TCP using either the asynchronous or synchronous API can be found in the examples folder.
The workspace contains documentation, tests, and examples for all available features. Running the tests for the whole workspace only succeeds with all features enabled:
sh
cargo test --workspace --all-features
Otherwise some doctests that require non-default features like sync
are expected to fail.
Copyright (c) 2017-2023 slowtec GmbH