File usrp.hpp

class USRP
#include <usrp.hpp>

Contains an abstract wrapper for the USRP object.

Public Functions

explicit USRP(const DriverOptions &driver_options, float tx_rate, float rx_rate)

Creates the multiUSRP abstraction with the options from the config file.

Parameters
  • driver_options[in] The driver options parsed from config

  • tx_rate[in] The transmit rate in Sps (samples per second, Hz).

  • rx_rate[in] The receive rate in Sps (samples per second, Hz).

void set_usrp_clock_source(std::string source)

Sets the USRP clock source.

Parameters

source[in] A string for a valid USRP clock source.

void set_tx_subdev(std::string tx_subdev)

Sets the USRP transmit subdev specification.

Parameters

tx_subdev[in] A string for a valid transmit subdev.

double set_tx_rate(std::vector<size_t> chs)

Sets the transmit sample rate.

Parameters

chs[in] A vector of USRP channels to tx on.

Returns

Actual set tx rate.

double get_tx_rate(uint32_t channel = 0)

Gets the USRP transmit sample rate.

Returns

The transmit sample rate in Sps.

double set_tx_center_freq(double freq, std::vector<size_t> chs, uhd::time_spec_t tune_delay)

Sets the transmit center frequency.

The USRP uses a numbered channel mapping system to identify which data streams come from which USRP and its daughterboard frontends. With the daughtboard frontends connected to the transmitters, controlling what USRP channels are selected will control what antennas are used and what order they are in. To synchronize tuning of all boxes, timed commands are used so that everything is done at once.

Parameters
  • freq[in] The frequency in Hz.

  • chs[in] A vector of which USRP channels to set a center frequency.

  • tune_delay[in] The amount of time in future to tune the devices.

Returns

The actual set tx center frequency for the USRPs

double get_tx_center_freq(uint32_t channel = 0)

Gets the transmit center frequency.

Returns

The actual center frequency that the USRPs are tuned to.

void set_main_rx_subdev(std::string main_subdev)

Sets the receive subdev for the main array antennas.

Will set all boxes to receive from first USRP channel of all mboards for main array.

Parameters

main_subdev[in] A string for a valid receive subdev.

void set_interferometer_rx_subdev(std::string interferometer_subdev, uint32_t interferometer_antenna_count)

Sets the interferometer receive subdev.

Override the subdev spec of the first mboards to receive on a second channel for the interferometer.

Parameters
  • interferometer_subdev[in] A string for a valid receive subdev.

  • interferometer_antenna_count[in] The interferometer antenna count.

double set_rx_rate(std::vector<size_t> rx_chs)

Sets the receive sample rate.

Parameters

rx_chs[in] The USRP channels to rx on.

Returns

The actual rate set.

double get_rx_rate(uint32_t channel = 0)

Gets the USRP transmit sample rate.

Returns

The transmit sample rate in Sps.

double set_rx_center_freq(double freq, std::vector<size_t> chs, uhd::time_spec_t tune_delay)

Sets the receive center frequency.

The USRP uses a numbered channel mapping system to identify which data streams come from which USRP and its daughterboard frontends. With the daughtboard frontends connected to the transmitters, controlling what USRP channels are selected will control what antennas are used and what order they are in. To simplify data processing, all antenna mapped channels are used. To synchronize tuning of all boxes, timed commands are used so that everything is done at once.

Parameters
  • freq[in] The frequency in Hz.

  • chs[in] A vector of which USRP channels to set a center frequency.

  • tune_delay[in] The amount of time in future to tune the devices.

Returns

The actual center frequency that the USRPs are tuned to.

double get_rx_center_freq(uint32_t channel = 0)

Gets the receive center frequency.

Returns

The actual center frequency that the USRPs are tuned to.

void set_time_source(std::string source, std::string clk_addr)

Sets the USRP time source.

Uses the method Ettus suggests for setting time on the x300. https://files.ettus.com/manual/page_gpsdo_x3x0.html Falls back to Juha Vierinen’s method of latching to the current time by making sure the clock time is in a stable place past the second if no gps is available. The USRP is then set to this time.

Parameters
  • source[in] A string with the time source the USRP will use.

  • clk_addr[in] IP address of the octoclock for gps timing.

void check_ref_locked()

Makes a quick check that each USRP is locked to a reference frequency.

void create_usrp_rx_stream(std::string cpu_fmt, std::string otw_fmt, std::vector<size_t> chs)

Creates an USRP receive stream.

Parameters
  • cpu_fmt[in] The cpu format for the tx stream. Described in UHD docs.

  • otw_fmt[in] The otw format for the tx stream. Described in UHD docs.

  • chs[in] A vector of which USRP channels to receive on.

void create_usrp_tx_stream(std::string cpu_fmt, std::string otw_fmt, std::vector<size_t> chs)

Creates an USRP transmit stream.

Parameters
  • cpu_fmt[in] The cpu format for the tx stream. Described in UHD docs.

  • otw_fmt[in] The otw format for the tx stream. Described in UHD docs.

  • chs[in] A vector of which USRP channels to transmit on.

void set_command_time(uhd::time_spec_t cmd_time)

Sets the command time.

Parameters

cmd_time[in] The command time to run a timed command.

void clear_command_time()

Clears any timed USRP commands.

std::vector<uint32_t> get_gpio_bank_high_state()

Gets the state of the GPIO bank represented as a decimal number.

