#plc #modbus #ethernet #automation #hardware #api-bindings

plctag-core

a rust wrapper of libplctag, with rust style APIs and useful extensions

8 releases

0.4.1 Feb 19, 2023
0.4.0 Jan 14, 2023
0.3.1 Sep 27, 2022
0.3.0 Feb 25, 2022
0.1.0 Sep 14, 2021

#1059 in Hardware support

Download history 2/week @ 2023-11-20 30/week @ 2024-01-29 27/week @ 2024-02-19 19/week @ 2024-02-26 26/week @ 2024-03-04

72 downloads per month
Used in 3 crates

MIT license

2MB
30K SLoC

C 27K SLoC // 0.2% comments Rust 1K SLoC // 0.1% comments C++ 741 SLoC // 0.3% comments Java 464 SLoC // 0.4% comments Python 401 SLoC // 0.4% comments Shell 305 SLoC // 0.1% comments Go 234 SLoC // 0.2% comments Pascal 116 SLoC // 0.7% comments

plctag-core

a rust wrapper of libplctag, with rust style APIs and useful extensions.

crates.io docs build license

How to use

Add plctag-core to your Cargo.toml

[dependencies]
plctag-core= "0.4"

Examples

read/write tag

use plctag_core::{Encode, Decode, RawTag, ValueExt};
let timeout = 100;//ms
let path="protocol=ab-eip&plc=controllogix&path=1,0&gateway=192.168.1.120&name=MyTag1&elem_count=1&elem_size=16";// YOUR TAG DEFINITION
let tag = RawTag::new(path, timeout).unwrap();

//read tag
let status = tag.read(timeout);
assert!(status.is_ok());
let offset = 0;
let value:u16 = tag.get_value(offset).unwrap();
println!("tag value: {}", value);

let value = value + 10;
tag.set_value(offset, value).unwrap();

//write tag
let status = tag.write(timeout);
assert!(status.is_ok());
println!("write done!");

More examples

please take a look at examples

Build

Please refer to How to build to setup build environment.

License

MIT

Dependencies

~0–2MB
~41K SLoC