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

fe/sys: more info in debug for DtvProperty, DtvFrontendStats, DtvStats

This commit is contained in:
Andrey Dyldin 2021-01-29 13:52:09 +02:00
parent d3f6d144bd
commit f09139fd9a
2 changed files with 77 additions and 21 deletions

View File

@ -127,7 +127,6 @@ pub struct CaPid {
}
// pub const CA_GET_SLOT_INFO: IoctlInt = io_read::<CaSlotInfo>(b'o', 130);
// pub const CA_GET_DESCR_INFO: IoctlInt = io_read::<CaDescrInfo>(b'o', 131);
// pub const CA_GET_MSG: IoctlInt = io_read::<CaMsg>(b'o', 132);
// pub const CA_SEND_MSG: IoctlInt = io_write::<CaMsg>(b'o', 133);

View File

@ -439,13 +439,31 @@ pub struct DtvStats {
impl fmt::Debug for DtvStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut s = f.debug_struct("DtvStats");
s.field("scale", &{self.scale});
const FIELD_SCALE: &str = "scale";
const FIELD_VALUE: &str = "value";
match self.scale {
FE_SCALE_NOT_AVAILABLE => s.field("value", &"not available"),
FE_SCALE_DECIBEL => s.field("value", &{self.value}),
FE_SCALE_RELATIVE => s.field("value", &{self.value as u64}),
FE_SCALE_COUNTER => s.field("value", &{self.value as u64}),
_ => s.field("value", &"invalid scale format"),
FE_SCALE_NOT_AVAILABLE => {
s.field(FIELD_SCALE, &"FE_SCALE_NOT_AVAILABLE");
s.field(FIELD_VALUE, &"not available");
}
FE_SCALE_DECIBEL => {
s.field(FIELD_SCALE, &"FE_SCALE_DECIBEL");
s.field(FIELD_VALUE, &{(self.value as f64) / 1000.0});
}
FE_SCALE_RELATIVE => {
s.field(FIELD_SCALE, &"FE_SCALE_RELATIVE");
s.field(FIELD_VALUE, &{self.value as u64});
}
FE_SCALE_COUNTER => {
s.field(FIELD_SCALE, &"FE_SCALE_COUNTER");
s.field(FIELD_VALUE, &{self.value as u64});
}
_ => {
s.field(FIELD_SCALE, &{self.scale});
s.field(FIELD_VALUE, &"invalid scale format");
}
};
s.finish()
}
@ -457,13 +475,21 @@ pub const MAX_DTV_STATS: usize = 4;
/// Store Digital TV frontend statistics
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
#[derive(Copy, Clone)]
pub struct DtvFrontendStats {
pub len: u8,
pub stat: [DtvStats; MAX_DTV_STATS],
}
impl fmt::Debug for DtvFrontendStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let stats = &self.stat[0 .. self.len as usize];
f.debug_list().entries(stats.iter()).finish()
}
}
impl DtvFrontendStats {
pub fn get_counter(&self) -> Option<u64> {
for i in 0 .. ::std::cmp::min(self.len as usize, self.stat.len()) {
@ -625,41 +651,72 @@ pub struct DtvProperty {
impl fmt::Debug for DtvProperty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut s = f.debug_struct("DtvProperty");
s.field("cmd", &{ self.cmd });
const FNAME: &str = "value";
const FIELD_CMD: &str = "cmd";
const FIELD_DATA: &str = "data";
const FIELD_STATS: &str = "stats";
match self.cmd {
DTV_FREQUENCY => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_FREQUENCY");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_MODULATION => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_MODULATION");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_BANDWIDTH_HZ => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_BANDWIDTH_HZ");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_INVERSION => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_INVERSION");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_SYMBOL_RATE => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_SYMBOL_RATE");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_INNER_FEC => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_INNER_FEC");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_PILOT => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_PILOT");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_ROLLOFF => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_ROLLOFF");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_DELIVERY_SYSTEM => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_DELIVERY_SYSTEM");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
DTV_API_VERSION => {
s.field(FNAME, unsafe { &self.u.data });
s.field(FIELD_CMD, &"DTV_API_VERSION");
s.field(FIELD_DATA, unsafe { &self.u.data });
}
/* Quality parameters */
DTV_STAT_SIGNAL_STRENGTH => {
s.field(FIELD_CMD, &"DTV_STAT_SIGNAL_STRENGTH");
s.field(FIELD_STATS, unsafe { &self.u.st });
}
DTV_STAT_CNR => {
s.field(FIELD_CMD, &"DTV_STAT_CNR");
s.field(FIELD_STATS, unsafe { &self.u.st });
}
DTV_STAT_PRE_ERROR_BIT_COUNT => {
s.field(FIELD_CMD, &"DTV_STAT_PRE_ERROR_BIT_COUNT");
s.field(FIELD_STATS, unsafe { &self.u.st });
}
DTV_STAT_ERROR_BLOCK_COUNT => {
s.field(FIELD_CMD, &"DTV_STAT_ERROR_BLOCK_COUNT");
s.field(FIELD_STATS, unsafe { &self.u.st });
}
// TODO: more values
_ => {}
}