std::vector<uint32_t> get_gpio_bank_low_state()

Gets the state of the GPIO bank represented as a decimal number.

uhd::time_spec_t get_current_usrp_time()

Gets the current USRP time.

Returns

The current USRP time.

uhd::rx_streamer::sptr get_usrp_rx_stream()

Gets a pointer to the USRP rx stream.

Returns

The USRP rx stream.

uhd::tx_streamer::sptr get_usrp_tx_stream()

Gets a pointer to the USRP tx stream.

Returns

The USRP tx stream.

uhd::usrp::multi_usrp::sptr get_usrp()

Gets the usrp.

Returns

The multi-USRP shared pointer.

std::string to_string(std::vector<size_t> tx_chs, std::vector<size_t> rx_chs)

Returns a string representation of the USRP parameters.

Parameters
  • tx_chs[in] USRP TX channels for which to generate info for.

  • rx_chs[in] USRP RX channels for which to generate info for.

Returns

String representation of the USRP parameters.

void invert_test_mode(uint32_t mboard = 0)

Inverts the current test mode signal. Useful for testing.

Parameters

mboard[in] The USRP to invert test mode on. Default 0.

void set_test_mode(uint32_t mboard = 0)

Sets the current test mode signal HIGH.

Parameters

mboard[in] The USRP to set test mode HIGH on. Default 0.

void clear_test_mode(uint32_t mboard = 0)

Clears the current test mode signal LOW.

Parameters

mboard[in] The USRP to clear test mode LOW on. Default 0.

Private Functions

void set_atr_gpios()

Sets the USRP automatic transmit/receive states on GPIO for the given daughtercard bank.

void set_output_gpios()

Sets the pins mapping the test mode signals as GPIO outputs.

void set_input_gpios()

Sets the pins mapping the AGC and low power signals as GPIO inputs.

Private Members

uhd::usrp::multi_usrp::sptr usrp_

A shared pointer to a new multi-USRP device.

std::string gpio_bank_high_

A string representing what GPIO bank to use on the USRPs for active high sigs.

std::string gpio_bank_low_

A string representing what GPIO bank to use on the USRPs for active low sigs.

uint32_t scope_sync_mask_

The bitmask to use for the scope sync GPIO.

uint32_t atten_mask_

The bitmask to use for the attenuator GPIO.

uint32_t tr_mask_

The bitmask to use for the TR GPIO.

uint32_t atr_xx_

Bitmask used for full duplex ATR.

uint32_t atr_rx_

Bitmask used for rx only ATR.

uint32_t atr_tx_

Bitmask used for tx only ATR.

uint32_t atr_0x_

Bitmask used for idle ATR.

uint32_t agc_st_

Bitmask used for AGC signal.

uint32_t lo_pwr_

Bitmask used for lo pwr signal.

uint32_t test_mode_

Bitmask used for test mode signal.

float tx_rate_

The tx rate in Hz.

float rx_rate_

The rx rate in Hz.

uhd::tx_streamer::sptr tx_stream_
uhd::rx_streamer::sptr rx_stream_
class TXMetadata
#include <usrp.hpp>

Wrapper for the USRP TX metadata object.

Used to hold and initialize a new tx_metadata_t object. Creates getters and setters to access properties.

Public Functions

TXMetadata()

Constructs a blank USRP TX metadata object.

uhd::tx_metadata_t get_md()

Gets the TX metadata oject that can be sent the USRPs.

Returns

The USRP TX metadata.

void set_start_of_burst(bool start_of_burst)

Sets whether this data is the start of a burst.

Parameters

start_of_burst[in] The start of burst boolean.

void set_end_of_burst(bool end_of_burst)

Sets whether this data is the end of the burst.

Parameters

end_of_burst[in] The end of burst boolean.

void set_has_time_spec(bool has_time_spec)

Sets whether this data will have a particular timing.

Parameters

has_time_spec[in] Indicates if this metadata will have a time specifier.

void set_time_spec(uhd::time_spec_t time_spec)

Sets the timing in the future for this metadata.

Parameters

time_spec[in] The time specifier for this metadata.

Private Members

uhd::tx_metadata_t md_

A raw USRP TX metadata object.

class RXMetadata
#include <usrp.hpp>

Wrapper for the USRP RX metadata object.

Used to hold and initialize a new tx_metadata_t object. Creates getters and setters to access properties.

Public Functions

RXMetadata() = default
uhd::rx_metadata_t &get_md()

Gets the RX metadata object that will be retrieved on receiving.

Returns

The USRP RX metadata object.

bool get_end_of_burst()

Gets the end of burst.

Returns

The end of burst.

uhd::rx_metadata_t::error_code_t get_error_code()

Gets the error code from the metadata on receive.

Returns

The error code.

size_t get_fragment_offset()

Gets the fragment offset. The fragment offset is the sample number at start of buffer.

Returns

The fragment offset.

bool get_has_time_spec()

Gets the has time specifier status.

Returns

The has time specifier boolean.

bool get_out_of_sequence()

Gets out of sequence status. Queries whether a packet is dropped or out of order.

Returns

The out of sequence boolean.

bool get_start_of_burst()

Gets the start of burst status.

Returns

The start of burst.

uhd::time_spec_t get_time_spec()

Gets the time specifier of the packet.

Returns

The time specifier.

Private Members

uhd::rx_metadata_t md_

A raw USRP RX metadata object.