pub struct Device { /* private fields */ }
Expand description
An opened SDR hardware device.
Implementations§
source§impl Device
impl Device
sourcepub fn new<A: Into<Args>>(args: A) -> Result<Device, Error>
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();
sourcepub fn driver_key(&self) -> Result<String, Error>
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.
sourcepub fn hardware_key(&self) -> Result<String, Error>
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.
sourcepub fn hardware_info(&self) -> Result<Args, Error>
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.
sourcepub fn frontend_mapping(&self, direction: Direction) -> Result<String, Error>
pub fn frontend_mapping(&self, direction: Direction) -> Result<String, Error>
Get the mapping configuration string.
sourcepub fn set_frontend_mapping<S: Into<Vec<u8>>>(
&self,
direction: Direction,
mapping: S,
) -> Result<(), Error>
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.
sourcepub fn num_channels(&self, direction: Direction) -> Result<usize, Error>
pub fn num_channels(&self, direction: Direction) -> Result<usize, Error>
Get a number of channels given the streaming direction
sourcepub fn channel_info(
&self,
direction: Direction,
channel: usize,
) -> Result<Args, Error>
pub fn channel_info( &self, direction: Direction, channel: usize, ) -> Result<Args, Error>
Get channel info given the streaming direction
sourcepub fn full_duplex(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
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.
sourcepub fn stream_formats(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<Format>, Error>
pub fn stream_formats( &self, direction: Direction, channel: usize, ) -> Result<Vec<Format>, Error>
Query a list of the available stream formats.
sourcepub fn native_stream_format(
&self,
direction: Direction,
channel: usize,
) -> Result<(Format, f64), Error>
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).
sourcepub fn stream_args_info(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<ArgInfo>, Error>
pub fn stream_args_info( &self, direction: Direction, channel: usize, ) -> Result<Vec<ArgInfo>, Error>
Query the argument info description for stream args.
sourcepub fn rx_stream<E: StreamSample>(
&self,
channels: &[usize],
) -> Result<RxStream<E>, Error>
pub fn rx_stream<E: StreamSample>( &self, channels: &[usize], ) -> Result<RxStream<E>, Error>
Initialize an RX stream given a list of channels
sourcepub fn rx_stream_args<E: StreamSample, A: Into<Args>>(
&self,
channels: &[usize],
args: A,
) -> Result<RxStream<E>, Error>
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.
sourcepub fn tx_stream<E: StreamSample>(
&self,
channels: &[usize],
) -> Result<TxStream<E>, Error>
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.
sourcepub fn tx_stream_args<E: StreamSample, A: Into<Args>>(
&self,
channels: &[usize],
args: A,
) -> Result<TxStream<E>, Error>
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.
sourcepub fn antennas(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
pub fn antennas( &self, direction: Direction, channel: usize, ) -> Result<Vec<String>, Error>
Get a list of available antennas to select on a given chain.
sourcepub fn set_antenna<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
) -> Result<(), Error>
pub fn set_antenna<S: Into<Vec<u8>>>( &self, direction: Direction, channel: usize, name: S, ) -> Result<(), Error>
Set the selected antenna on a chain.
sourcepub fn antenna(
&self,
direction: Direction,
channel: usize,
) -> Result<String, Error>
pub fn antenna( &self, direction: Direction, channel: usize, ) -> Result<String, Error>
Get the selected antenna on a chain.
sourcepub fn has_dc_offset_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
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
sourcepub fn set_dc_offset_mode(
&self,
direction: Direction,
channel: usize,
automatic: bool,
) -> Result<(), Error>
pub fn set_dc_offset_mode( &self, direction: Direction, channel: usize, automatic: bool, ) -> Result<(), Error>
Enable or disable automatic DC offset corrections mode.
sourcepub fn dc_offset_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
pub fn dc_offset_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Returns true if automatic DC offset mode is enabled
sourcepub fn has_dc_offset(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
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
sourcepub fn set_dc_offset(
&self,
direction: Direction,
channel: usize,
offset_i: f64,
offset_q: f64,
) -> Result<(), Error>
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)
sourcepub fn dc_offset(
&self,
direction: Direction,
channel: usize,
) -> Result<(f64, f64), Error>
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
sourcepub fn has_iq_balance(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
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.
sourcepub fn set_iq_balance(
&self,
direction: Direction,
channel: usize,
balance_i: f64,
balance_q: f64,
) -> Result<(), Error>
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)
sourcepub fn iq_balance(
&self,
direction: Direction,
channel: usize,
) -> Result<(f64, f64), Error>
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
sourcepub fn list_gains(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
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.
sourcepub fn has_gain_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
pub fn has_gain_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Does the device support automatic gain control?
sourcepub fn set_gain_mode(
&self,
direction: Direction,
channel: usize,
automatic: bool,
) -> Result<(), Error>
pub fn set_gain_mode( &self, direction: Direction, channel: usize, automatic: bool, ) -> Result<(), Error>
Enable or disable automatic gain control.
sourcepub fn gain_mode(
&self,
direction: Direction,
channel: usize,
) -> Result<bool, Error>
pub fn gain_mode( &self, direction: Direction, channel: usize, ) -> Result<bool, Error>
Returns true if automatic gain control is enabled
sourcepub fn set_gain(
&self,
direction: Direction,
channel: usize,
gain: f64,
) -> Result<(), Error>
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
sourcepub fn gain(&self, direction: Direction, channel: usize) -> Result<f64, Error>
pub fn gain(&self, direction: Direction, channel: usize) -> Result<f64, Error>
Get the overall value of the gain elements in a chain in dB.
sourcepub fn gain_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Range, Error>
pub fn gain_range( &self, direction: Direction, channel: usize, ) -> Result<Range, Error>
Get the overall range of possible gain values.
sourcepub fn set_gain_element<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
gain: f64,
) -> Result<(), Error>
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 fromDevice::list_gains
gain
: the new amplification value in dB
sourcepub fn gain_element<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
) -> Result<f64, Error>
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.
sourcepub fn gain_element_range<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
) -> Result<Range, Error>
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.
sourcepub fn frequency_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<Range>, Error>
pub fn frequency_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>
Get the ranges of overall frequency values.
sourcepub fn frequency(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>
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.
sourcepub fn set_frequency<A: Into<Args>>(
&self,
direction: Direction,
channel: usize,
frequency: f64,
args: A,
) -> Result<(), Error>
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.
sourcepub fn list_frequencies(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<String>, Error>
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.
sourcepub fn component_frequency_range<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
) -> Result<Vec<Range>, Error>
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.
sourcepub fn component_frequency<S: Into<Vec<u8>>>(
&self,
direction: Direction,
channel: usize,
name: S,
) -> Result<f64, Error>
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.
sourcepub fn set_component_frequency<S: Into<Vec<u8>>, A: Into<Args>>(
&self,
direction: Direction,
channel: usize,
name: S,
frequency: f64,
args: A,
) -> Result<(), Error>
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
sourcepub fn frequency_args_info(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<ArgInfo>, Error>
pub fn frequency_args_info( &self, direction: Direction, channel: usize, ) -> Result<Vec<ArgInfo>, Error>
Query the argument info description for tune args.
sourcepub fn sample_rate(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>
pub fn sample_rate( &self, direction: Direction, channel: usize, ) -> Result<f64, Error>
Get the baseband sample rate of the chain in samples per second.
sourcepub fn set_sample_rate(
&self,
direction: Direction,
channel: usize,
rate: f64,
) -> Result<(), Error>
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.
sourcepub fn get_sample_rate_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<Range>, Error>
pub fn get_sample_rate_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>
Get the range of possible baseband sample rates.
sourcepub fn bandwidth(
&self,
direction: Direction,
channel: usize,
) -> Result<f64, Error>
pub fn bandwidth( &self, direction: Direction, channel: usize, ) -> Result<f64, Error>
Get the baseband filter width of the chain in Hz
sourcepub fn set_bandwidth(
&self,
direction: Direction,
channel: usize,
bandwidth: f64,
) -> Result<(), Error>
pub fn set_bandwidth( &self, direction: Direction, channel: usize, bandwidth: f64, ) -> Result<(), Error>
Set the baseband filter width of the chain in Hz
sourcepub fn bandwidth_range(
&self,
direction: Direction,
channel: usize,
) -> Result<Vec<Range>, Error>
pub fn bandwidth_range( &self, direction: Direction, channel: usize, ) -> Result<Vec<Range>, Error>
Get the ranges of possible baseband filter widths.
sourcepub fn get_time_source(&self) -> Result<String, Error>
pub fn get_time_source(&self) -> Result<String, Error>
Get the current time source
sourcepub fn set_time_source<S: Into<Vec<u8>>>(
&self,
time_source: S,
) -> Result<(), Error>
pub fn set_time_source<S: Into<Vec<u8>>>( &self, time_source: S, ) -> Result<(), Error>
Set the current time source
sourcepub fn has_hardware_time(
&self,
hw_time_source: Option<&str>,
) -> Result<bool, Error>
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)
sourcepub fn get_hardware_time(
&self,
hw_time_source: Option<&str>,
) -> Result<i64, Error>
pub fn get_hardware_time( &self, hw_time_source: Option<&str>, ) -> Result<i64, Error>
Get the current timestamp in ns
sourcepub fn set_hardware_time(
&self,
hw_time_source: Option<&str>,
new_time_ns: i64,
) -> Result<(), Error>
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”
sourcepub fn get_clock_source(&self) -> Result<String, Error>
pub fn get_clock_source(&self) -> Result<String, Error>
Get the current clock source
sourcepub fn set_clock_source<S: Into<Vec<u8>>>(
&self,
clock_source: S,
) -> Result<(), Error>
pub fn set_clock_source<S: Into<Vec<u8>>>( &self, clock_source: S, ) -> Result<(), Error>
Set the current clock source
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)