1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-30 04:19:00 +01:00
libdvb/examples/femon.rs

45 lines
776 B
Rust
Raw Normal View History

use {
std::{
path::Path,
time::Duration,
thread,
},
anyhow::{
anyhow,
Result,
},
libdvb::{
FeDevice,
FeStatus,
},
};
pub fn start(fepath: &str) -> Result<()> {
let fepath = Path::new(fepath);
println!("Frontend: {}", fepath.display());
let fe = FeDevice::open_rd(fepath)?;
let mut status = FeStatus::default();
let delay = Duration::from_secs(1);
loop {
status.read(&fe)?;
2021-01-29 18:45:49 +01:00
println!("{}", &status);
thread::sleep(delay);
}
}
fn main() -> Result<()> {
let mut args = std::env::args().skip(1);
if let Some(ref fepath) = args.next() {
start(fepath)
} else {
Err(anyhow!("Path to frontend not defined"))
}
}