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:
ABCThis 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_samplesorrx_timemust be provided.Note that
init_rx()must be called beforerecord().
- stream_to_zmq(zmq_address, n_samples, buffer_size=10000)[source]
Stream iq samples as interleaved bytes via zmq.
- 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.
- 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.
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:
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:
- 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_samplesorrx_timemust be provided.Note that
init_rx()must be called beforerecord().
- 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.
- 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.
- 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.
- 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:
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:
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.