plctag-async

Crates.ioplctag-async
lib.rsplctag-async
version0.4.1
sourcesrc
created_at2021-09-14 07:22:09.524769
updated_at2023-02-19 02:09:41.431757
descriptionasync wrapper for libplctag
homepagehttps://github.com/Joylei/plctag-rs
repositoryhttps://github.com/Joylei/plctag-rs.git
max_upload_size
id451078
size19,122
joylei (Joylei)

documentation

https://docs.rs/crate/plctag/

README

plctag-async

async wrapper for libplctag.

crates.io docs build license

How to use

Add plctag-async to your Cargo.toml

[dependencies]
plctag-async= "0.4"

Examples

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();
});

Build

Please refer to How to build to setup build environment.

License

MIT

Commit count: 195

cargo fmt