Skip to content

Instantly share code, notes, and snippets.

@zzeroo
Created May 25, 2020 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzeroo/b89a0c7e4d3de4d834faf8cd7ebaa345 to your computer and use it in GitHub Desktop.
Save zzeroo/b89a0c7e4d3de4d834faf8cd7ebaa345 to your computer and use it in GitHub Desktop.
How to annote the type information?
use std::thread;
use tokio::runtime::Runtime;
use tokio_modbus::prelude::*;
use tokio_serial::Serial;
fn main() {
thread::spawn(|| {
let mut rt = Runtime::new().expect("Couldn't create Runtime");
rt.block_on(async {
let port = Serial::from_path("/dev/ttyUSB0", &Default::default()).unwrap();
let mut ctx = rtu::connect_slave(port, 247.into()).await?;
let data = ctx.read_input_registers(0, 10).await?;
println!(".");
Ok(())
})
})
.join()
.unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment