Crates.io | plctag-core |
lib.rs | plctag-core |
version | 0.4.1 |
source | src |
created_at | 2021-09-14 07:17:39.600581 |
updated_at | 2023-02-19 02:07:14.590461 |
description | a rust wrapper of [libplctag](https://github.com/libplctag/libplctag), with rust style APIs and useful extensions |
homepage | https://github.com/Joylei/plctag-rs |
repository | https://github.com/Joylei/plctag-rs.git |
max_upload_size | |
id | 451076 |
size | 55,639 |
a rust wrapper of libplctag, with rust style APIs and useful extensions.
Add plctag-core
to your Cargo.toml
[dependencies]
plctag-core= "0.4"
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!");
please take a look at examples
Please refer to How to build to setup build environment.
MIT