pub trait DeviceTrait: Any + Send {
type RxStreamer: RxStreamer;
type TxStreamer: TxStreamer;
Show 38 methods
// Required methods
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn driver(&self) -> Driver;
fn id(&self) -> Result<String, Error>;
fn info(&self) -> Result<Args, Error>;
fn num_channels(&self, direction: Direction) -> Result<usize, Error>;
fn full_duplex(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>;
fn rx_streamer(
&self,
channels: &[usize],
args: Args,
) -> Result<Self::RxStreamer, Error>;
fn tx_streamer(
&self,
channels: &[usize],
args: Args,
) -> Result<Self::TxStreamer, Error>;
fn antennas(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>;
fn antenna(
&self,
direction: Direction,
channel: usize,
) -> Result<String, Error>;
fn set_antenna(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<(), Error>;
fn supports_agc(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>;
fn enable_agc(
&self,
direction: Direction,
channel: usize,
agc: bool,
) -> Result<(), Error>;
fn agc(&self, direction: Direction, channel: usize) -> Result<bool, Error>;
fn gain_elements(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>;
fn set_gain(
&self,
direction: Direction,
channel: usize,
gain: f64,
) -> Result<(), Error>;
fn gain(
&self,
direction: Direction,
channel: usize,
) -> Result<Option<f64>, Error>;
fn gain_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>;
fn set_gain_element(
&self,
direction: Direction,
channel: usize,
name: &str,
gain: f64,
) -> Result<(), Error>;
fn gain_element(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Option<f64>, Error>;
fn gain_element_range(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Range, Error>;
fn frequency_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>;
fn frequency(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>;
fn set_frequency(
&self,
direction: Direction,
channel: usize,
frequency: f64,
args: Args,
) -> Result<(), Error>;
fn frequency_components(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>;
fn component_frequency_range(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Range, Error>;
fn component_frequency(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<f64, Error>;
fn set_component_frequency(
&self,
direction: Direction,
channel: usize,
name: &str,
frequency: f64,
) -> Result<(), Error>;
fn sample_rate(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>;
fn set_sample_rate(
&self,
direction: Direction,
channel: usize,
rate: f64,
) -> Result<(), Error>;
fn get_sample_rate_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>;
fn bandwidth(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>;
fn set_bandwidth(
&self,
direction: Direction,
channel: usize,
bw: f64,
) -> Result<(), Error>;
fn get_bandwidth_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>;
fn has_dc_offset_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>;
fn set_dc_offset_mode(
&self,
direction: Direction,
channel: usize,
automatic: bool,
) -> Result<(), Error>;
fn dc_offset_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>;
}Expand description
Central trait, implemented by hardware drivers.
Required Associated Types§
Sourcetype RxStreamer: RxStreamer
type RxStreamer: RxStreamer
Associated RX streamer
Sourcetype TxStreamer: TxStreamer
type TxStreamer: TxStreamer
Associated TX streamer
Required Methods§
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Cast to Any for downcasting to a mutable reference.
Sourcefn num_channels(&self, direction: Direction) -> Result<usize, Error>
fn num_channels(&self, direction: Direction) -> Result<usize, Error>
Number of supported Channels.
Sourcefn full_duplex(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
fn full_duplex( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Full Duplex support.
Sourcefn rx_streamer(
&self,
channels: &[usize],
args: Args,
) -> Result<Self::RxStreamer, Error>
fn rx_streamer( &self, channels: &[usize], args: Args, ) -> Result<Self::RxStreamer, Error>
Create an RX streamer.
Sourcefn tx_streamer(
&self,
channels: &[usize],
args: Args,
) -> Result<Self::TxStreamer, Error>
fn tx_streamer( &self, channels: &[usize], args: Args, ) -> Result<Self::TxStreamer, Error>
Create a TX streamer.
Sourcefn antennas(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
fn antennas( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>
List of available antenna ports.
Sourcefn antenna(&self, direction: Direction, channel: usize) -> Result<String, Error>
fn antenna(&self, direction: Direction, channel: usize) -> Result<String, Error>
Currently used antenna port.
Sourcefn set_antenna(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<(), Error>
fn set_antenna( &self, direction: Direction, channel: usize, name: &str, ) -> Result<(), Error>
Set antenna port.
Sourcefn supports_agc(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
fn supports_agc( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Does the device support automatic gain control?
Sourcefn enable_agc(
&self,
direction: Direction,
channel: usize,
agc: bool,
) -> Result<(), Error>
fn enable_agc( &self, direction: Direction, channel: usize, agc: bool, ) -> Result<(), Error>
Enable or disable automatic gain control.
Sourcefn agc(&self, direction: Direction, channel: usize) -> Result<bool, Error>
fn agc(&self, direction: Direction, channel: usize) -> Result<bool, Error>
Returns true, if automatic gain control is enabled
Sourcefn gain_elements(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
fn gain_elements( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>
List of available gain elements.
Elements should be in order RF to baseband.
Sourcefn set_gain(
&self,
direction: Direction,
channel: usize,
gain: f64,
) -> Result<(), Error>
fn set_gain( &self, direction: Direction, channel: usize, gain: f64, ) -> Result<(), Error>
Set the overall amplification in a chain.
The gain will be distributed automatically across available elements.
gain: the new amplification value in dB
Sourcefn gain(
&self,
direction: Direction,
channel: usize,
) -> Result<Option<f64>, Error>
fn gain( &self, direction: Direction, channel: usize, ) -> Result<Option<f64>, Error>
Get the overall value of the gain elements in a chain in dB.
Sourcefn gain_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>
fn gain_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>
Get the overall Range of possible gain values.
Sourcefn set_gain_element(
&self,
direction: Direction,
channel: usize,
name: &str,
gain: f64,
) -> Result<(), Error>
fn set_gain_element( &self, direction: Direction, channel: usize, name: &str, gain: f64, ) -> Result<(), Error>
Set the value of a amplification element in a chain.
§Arguments
name: the name of an amplification element fromDevice::list_gainsgain: the new amplification value in dB
Sourcefn gain_element(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Option<f64>, Error>
fn gain_element( &self, direction: Direction, channel: usize, name: &str, ) -> Result<Option<f64>, Error>
Get the value of an individual amplification element in a chain in dB.
Sourcefn gain_element_range(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Range, Error>
fn gain_element_range( &self, direction: Direction, channel: usize, name: &str, ) -> Result<Range, Error>
Get the range of possible gain values for a specific element.
Sourcefn frequency_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>
fn frequency_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>
Get the ranges of overall frequency values.
Sourcefn frequency(&self, direction: Direction, channel: usize) -> Result<f64, Error>
fn frequency(&self, direction: Direction, channel: usize) -> Result<f64, Error>
Get the overall center frequency of the chain.
- For RX, this specifies the down-conversion frequency.
- For TX, this specifies the up-conversion frequency.
Returns the center frequency in Hz.
Sourcefn set_frequency(
&self,
direction: Direction,
channel: usize,
frequency: f64,
args: Args,
) -> Result<(), Error>
fn set_frequency( &self, direction: Direction, channel: usize, frequency: f64, args: Args, ) -> Result<(), Error>
Set the center frequency of the chain.
- For RX, this specifies the down-conversion frequency.
- For TX, this specifies the up-conversion frequency.
The default implementation of set_frequency will tune the “RF”
component as close as possible to the requested center frequency in Hz.
Tuning inaccuracies will be compensated for with the “BB” component.
The args can be used to augment the tuning algorithm.
- Use
"OFFSET"to specify an “RF” tuning offset, usually with the intention of moving the LO out of the passband. The offset will be compensated for using the “BB” component. - Use the name of a component for the key and a frequency in Hz as the value (any format) to enforce a specific frequency. The other components will be tuned with compensation to achieve the specified overall frequency.
- Use the name of a component for the key and the value
"IGNORE"so that the tuning algorithm will avoid altering the component. - Vendor specific implementations can also use the same args to augment tuning in other ways such as specifying fractional vs integer N tuning.
Sourcefn frequency_components(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
fn frequency_components( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>
List available tunable elements in the chain.
Elements should be in order RF to baseband.
Sourcefn component_frequency_range(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<Range, Error>
fn component_frequency_range( &self, direction: Direction, channel: usize, name: &str, ) -> Result<Range, Error>
Get the range of tunable values for the specified element.
Sourcefn component_frequency(
&self,
direction: Direction,
channel: usize,
name: &str,
) -> Result<f64, Error>
fn component_frequency( &self, direction: Direction, channel: usize, name: &str, ) -> Result<f64, Error>
Get the frequency of a tunable element in the chain.
Sourcefn set_component_frequency(
&self,
direction: Direction,
channel: usize,
name: &str,
frequency: f64,
) -> Result<(), Error>
fn set_component_frequency( &self, direction: Direction, channel: usize, name: &str, frequency: f64, ) -> Result<(), Error>
Tune the center frequency of the specified element.
- For RX, this specifies the down-conversion frequency.
- For TX, this specifies the up-conversion frequency.
Sourcefn sample_rate(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>
fn sample_rate( &self, direction: Direction, channel: usize, ) -> Result<f64, Error>
Get the baseband sample rate of the chain in samples per second.
Sourcefn set_sample_rate(
&self,
direction: Direction,
channel: usize,
rate: f64,
) -> Result<(), Error>
fn set_sample_rate( &self, direction: Direction, channel: usize, rate: f64, ) -> Result<(), Error>
Set the baseband sample rate of the chain in samples per second.
Sourcefn get_sample_rate_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>
fn get_sample_rate_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>
Get the range of possible baseband sample rates.
Sourcefn bandwidth(&self, direction: Direction, channel: usize) -> Result<f64, Error>
fn bandwidth(&self, direction: Direction, channel: usize) -> Result<f64, Error>
Get the hardware bandwidth filter, if available.
Returns Err(Error::NotSupported) if unsupported in underlying driver.
Sourcefn set_bandwidth(
&self,
direction: Direction,
channel: usize,
bw: f64,
) -> Result<(), Error>
fn set_bandwidth( &self, direction: Direction, channel: usize, bw: f64, ) -> Result<(), Error>
Set the hardware bandwidth filter, if available.
Returns Err(Error::NotSupported) if unsupported in underlying driver.
Sourcefn get_bandwidth_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>
fn get_bandwidth_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>
Get the range of possible bandwidth filter values, if available.
Returns Err(Error::NotSupported) if unsupported in underlying driver.
Sourcefn has_dc_offset_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
fn has_dc_offset_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Returns true if automatic corrections are supported