SDR Package (ria_toolkit_oss.sdr)

This package provides a unified API for working with a variety of software-defined radios. It streamlines tasks involving signal reception and transmission, as well as common administrative operations such as detecting and configuring available devices.

class ria_toolkit_oss.sdr.SDR[source]

Bases: ABC

This class defines a common interface (a template) for all SDR devices. Each specific SDR implementation should subclass SDR and provide concrete implementations for the abstract methods.

To add support for a new radio, subclass this interface and implement all abstract methods. If you experience difficulties, please contact us, we are happy to provide additional direction and/or help with the implementation details.

record(num_samples=None, rx_time=None)[source]

Create a radio recording of a given length. Either num_samples or rx_time must be provided.

Note that init_rx() must be called before record().

Parameters:
  • num_samples (int, optional) – The number of samples to record.

  • rx_time (int or float, optional) – The time to record.

Returns:

The Recording object

Return type:

Recording

stream_to_zmq(zmq_address, n_samples, buffer_size=10000)[source]

Stream iq samples as interleaved bytes via zmq.

Parameters:
  • zmq_address – The zmq address.

  • n_samples (int) – The number of samples to stream.

  • buffer_size (int, optional) – The buffer size during streaming. Defaults to 10000.

Returns:

The trimmed Recording.

Return type:

Recording

pickle_buffer_to_zmq(zmq_address, buffer_size, num_buffers)[source]

Stream samples to a zmq address, packaged in binary buffers using numpy.pickle. Useful for inference applications with a known input size. May reduce transfer rates, but individual buffers will not have discontinuities.

Parameters:
  • zmq_address (str) – The tcp address to stream to.

  • buffer_size (int) – The number of iq samples in a buffer.

  • num_buffers (int) – The number of buffers to stream before stopping.

tx_recording(recording, num_samples=None, tx_time=None)[source]

Transmit the given iq samples from the provided recording. init_tx() must be called before this function.

Parameters:
  • recording (Recording or ndarray) – The recording to transmit.

  • num_samples (int, optional) – The number of samples to transmit, will repeat or truncate the recording to this length. Defaults to None.

  • tx_time (int or float, optional) – The time to transmit, will repeat or truncate the recording to this length. Defaults to None.

pause_rx()[source]
pause_tx()[source]
stop()[source]
abstract close()[source]
abstract init_rx(sample_rate, center_frequency, gain, channel, gain_mode)[source]
abstract init_tx(sample_rate, center_frequency, gain, channel, gain_mode)[source]
abstract set_clock_source(source)[source]

Sets the clock source to external or internal.

Parameters:

source (str) – The clock source

Radio Classes

class ria_toolkit_oss.sdr.usrp.USRP(identifier=None)[source]
init_rx(sample_rate, center_frequency, channel, gain, gain_mode='absolute', rx_buffer_size=960000)[source]

Initialize the USRP for receiving.

Parameters:
  • sample_rate (int or float) – The sample rate for receiving.

  • center_frequency (int or float) – The center frequency of the recording.

  • channel (int) – The channel the USRP is set to.

  • gain (int) – The gain set for receiving on the USRP.

  • gain_mode (str) – Gain mode setting. "absolute" passes gain directly to the SDR. "relative" means gain should be a negative value, which will be subtracted from the maximum gain.

  • rx_buffer_size (int) – Internal buffer size for receiving samples. Defaults to 960000.

Returns:

Dictionary with the actual RX parameters after configuration.

Return type:

dict

get_rx_sample_rate()[source]

Retrieve the current sample rate of the receiver.

Returns:

float: The receiver’s sample rate in samples per second (Hz).

get_rx_center_frequency()[source]

Retrieve the current center frequency of the receiver.

Returns:

float: The receiver’s center frequency in Hertz (Hz).

get_rx_gain()[source]

Retrieve the current gain setting of the receiver.

Returns:

float: The receiver’s gain in decibels (dB).

record(num_samples)[source]

Create a radio recording of a given length. Either num_samples or rx_time must be provided.

Note that init_rx() must be called before record().

Parameters:
  • num_samples (int, optional) – The number of samples to record.

  • rx_time (int or float, optional) – The time to record.

Returns:

The Recording object

Return type:

Recording

init_tx(sample_rate, center_frequency, gain, channel, gain_mode='absolute')[source]

Initialize the USRP for transmitting.

