Created
May 25, 2020 14:21
-
-
Save zzeroo/b89a0c7e4d3de4d834faf8cd7ebaa345 to your computer and use it in GitHub Desktop.
How to annote the type information?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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