kinghajj / modbus-rs

Modbus implementation in pure Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust Modbus

Build Status Coverage Status License

Modbus implementation in pure Rust.

Usage

Add modbus to your Cargo.toml dependencies:

[dependencies]
modbus = "0.1.0"

Import the modbus crate and use it's functions:

use modbus::{BitValue};
use modbus::tcp::{Ctx, write_single_coil, read_coils};

let mut ctx = Ctx::new("192.168.0.10");

write_single_coil(&mut ctx, 1, BitValue::On).unwrap();
write_single_coil(&mut ctx, 3, BitValue::On).unwrap();

let res = read_coils(&mut ctx, 0, 5).unwrap();

// res ==  vec![BitValue::Off, BitValue::On, BitValue::Off, BitValue::On, BitValue::Off]);

See the documentation for usage examples and further reference.

License

Copyright © 2015 Falco Hirschenberger

Distributed under the MIT License.

About

Modbus implementation in pure Rust

License:MIT License


Languages

Language:Rust 92.7%Language:C 7.3%