Struct soapysdr::Device

source ·
pub struct Device { /* private fields */ }
Expand description

An opened SDR hardware device.

Implementations§

source§

impl Device

source

pub fn new<A: Into<Args>>(args: A) -> Result<Device, Error>

Find and open a device matching a set of filters.

§Example
let mut d = soapysdr::Device::new("type=null").unwrap();
source

pub fn driver_key(&self) -> Result<String, Error>

A key that uniquely identifies the device driver.

This key identifies the underlying implementation. Several variants of a product may share a driver.

source

pub fn hardware_key(&self) -> Result<String, Error>

A key that uniquely identifies the hardware.

This key should be meaningful to the user to optimize for the underlying hardware.

source

pub fn hardware_info(&self) -> Result<Args, Error>

Query a dictionary of available device information.

This dictionary can any number of values like vendor name, product name, revisions, serials…

This information can be displayed to the user to help identify the instantiated device.

source

pub fn frontend_mapping(&self, direction: Direction) -> Result<String, Error>

Get the mapping configuration string.

source

pub fn set_frontend_mapping<S: Into<Vec<u8>>>( &self, direction: Direction, mapping: S, ) -> Result<(), Error>

Set the frontend mapping of available DSP units to RF frontends.

This controls channel mapping and channel availability.

source

pub fn num_channels(&self, direction: Direction) -> Result<usize, Error>

Get a number of channels given the streaming direction

source

pub fn channel_info( &self, direction: Direction, channel: usize, ) -> Result<Args, Error>

Get channel info given the streaming direction

source

