A tokio-based modbus library.
- Pure Rust library
- Modbus TCP or RTU at your choice
- Both
async
(non-blocking, default) andsync
(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)
Add this to your Cargo.toml
:
[dependencies]
tokio-modbus = "*"
If you like to use Modbus TCP only:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp"] }
If you like to use Modbus RTU only:
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu"] }
If you like to build a TCP server:
[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:
cargo test --workspace --all-features
Otherwise some doctests that require non-default features like sync
are expected to fail.
- MODBUS Application Protocol Specification v1.1b3 (PDF)
- MODBUS over serial line specification and implementation guide v1.02 (PDF)
- MODBUS Messaging on TCP/IP Implementation Guide v1.0b (PDF)
Copyright 2017 - 2021 slowtec GmbH