Parameters:
  • sample_rate (int or float) – The sample rate for transmitting.

  • center_frequency (int or float) – The center frequency of the recording.

  • gain (int) – The gain set for transmitting on the USRP.

  • channel (int) – The channel the USRP is set to.

  • gain_mode (str) – Gain mode setting. "absolute" passes gain directly to the SDR. "relative" means gain should be a negative value, which will be subtracted from the maximum gain.

tx_recording(recording, num_samples=None, tx_time=None)[source]

Transmit the given iq samples from the provided recording. init_tx() must be called before this function.

Parameters:
  • recording (Recording or ndarray) – The recording to transmit.

  • num_samples (int, optional) – The number of samples to transmit, will repeat or truncate the recording to this length. Defaults to None.

  • tx_time (int or float, optional) – The time to transmit, will repeat or truncate the recording to this length. Defaults to None.

set_clock_source(source)[source]

Sets the clock source to external or internal.

Parameters:

source (str) – The clock source

class ria_toolkit_oss.sdr.blade.Blade(identifier='')[source]
init_rx(sample_rate, center_frequency, gain, channel, buffer_size=8192, gain_mode='absolute')[source]

Initializes the BladeRF for receiving.

Parameters:
  • sample_rate (int or float) – The sample rate for receiving.

  • center_frequency (int or float) – The center frequency of the recording.

  • gain (int) – The gain set for receiving on the BladeRF

  • channel (int) – The channel the BladeRF is set to.

  • buffer_size (int) – The buffer size during receive. Defaults to 8192.

init_tx(sample_rate, center_frequency, gain, channel, buffer_size=8192, gain_mode='absolute')[source]

Initializes the BladeRF for transmitting.

Parameters:
  • sample_rate (int or float) – The sample rate for transmitting.

  • center_frequency (int or float) – The center frequency of the recording.

  • gain (int) – The gain set for transmitting on the BladeRF

  • channel (int) – The channel the BladeRF is set to.

  • buffer_size (int) – The buffer size during transmission. Defaults to 8192.

record(num_samples)[source]

Create a radio recording of a given length. Either num_samples or rx_time must be provided.

Note that init_rx() must be called before record().

Parameters:
  • num_samples (int, optional) – The number of samples to record.

  • rx_time (int or float, optional) – The time to record.

Returns:

The Recording object

Return type:

Recording

set_clock_source(source)[source]

Sets the clock source to external or internal.

Parameters:

source (str) – The clock source

class ria_toolkit_oss.sdr.pluto.Pluto(identifier=None)[source]
init_rx(sample_rate, center_frequency, gain, channel, gain_mode='absolute')[source]

Initializes the Pluto for receiving.

Parameters:
  • sample_rate (int or float) – The sample rate for receiving.

  • center_frequency (int or float) – The center frequency of the recording.

  • gain (int) – The gain set for receiving on the Pluto

  • channel (int) – The channel the Pluto is set to. Must be 0 or 1. 0 enables channel 1, 1 enables both channels.

  • buffer_size (int) – The buffer size during receive. Defaults to 10000.

init_tx(sample_rate, center_frequency, gain, channel, gain_mode='absolute')[source]

Initializes the Pluto for transmitting. Will transmit garbage during center frequency tuning and setting the sample rate.

Parameters:
  • sample_rate (int or float) – The sample rate for transmitting.

  • center_frequency (int or float) – The center frequency of the recording.

  • gain (int) – The gain set for transmitting on the Pluto

  • channel (int) – The channel the Pluto is set to. Must be 0 or 1. 0 enables channel 1, 1 enables both channels.

  • buffer_size (int) – The buffer size during transmit. Defaults to 10000.

record(num_samples=None, rx_time=None)[source]

Create a radio recording (iq samples and metadata) of a given length from the SDR. Either num_samples or rx_time must be provided. init_rx() must be called before record()

Parameters:
  • num_samples (int, optional) – The number of samples to record. Pluto max = 16M.

  • rx_time (int or float, optional) – The time to record.

returns: Recording object (iq samples and metadata)

tx_recording(recording, num_samples=None, tx_time=None, mode='timed')[source]

Transmit the given iq samples from the provided recording. init_tx() must be called before this function.

Parameters:
  • recording (Recording, ndarray, list[Recording, ndarray]) – The recording(s) to transmit.

  • num_samples (int, optional) – The number of samples to transmit, will repeat or truncate the recording to this length. Defaults to None.

  • tx_time (int or float, optional) – The time to transmit, will repeat or truncate the recording to this length. Defaults to None.

  • mode (str, optional) – The mode of transmission, either timed or continuous. Defaults to timed.

set_clock_source(source)[source]

Sets the clock source to external or internal.

Parameters:

source (str) – The clock source