mirror of
https://github.com/icewind1991/mhz19-rs
synced 2026-06-03 09:34:12 +02:00
take tty path as arugment
This commit is contained in:
parent
4edd0ffff0
commit
630087ac72
1 changed files with 8 additions and 4 deletions
|
|
@ -2,13 +2,17 @@ use mhz19::MHZ19;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
const DELAY: Duration = Duration::from_secs(1);
|
const DELAY: Duration = Duration::from_secs(1);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
loop {
|
match env::args().skip(1).next() {
|
||||||
listen("/dev/ttyUSB0");
|
Some(path) => loop {
|
||||||
|
listen(&path);
|
||||||
sleep(DELAY);
|
sleep(DELAY);
|
||||||
|
},
|
||||||
|
None => eprintln!("Path required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue