sleep in passive read example

This commit is contained in:
Robin Appelman 2020-08-16 06:20:16 +02:00
commit 1b2e248126

View file

@ -3,11 +3,14 @@ use nb::block;
use pms700x::Pms700X; use pms700x::Pms700X;
use std::env::args; use std::env::args;
use std::path::PathBuf; use std::path::PathBuf;
use std::thread::sleep;
use std::time::Duration;
fn main() { fn main() {
let port = args().skip(1).next().expect("No serial provided"); let port = args().skip(1).next().expect("No serial provided");
let serial = Serial::open(&PathBuf::from(port)).unwrap(); let serial = Serial::open(&PathBuf::from(port)).unwrap();
let mut pms = Pms700X::new(serial).into_passive().unwrap(); let mut pms = Pms700X::new(serial).into_passive().unwrap();
sleep(Duration::from_millis(50));
dbg!(block!(pms.read()).unwrap()); dbg!(block!(pms.read()).unwrap());
} }