pub fn full_duplex( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Find out if the specified channel is full or half duplex.

Returns true for full duplex, false for half duplex.

source

pub fn stream_formats( &self, direction: Direction, channel: usize, ) -> Result<Vec<Format>, Error>

Query a list of the available stream formats.

source

pub fn native_stream_format( &self, direction: Direction, channel: usize, ) -> Result<(Format, f64), Error>

Get the hardware’s native stream format and full-scale value for this channel.

This is the format used by the underlying transport layer, and the direct buffer access API calls (when available).

source

pub fn stream_args_info( &self, direction: Direction, channel: usize, ) -> Result<Vec<ArgInfo>, Error>

Query the argument info description for stream args.

source

pub fn rx_stream<E: StreamSample>( &self, channels: &[usize], ) -> Result<RxStream<E>, Error>

Initialize an RX stream given a list of channels

source

pub fn rx_stream_args<E: StreamSample, A: Into<Args>>( &self, channels: &[usize], args: A, ) -> Result<RxStream<E>, Error>

Initialize an RX stream given a list of channels and stream arguments.

source

pub fn tx_stream<E: StreamSample>( &self, channels: &[usize], ) -> Result<TxStream<E>, Error>

Initialize a TX stream given a list of channels and stream arguments.

source

pub fn tx_stream_args<E: StreamSample, A: Into<Args>>( &self, channels: &[usize], args: A, ) -> Result<TxStream<E>, Error>

Initialize a TX stream given a list of channels and stream arguments.

source

pub fn antennas( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>

Get a list of available antennas to select on a given chain.

source

pub fn set_antenna<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<(), Error>

Set the selected antenna on a chain.

source

pub fn antenna( &self, direction: Direction, channel: usize, ) -> Result<String, Error>

Get the selected antenna on a chain.

source

pub fn has_dc_offset_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Does the device support automatic DC offset corrections?

Returns true if automatic corrections are supported

source

pub fn set_dc_offset_mode( &self, direction: Direction, channel: usize, automatic: bool, ) -> Result<(), Error>

Enable or disable automatic DC offset corrections mode.

source

pub fn dc_offset_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Returns true if automatic DC offset mode is enabled

source

pub fn has_dc_offset( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Does the device support frontend DC offset corrections?

Returns true if manual corrections are supported

source

pub fn set_dc_offset( &self, direction: Direction, channel: usize, offset_i: f64, offset_q: f64, ) -> Result<(), Error>

Set the frontend DC offset correction.

The offsets are configured for each of the I and Q components (1.0 max)

source

pub fn dc_offset( &self, direction: Direction, channel: usize, ) -> Result<(f64, f64), Error>

Get the frontend DC offset correction for (I, Q), 1.0 max

source

pub fn has_iq_balance( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Does the device support frontend IQ balance correction?

Returns true if IQ balance corrections are supported.

source

pub fn set_iq_balance( &self, direction: Direction, channel: usize, balance_i: f64, balance_q: f64, ) -> Result<(), Error>

Set the frontend IQ balance correction

The correction is configured for each of the I and Q components (1.0 max)

source

pub fn iq_balance( &self, direction: Direction, channel: usize, ) -> Result<(f64, f64), Error>

Get the frontend IQ balance correction for (I, Q), 1.0 max

source

pub fn list_gains( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>

List available amplification elements.

Elements should be in order RF to baseband.

source

pub fn has_gain_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Does the device support automatic gain control?

source

pub fn set_gain_mode( &self, direction: Direction, channel: usize, automatic: bool, ) -> Result<(), Error>

Enable or disable automatic gain control.

source

pub fn gain_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>

Returns true if automatic gain control is enabled

source

pub 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

source

pub fn gain(&self, direction: Direction, channel: usize) -> Result<f64, Error>

Get the overall value of the gain elements in a chain in dB.

source

pub fn gain_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>

Get the overall range of possible gain values.

source

pub fn set_gain_element<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, gain: f64, ) -> Result<(), Error>

Set the value of a amplification element in a chain.

§Arguments
  • name: the name of an amplification element from Device::list_gains
  • gain: the new amplification value in dB
source

pub fn gain_element<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<f64, Error>

Get the value of an individual amplification element in a chain in dB.

source

pub fn gain_element_range<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<Range, Error>

Get the range of possible gain values for a specific element.

source

pub fn frequency_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>

Get the ranges of overall frequency values.

source

pub 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.

source

pub fn set_frequency<A: Into<Args>>( &self, direction: Direction, channel: usize, frequency: f64, args: A, ) -> 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.
source

pub fn list_frequencies( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>

List available tunable elements in the chain.

Elements should be in order RF to baseband.

source

pub fn component_frequency_range<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<Vec<Range>, Error>

Get the range of tunable values for the specified element.

source

pub fn component_frequency<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<f64, Error>

Get the frequency of a tunable element in the chain.

source

pub fn set_component_frequency<S: Into<Vec<u8>>, A: Into<Args>>( &self, direction: Direction, channel: usize, name: S, frequency: f64, args: A, ) -> 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.

Recommended names used to represent tunable components:

  • “CORR” - freq error correction in PPM
  • “RF” - frequency of the RF frontend
  • “BB” - frequency of the baseband DSP
source

pub fn frequency_args_info( &self, direction: Direction, channel: usize, ) -> Result<Vec<ArgInfo>, Error>

Query the argument info description for tune args.

source

pub fn sample_rate( &self, direction: Direction, channel: usize, ) -> Result<f64, Error>

Get the baseband sample rate of the chain in samples per second.

source

pub 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.

source

pub fn get_sample_rate_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>

Get the range of possible baseband sample rates.

source

pub fn bandwidth( &self, direction: Direction, channel: usize, ) -> Result<f64, Error>

Get the baseband filter width of the chain in Hz

source

pub fn set_bandwidth( &self, direction: Direction, channel: usize, bandwidth: f64, ) -> Result<(), Error>

Set the baseband filter width of the chain in Hz

source

pub fn bandwidth_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>

Get the ranges of possible baseband filter widths.

source

pub fn list_time_sources(&self) -> Result<Vec<String>, Error>

List time sources

source

pub fn get_time_source(&self) -> Result<String, Error>

Get the current time source

source

pub fn set_time_source<S: Into<Vec<u8>>>( &self, time_source: S, ) -> Result<(), Error>

Set the current time source

source

pub fn has_hardware_time( &self, hw_time_source: Option<&str>, ) -> Result<bool, Error>

Check whether there is a given hardware time source. Hardware time sources are not the same as time sources (at least for UHD Devices) UHD supported hw time sources: “PPS” or “” (i.e. None)

source

pub fn get_hardware_time( &self, hw_time_source: Option<&str>, ) -> Result<i64, Error>

Get the current timestamp in ns

source

pub fn set_hardware_time( &self, hw_time_source: Option<&str>, new_time_ns: i64, ) -> Result<(), Error>

Set the current hardware timestmap for the given source UHD supported hardware times: “CMD”,“PPS”,“UNKNOWN_PPS”

source

pub fn list_clock_sources(&self) -> Result<Vec<String>, Error>

List clock sources

source

pub fn get_clock_source(&self) -> Result<String, Error>

Get the current clock source

source

pub fn set_clock_source<S: Into<Vec<u8>>>( &self, clock_source: S, ) -> Result<(), Error>

Set the current clock source

source

pub fn write_setting<S: Into<Vec<u8>>>( &self, key: S, value: S, ) -> Result<(), Error>

Write a setting

source

pub fn read_setting<S: Into<Vec<u8>>>(&self, key: S) -> Result<String, Error>

Read a setting

Trait Implementations§

source§

impl Clone for Device

source§

fn clone(&self) -> Device

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.