Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
ffi
 
 
 
 
 
 
 
 
 
 
 
 

README.md

rodbus

crates.io docs.rs MSRV Build status Codecov

Rust async/await implementation of the Modbus protocol using Tokio with idiomatic bindings for C/C++, Java, and .NET Core.

license

Refer to License.txt for the terms of the non-commercial license. This software is "source available", but is not "open source". You must purchase a commercial license to use this software for profit.

Library

Documentation

Rodbus is library for implementing Modbus client and server applications. The library is safe, memory-efficient and easy to use. All of the error handling in the library is explicit and logging is available by providing a backend to the log crate. Three client interfaces are provided for making requests:

  • Async (Rust futures)
  • Callback-based
  • Synchronous (blocking)

The client and server examples demonstrate simple usage of the API.

The following function codes are supported:

  • Read Coils (0x01)
  • Read Discrete Inputs (0x02)
  • Read Holding Registers (0x03)
  • Read Input Registers (0x04)
  • Write Single Coil (0x05)
  • Write Single Register (0x06)
  • Write Multiple Coils (0x0F)
  • Write Multiple Registers (0x10)

The library uses the Tokio executor under the hood. The perf example is a benchmark that creates multiple sessions on a single server and sends multiple requests in parallel. On a decent workstation, the benchmark achieved around 200k requests per second spread across 100 concurrent sessions in only 800 KB of memory.

Future support

C/C++ bindings

The rodbus-ffi directory contains an idiomatic C/C++ API to the library. Requests can be sent asynchronously using callback functions or synchronously with blocking function calls.

In this early release, only the client side of the library has been exposed and is only known to work on *nix platforms. Please read the C/C++ Documentation and review the examples.

To generate the bindings, do the following:

  • Install cbindgen with cargo install cbindgen
  • Run cbingen -c cmake/cbindgen.c.toml -o rodbus.h
  • Run cbingen -c cmake/cbindgen.cpp.toml -o rodbus.hpp
  • Build rodbus-ffi

To use the bindings, you will need to includerodbus.h or rodbus.hpp which each include prelude.h. You will also need to link with the compiled library rodbus_ffi.so found in the target directory.

There is also a CMake script that can help you automatically build and link to rodbus from a C/C++ project.

Modbus client CLI

You can test Modbus servers from the command line with the rodbus-client crate.

You can’t perform that action at this time.