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.
libmodbus-rs
libmodbus bindings for Rust
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.
[]
= "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 ;
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 runningrandom-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
andbandwidth-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 whereasbandwidth-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
In another shell start the client after the server
License
libmodbus-rs
is distributed under the terms of the LGPL-2.1 license, which is the same license, libmodbus is using.
Links
- http://libmodbus.org
- https://github.com/stephane/libmodbus.git
- https://github.com/servo/rust-bindgen
- https://doc.rust-lang.org/book/ffi.html
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.