libmodbus-rs 0.4.2

Binding to libmodbus. Libmodbus is a free software library to send/receive data with a device which respects the Modbus protocol. This library can use a serial port or an Ethernet connection. http://libmodbus.org/
docs.rs failed to build libmodbus-rs-0.4.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: libmodbus-rs-0.8.3

libmodbus-rs

libmodbus bindings for Rust Crates.io version Build Status Build status

Homepage |  Documentation |  original libmodbus Documentation |  Repo auf Github.com |

This crate is in early beta state. Please don't use in production and expect odd behavior.

This crate based on the latest libmodbus git:master branch. I plan to support the different libmodbus version via cargo's feature feature.

Usage

Include the dependencies into your Cargo.toml file.

[dependencies]
libmodbus = "0.4"

Some header files of the original libmodbus C library are recreated as traits (e.g. ModbusTCP, ModbusRTU, ModbusServer, ModbusClient, ...). For example if you what to build an modbus server, in the modbus tcp context, include the following:

extern crate libmodbus_rs;

use libmodbus_rs::{Modbus, ModbusTCP, ModbusServer};

The examples in the examples dir, show this.

Building libmodbus-rs

The libmobus ffi bindings (libmodbus-sys) are build using bindgen. Bindgen need Clang 3.9 or greater on your system.

Debian based

# apt-get install llvm-3.9-dev libclang-3.9-dev clang-3.9

Arch

# pacman -S clang

For mor information about the bindgen requirements please visit https://servo.github.io/rust-bindgen/requirements.html

Examples

All original libmodbus examples are reproduced in Rust. You can find them in the examples directory of this crate.

  • random-test-server.rs is necessary to launch a server before running random-test-client.rs. By default, it receives and replies to Modbus query on the localhost and port 1502.

  • random-test-client.rs sends many different queries to a large range of addresses and values to test the communication between the client and the server.

  • unit-test-server.rs and unit-test-client run a full unit test suite. These programs are essential to test the Modbus protocol implementation and libmodbus behavior.

  • bandwidth-server-one.rs, bandwidth-server-many-up.rs and bandwidth-client.rs return very useful information about the performance of transfert rate between the server and the client. bandwidth-server-one.rs can only handles one connection at once with a client whereas bandwidth-server-many-up.rs opens a connection for each new clients (with a limit).

To start, for example, the random test server/ client use the following commands

cargo run --example random-test-server

In another shell start the client after the server

cargo run --example random-test-client
$ git clone https://github.com/zzeroo/libmodbus-rs
$ cd libmodbus-rs
$ cargo build

License

libmodbus-rs is distributed under the terms of the LGPL-2.1 license, which is the same license, libmodbus is using.

Links

This project hosts the original libmodbus documentation, used here, as well. Please have a look at http://zzeroo.github.io/libmodbus-rs/libmodbus/libmodbus.html.