Skip to content

ju6ge/tokio-modbus

 
 

Repository files navigation

tokio-modbus (PCE modbus)

This version of tokio-modbus was modified to be compatible with PCE instruments implementation of modbus which does not follow the modbus spec 🙈.

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

  • 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 = "*"

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"] }

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. 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.

Protocol-Specification

License

Copyright (c) 2017-2022 slowtec GmbH

MIT/Apache-2.0

About

A tokio-based modbus library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%