https://github.com/slowtec/tokio-modbus
A tokio-based modbus library
https://github.com/slowtec/tokio-modbus
ascii async automation client fieldbus library modbus non-blocking rtu rust server support tcp tokio
Last synced: 27 days ago
JSON representation
A tokio-based modbus library
- Host: GitHub
- URL: https://github.com/slowtec/tokio-modbus
- Owner: slowtec
- License: apache-2.0
- Created: 2017-10-21T19:51:54.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-14T13:33:30.000Z (about 1 month ago)
- Last Synced: 2025-03-14T14:31:32.896Z (about 1 month ago)
- Topics: ascii, async, automation, client, fieldbus, library, modbus, non-blocking, rtu, rust, server, support, tcp, tokio
- Language: Rust
- Size: 560 KB
- Stars: 447
- Watchers: 14
- Forks: 129
- Open Issues: 39
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSES/Apache-2.0.txt
Awesome Lists containing this project
- awesome-rust - slowtec/tokio-modbus - based [modbus](http://modbus.org) library. [](https://travis-ci.org/slowtec/tokio-modbus) (Applications / Industrial automation)
- awesome-rust - slowtec/tokio-modbus - based [modbus](https://modbus.org) library. (Applications / Industrial automation)
- fucking-awesome-rust - slowtec/tokio-modbus - A 🌎 [tokio](tokio.rs)-based 🌎 [modbus](modbus.org) library. (Applications / Industrial automation)
- awesome-rust-zh - slowtec/tokio-modbus - 一个基于[tokio](https://tokio.rs)的[modbus](http://modbus.org) 库。[](https://travis-ci.org/slowtec/tokio-modbus) (应用 / 工业自动化)
- awesome-rust - slowtec/tokio-modbus - A [tokio](https://tokio.rs)-based [modbus](https://modbus.org) library. (Applications / Industrial automation)
- awesome-rust - slowtec/tokio-modbus - based [modbus](http://modbus.org) library. [](https://travis-ci.org/slowtec/tokio-modbus) (应用 Applications / 工业自动化 Industrial automation)
- awesome-rust-cn - slowtec/tokio-modbus - based [modbus](http://modbus.org) library. [](https://travis-ci.org/slowtec/tokio-modbus) (应用 / Industrial automation)
- fucking-awesome-rust - slowtec/tokio-modbus - A 🌎 [tokio](tokio.rs)-based 🌎 [modbus](modbus.org) library. (Applications / Industrial automation)
- awesome-rust-cn - slowtec/tokio-modbus
README
# tokio-modbus
A pure [Rust](https://www.rust-lang.org)
[Modbus](https://en.wikipedia.org/wiki/Modbus) library based on
[tokio](https://tokio.rs).[](https://crates.io/crates/tokio-modbus)
[](https://docs.rs/tokio-modbus/)
[](https://github.com/slowtec/tokio-modbus/actions/workflows/security-audit.yaml)
[](https://github.com/slowtec/tokio-modbus/actions/workflows/build-and-test.yaml)
[](./LICENSE-MIT)
[](./LICENSE-APACHE)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`:
```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:```toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["tcp"] }
```For an asynchronous RTU client:
```toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu"] }
```For an RTU server:
```toml
[dependencies]
tokio-modbus = { version = "*", default-features = false, features = ["rtu-server"] }
```For a TCP server:
```toml
[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](https://github.com/slowtec/tokio-modbus/tree/main/examples) folder.## Testing
The workspace contains documentation, tests, and examples for all available
features.```sh
cargo test --workspace
cargo test --workspace --all-features
```## Protocol-Specification
- [Modbus Application Protocol Specification v1.1b3 (PDF)](http://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf)
- [Modbus over serial line specification and implementation guide v1.02 (PDF)](http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
- [Modbus Messaging on TCP/IP Implementation Guide v1.0b (PDF)](http://modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)## License
Copyright (c) 2017-2024 [slowtec GmbH](https://www.slowtec.de)
[MIT](LICENSES/MIT.txt)/[Apache-2.0](LICENSES/Apache-2.0.txt)