use ads_client::{Client, AdsTimeout}; use tokio::runtime::Runtime; fn main() { let rt = Runtime::new().unwrap(); let ads_client = rt.block_on(Client::new("5.80.201.232.1.1", 851, AdsTimeout::DefaultTimeout)).unwrap(); // Get symbol handle let mut hdl : [u8; 4] = [0; 4]; let symbol = b"MAIN.n_cnt_a"; if let Err(err) = rt.block_on(ads_client.read_write(0xF003, 0, &mut hdl, symbol)){ println!("Error: {}", err.to_string()); } let n_hdl = u32::from_ne_bytes(hdl.try_into().unwrap()); if n_hdl != 0 { println!("Got handle!"); let mut plc_n_cnt_a : [u8; 2] = [0; 2]; match rt.block_on(ads_client.read(0xF005, n_hdl, &mut plc_n_cnt_a)){ Ok(_bytes_read) => { let n_cnt_a = u16::from_ne_bytes(plc_n_cnt_a.try_into().unwrap()); println!("MAIN.n_cnt_a: {}", n_cnt_a); }, Err(err) => println!("Read failed: {}", err.to_string()) } } }