slowtec / tokio-modbus

A tokio-based modbus library
Apache License 2.0
379 stars 117 forks source link
ascii async automation client fieldbus library modbus non-blocking rtu rust server support tcp tokio

tokio-modbus

A pure Rust Modbus library based on tokio.

Crates.io Docs.rs Security audit Continuous integration MIT licensed Apache 2.0 licensed

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

Installation

Add this to your Cargo.toml:

[dependencies]
tokio-modbus = "*"

Cargo Features

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

Protocol-Specification

License

Copyright (c) 2017-2024 slowtec GmbH

MIT/Apache-2.0