Crates.io | libmodbus-rs |
lib.rs | libmodbus-rs |
version | 0.8.3 |
source | src |
created_at | 2017-05-14 06:24:05.966741 |
updated_at | 2017-12-21 09:36:55.110607 |
description | libmodbus bindings for Rust |
homepage | http://zzeroo.github.io/libmodbus-rs |
repository | https://github.com/zzeroo/libmodbus-rs.git |
max_upload_size | |
id | 14528 |
size | 261,964 |
This crate is an reduced version without active bindgen! I need this because our build system can not deliver rust and libclang. Please don't use in production and expect odd behavior.
Libmodbus is a free software library to send and receive data with a device that respects the Modbus protocol. That crate contains the Rust bindings for the libmodbus library (written in C). Like libmodbus self, this crate supports serial port and Ethernet connections for Modbus server and clients.
Homepage | Documentation | Original libmodbus documentation | Github repo |
This crate based on the latest libmodbus git:master branch. I plan to support the different libmodbus version via cargo's feature
feature.
Include the dependencies into your Cargo.toml
file.
[dependencies]
libmodbus-rs = "0.6"
[dependencies]
libmodbus-rs = { git = "https://github.com/zzeroo/libmodbus-rs.git" }
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, ModbusServer, ModbusTCP};
The examples in the examples directory show this.
The libmodbus ffi bindings (libmodbus-sys) are build using bindgen. Bindgen need Clang 3.9 or greater on your system.
pacman -S autoconf clang39 git libtool make
apt-get install autoconf build-essential curl clang-3.9 git-core libtool
Look also at the local ci/ docker files under ./ci/docker-archlinux
and .ci/docker-debian9
for a known working, minimal setup.
For more information about the bindgen requirements please visit https://servo.github.io/rust-bindgen/requirements.html
If all dependencies are solved, compile with cargo build
and/ or run the tests with cargo test
.
git clone https://github.com/zzeroo/libmodbus-rs
cd libmodbus-rs
cargo build
All original libmodbus examples are reproduced in Rust. You can find them in the
examples
directory of this crate.
Please have look at the README.md in the examples directory for more information about the examples.
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
libmodbus-rs
is distributed under the terms of the LGPL-2.1 license, which is the same license, libmodbus is using.
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.