Crates.io | plctag-async |
lib.rs | plctag-async |
version | 0.4.1 |
source | src |
created_at | 2021-09-14 07:22:09.524769 |
updated_at | 2023-02-19 02:09:41.431757 |
description | async wrapper for libplctag |
homepage | https://github.com/Joylei/plctag-rs |
repository | https://github.com/Joylei/plctag-rs.git |
max_upload_size | |
id | 451078 |
size | 19,122 |
async wrapper for libplctag
.
Add plctag-async
to your Cargo.toml
[dependencies]
plctag-async= "0.4"
use plctag_async::{AsyncTag, Error, Pool, PoolEntry};
use tokio::runtime;
let rt = runtime::Runtime::new().unwrap()?;
rt.block_on(async {
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 pool = Pool::new();
let tag = pool.entry(path).await.unwrap();
let tag_ref = tag.get().await.unwrap();
let offset = 0;
let value:u16 = tag_ref.read_value(offset).await.unwrap();
println!("tag value: {}", value);
let value = value + 10;
tag_ref.write_value(offset, value).await.unwrap();
});
Please refer to How to build to setup build environment.
MIT