Skip to main content

BidirDecoder

Struct BidirDecoder 

Source
pub struct BidirDecoder {
    pub cfg: OversamplingConfig,
    pub preamble_tuning: PreambleTuningConfig,
    /* private fields */
}

Fields§

§cfg: OversamplingConfig§preamble_tuning: PreambleTuningConfig

Implementations§

Source§

impl BidirDecoder

Source

pub const fn new(cfg: OversamplingConfig) -> Self

Examples found in repository?
examples/local_telemetry_oversampling.rs (line 48)
38fn main() {
39    let cfg = OversamplingConfig {
40        sample_bit_index: 0,
41        oversampling: 4,
42        frame_bits: 21,
43        min_detected_bits: 18,
44        bit_tolerance: 2,
45    };
46    let samples = build_oversampled_samples(0, 8, &RUNS_5A55, cfg.oversampling as usize);
47
48    let decoder = BidirDecoder::new(cfg);
49    match decoder.decode_frame(&samples) {
50        Ok(TelemetryFrame::Erpm(erpm)) => {
51            println!(
52                "decoded eRPM period={}us mech_rpm(pole_pairs=14)={}",
53                erpm.period(),
54                erpm.mechanical_rpm(14)
55            );
56        }
57        Ok(other) => println!("decoded frame={other:?}"),
58        Err(err) => println!("decode error={err:?}"),
59    }
60}
Source

pub const fn with_preamble_tuning( cfg: OversamplingConfig, preamble_tuning: PreambleTuningConfig, ) -> Self

Source

pub fn decode_frame( &self, samples: &[u16], ) -> Result<TelemetryFrame, TelemetryError>

Examples found in repository?
examples/local_telemetry_oversampling.rs (line 49)
38fn main() {
39    let cfg = OversamplingConfig {
40        sample_bit_index: 0,
41        oversampling: 4,
42        frame_bits: 21,
43        min_detected_bits: 18,
44        bit_tolerance: 2,
45    };
46    let samples = build_oversampled_samples(0, 8, &RUNS_5A55, cfg.oversampling as usize);
47
48    let decoder = BidirDecoder::new(cfg);
49    match decoder.decode_frame(&samples) {
50        Ok(TelemetryFrame::Erpm(erpm)) => {
51            println!(
52                "decoded eRPM period={}us mech_rpm(pole_pairs=14)={}",
53                erpm.period(),
54                erpm.mechanical_rpm(14)
55            );
56        }
57        Ok(other) => println!("decoded frame={other:?}"),
58        Err(err) => println!("decode error={err:?}"),
59    }
60}
Source

pub fn decode_frame_with_hint( &self, samples: &[u16], hint: DecodeHint, ) -> Result<TelemetryFrame, TelemetryError>

Source

pub fn decode_frame_tuned( &mut self, samples: &[u16], ) -> Result<TelemetryFrame, TelemetryError>

Source

pub fn decode_frame_tuned_port_samples( &mut self, samples: &[u32], bit_mask: u32, ) -> Result<TelemetryFrame, TelemetryError>

Source

pub fn decode_frame_tuned_port_samples_u16( &mut self, samples: &[u16], bit_mask: u16, ) -> Result<TelemetryFrame, TelemetryError>

Source

pub const fn stream_hint(&self) -> DecodeHint

Source

pub fn set_stream_hint(&mut self, hint: DecodeHint)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.