1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-30 04:19:00 +01:00
libdvb/examples/femon.rs
2021-03-16 10:43:37 +02:00

43 lines
800 B
Rust

use {
std::{
time::Duration,
thread,
},
anyhow::{
bail,
Context,
Result,
},
libdvb::{
FeDevice,
FeStatus,
},
};
fn main() -> Result<()> {
let mut args = std::env::args().skip(1);
let adapter = match args.next() {
Some(v) => v.parse::<u32>().context("adapter number")?,
None => bail!("adapter number not defined"),
};
let device = match args.next() {
Some(v) => v.parse::<u32>().context("device number")?,
None => 0,
};
let fe = FeDevice::open_ro(adapter, device)?;
let mut status = FeStatus::default();
let delay = Duration::from_secs(1);
loop {
status.read(&fe)?;
println!("{}", &status);
thread::sleep(delay);
}
}