Created
May 25, 2020 14:22
-
-
Save zzeroo/1b8e25eda202ce37b915b32a5c287fdd to your computer and use it in GitHub Desktop.
Where to put the type info?
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!("{:?}", data); | |
Ok(()) | |
}) | |
}) | |
.join() | |
.unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This returns an error like this: