GNU Radio 3.3.0 C++ API
usrp2::usrp2 Class Reference

standard C++ interface to USRP2 More...

#include <usrp2.h>

List of all members.

Classes

class  impl

Public Types

typedef boost::shared_ptr< usrp2sptr

Public Member Functions

 ~usrp2 ()
std::string mac_addr ()
std::string interface_name ()
bool set_rx_antenna (int ant)
bool set_rx_gain (double gain)
double rx_gain_min ()
 return minimum Rx gain
double rx_gain_max ()
 return maximum Rx gain
double rx_gain_db_per_step ()
 return Rx gain db_per_step
bool set_rx_lo_offset (double frequency)
 Set receive daughterboard LO offset frequency.
bool set_rx_center_freq (double frequency, tune_result *result)
double rx_freq_min ()
 return minimum Rx center frequency
double rx_freq_max ()
 return maximum Rx center frequency
bool set_rx_decim (int decimation_factor)
int rx_decim ()
 Return current decimation factor.
bool set_rx_scale_iq (int scale_i, int scale_q)
bool start_rx_streaming (unsigned int channel=0, unsigned int items_per_frame=0)
bool start_rx_streaming_at (unsigned int channel=0, unsigned int items_per_frame=0, unsigned int time=0)
bool sync_and_start_rx_streaming_at (unsigned int channel=0, unsigned int items_per_frame=0, uint32_t time=0)
bool stop_rx_streaming (unsigned int channel=0)
bool rx_samples (unsigned int channel, rx_sample_handler *handler)
 Receive data from the specified channel This method is used to receive all data: streaming or discrete.
unsigned int rx_overruns ()
unsigned int rx_missing ()
bool set_tx_antenna (int ant)
bool set_tx_gain (double gain)
double tx_gain_min ()
 return minimum Tx gain
double tx_gain_max ()
 return maximum Tx gain
double tx_gain_db_per_step ()
 return Tx gain db_per_step
bool set_tx_lo_offset (double frequency)
bool set_tx_center_freq (double frequency, tune_result *result)
double tx_freq_min ()
 return minimum Tx center frequency
double tx_freq_max ()
 return maximum Tx center frequency
bool set_tx_interp (int interpolation_factor)
int tx_interp ()
 Return current interpolation factor.
void default_tx_scale_iq (int interpolation_factor, int *scale_i, int *scale_q)
bool set_tx_scale_iq (int scale_i, int scale_q)
bool tx_32fc (unsigned int channel, const std::complex< float > *samples, size_t nsamples, const tx_metadata *metadata)
 transmit complex<float> samples to USRP2
bool tx_16sc (unsigned int channel, const std::complex< int16_t > *samples, size_t nsamples, const tx_metadata *metadata)
 transmit complex<int16_t> samples to USRP2
bool tx_raw (unsigned int channel, const uint32_t *items, size_t nitems, const tx_metadata *metadata)
 transmit raw uint32_t data items to USRP2
bool config_mimo (int flags)
 MIMO configuration.
bool fpga_master_clock_freq (long *freq)
 Get frequency of master oscillator in Hz.
bool adc_rate (long *rate)
bool dac_rate (long *rate)
bool tx_daughterboard_id (int *dbid)
 Get Tx daughterboard ID.
bool rx_daughterboard_id (int *dbid)
 Get Rx daughterboard ID.
bool burn_mac_addr (const std::string &new_addr)
bool sync_to_pps ()
bool sync_every_pps (bool enable)
std::vector< uint32_tpeek32 (uint32_t addr, uint32_t words)
bool poke32 (uint32_t addr, const std::vector< uint32_t > &data)
bool set_gpio_ddr (int bank, uint16_t value, uint16_t mask)
bool set_gpio_sels (int bank, std::string sels)
bool write_gpio (int bank, uint16_t value, uint16_t mask)
bool read_gpio (int bank, uint16_t *value)
bool enable_gpio_streaming (int bank, int enable)

Static Public Member Functions

static sptr make (const std::string &ifc, const std::string &addr="", size_t rx_bufsize=0)

Static Public Attributes

static const unsigned int MAX_CHAN = 30

Detailed Description

standard C++ interface to USRP2


Member Typedef Documentation

Shared pointer to this class


Constructor & Destructor Documentation

usrp2::usrp2::~usrp2 ( )

Class destructor


Member Function Documentation

bool usrp2::usrp2::adc_rate ( long *  rate)
bool usrp2::usrp2::burn_mac_addr ( const std::string &  new_addr)

Burn new mac address into EEPROM on USRP2

Parameters:
new_addrNetwork mac address, e.g., "01:23:45:67:89:ab" or "89:ab". If addr is HH:HH, it's treated as if it were 00:50:c2:85:HH:HH
bool usrp2::usrp2::config_mimo ( int  flags)

MIMO configuration.

Parameters:
flagsfrom usrp2_mimo_config.h
   one of these:
     MC_WE_DONT_LOCK
     MC_WE_LOCK_TO_SMA
     MC_WE_LOCK_TO_MIMO
   and optionally this:
     MC_PROVIDE_CLK_TO_MIMO
 
bool usrp2::usrp2::dac_rate ( long *  rate)
void usrp2::usrp2::default_tx_scale_iq ( int  interpolation_factor,
int *  scale_i,
int *  scale_q 
)
bool usrp2::usrp2::enable_gpio_streaming ( int  bank,
int  enable 
)

Set GPIO streaming mode

Individually enables streaming GPIO pins through LSBs of DSP samples.

On receive, io_rx[15] replaces I[0], io_rx[14] replaces Q[0] On transmit, I[0] maps to io_tx[15], Q[0] maps to io_tx[14] (Transmit streaming is not yet implemented.)

The selected GPIO pins must have been set as inputs or outputs and, for transmit, set to software control.

When enabled, the replaced DSP sample LSBs become 0.

Parameters:
bankGPIO_TX_BANK or GPIO_RX_BANK
enableenable[0] controls I channel LSB enable[1] controls Q channel LSB
Returns:
true iff successful

WARNING: Improper usage of this function may result in damage to the USRP2

bool usrp2::usrp2::fpga_master_clock_freq ( long *  freq)

Get frequency of master oscillator in Hz.

std::string usrp2::usrp2::interface_name ( )

Returns the GbE interface name associated with this USRP

std::string usrp2::usrp2::mac_addr ( )

Returns the MAC address associated with this USRP

static sptr usrp2::usrp2::make ( const std::string &  ifc,
const std::string &  addr = "",
size_t  rx_bufsize = 0 
) [static]

Static function to return an instance of usrp2 as a shared pointer

Parameters:
ifcNetwork interface name, e.g., "eth0"
addrNetwork mac address, e.g., "01:23:45:67:89:ab", "89:ab" or "". If addr is HH:HH, it's treated as if it were 00:50:c2:85:HH:HH "" will autoselect a USRP2 if there is only a single one on the local ethernet.
rx_bufsizeis the length in bytes of the kernel networking buffer to allocate.
std::vector<uint32_t> usrp2::usrp2::peek32 ( uint32_t  addr,
uint32_t  words 
)

Read memory from Wishbone bus as 32-bit words. Handles endian swapping if needed.

Parameters:
addr32-bit aligned address. Only the lower 16-bits are significant.
wordsNumber of 32-bit words
Returns:
Vector of 32-bit read values

WARNING: Attempts to read memory from addresses that do not correspond to RAM or memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.

bool usrp2::usrp2::poke32 ( uint32_t  addr,
const std::vector< uint32_t > &  data 
)

Write memory to Wishbone bus as 32-bit words. Handles endian swapping if needed.

Parameters:
addr32-bit aligned address. Only the lower 16-bits are significant
dataVector of 32-bit values to write.
Returns:
true iff successful

WARNING: Attempts to read memory from addresses that do not correspond to RAM or memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.

bool usrp2::usrp2::read_gpio ( int  bank,
uint16_t value 
)

Read daughterboard GPIO pin values

Parameters:
bankGPIO_TX_BANK or GPIO_RX_BANK
valuepointer to uint16_t to hold read results
Returns:
true iff successful
bool usrp2::usrp2::rx_daughterboard_id ( int *  dbid)

Get Rx daughterboard ID.

Parameters:
[out]dbidreturns the daughterboard id.

daughterboard id >= 0 if successful, -1 if no daugherboard installed, -2 if invalid EEPROM on daughterboard.

int usrp2::usrp2::rx_decim ( )

Return current decimation factor.

double usrp2::usrp2::rx_freq_max ( )

return maximum Rx center frequency

double usrp2::usrp2::rx_freq_min ( )

return minimum Rx center frequency

double usrp2::usrp2::rx_gain_db_per_step ( )

return Rx gain db_per_step

double usrp2::usrp2::rx_gain_max ( )

return maximum Rx gain

double usrp2::usrp2::rx_gain_min ( )

return minimum Rx gain

unsigned int usrp2::usrp2::rx_missing ( )

Returns total number of missing frames from overruns.

unsigned int usrp2::usrp2::rx_overruns ( )

Returns number of times receive overruns have occurred

bool usrp2::usrp2::rx_samples ( unsigned int  channel,
rx_sample_handler handler 
)

Receive data from the specified channel This method is used to receive all data: streaming or discrete.

bool usrp2::usrp2::set_gpio_ddr ( int  bank,
uint16_t  value,
uint16_t  mask 
)

Set daughterboard GPIO data direction register.

Parameters:
bankGPIO_TX_BANK or GPIO_RX_BANK
value16-bits, 0=FPGA input, 1=FPGA output
mask16-bits, 0=ignore, 1=set
Returns:
true iff successful

WARNING: Improper usage of this function may result in damage to the USRP2

bool usrp2::usrp2::set_gpio_sels ( int  bank,
std::string  sels 
)

Set daughterboard GPIO output selection register. For those GPIO pins that are configured as outputs in the DDR, this settings configures the source of the pin value.

Parameters:
bankGPIO_TX_BANK or GPIO_RX_BANK
selsExactly 16 character MSB->LSB string. For each position: '.' = ignore this bit, i.e., leave current value 'a' = Output ATR value 's' = Output host software controlled value '0' = Output FPGA debug bus 0 value '1' = Output FPGA debug bus 1 value
Returns:
true iff successful

WARNING: Improper usage of this function may result in damage to the USRP2

bool usrp2::usrp2::set_rx_antenna ( int  ant)

Set the rx antenna

bool usrp2::usrp2::set_rx_center_freq ( double  frequency,
tune_result result 
)

Set receiver center frequency

bool usrp2::usrp2::set_rx_decim ( int  decimation_factor)

Set receiver sample rate decimation

bool usrp2::usrp2::set_rx_gain ( double  gain)

Set receiver gain

Parameters:
gainin dB (more or less)
bool usrp2::usrp2::set_rx_lo_offset ( double  frequency)

Set receive daughterboard LO offset frequency.

bool usrp2::usrp2::set_rx_scale_iq ( int  scale_i,
int  scale_q 
)

Set receiver IQ magnitude scaling

bool usrp2::usrp2::set_tx_antenna ( int  ant)

Set the tx antenna

bool usrp2::usrp2::set_tx_center_freq ( double  frequency,
tune_result result 
)

Set transmitter center frequency

bool usrp2::usrp2::set_tx_gain ( double  gain)

Set transmitter gain

bool usrp2::usrp2::set_tx_interp ( int  interpolation_factor)

Set transmitter sample rate interpolation

bool usrp2::usrp2::set_tx_lo_offset ( double  frequency)
bool usrp2::usrp2::set_tx_scale_iq ( int  scale_i,
int  scale_q 
)

Set transmit IQ magnitude scaling

bool usrp2::usrp2::start_rx_streaming ( unsigned int  channel = 0,
unsigned int  items_per_frame = 0 
)

Set received sample format

domain: complex or real type: floating, fixed point, or raw depth: bits per sample

Sets format over the wire for samples from USRP2.

Start streaming receive mode. USRP2 will send a continuous stream of DSP pipeline samples to host. Call rx_samples(...) to access.

Parameters:
channelStream channel number (0-30)
items_per_frameNumber of 32-bit items per frame.
bool usrp2::usrp2::start_rx_streaming_at ( unsigned int  channel = 0,
unsigned int  items_per_frame = 0,
unsigned int  time = 0 
)

Start streaming receive mode at specified timestamp. USRP2 will send a continuous stream of DSP pipeline samples to host. Call rx_samples(...) to access.

Parameters:
channelStream channel number (0-30)
items_per_frameNumber of 32-bit items per frame.
timeTimestamp to start streaming at
bool usrp2::usrp2::stop_rx_streaming ( unsigned int  channel = 0)

Stop streaming receive mode.

bool usrp2::usrp2::sync_and_start_rx_streaming_at ( unsigned int  channel = 0,
unsigned int  items_per_frame = 0,
uint32_t  time = 0 
)

Sync to PPS and start streaming receive mode at specified timestamp. Just like calling sync_to_pps() and start_rx_streaming_at().

Parameters:
channelStream channel number (0-30)
items_per_frameNumber of 32-bit items per frame.
timeTimestamp to start streaming at
bool usrp2::usrp2::sync_every_pps ( bool  enable)

Reset master time to 0 at every PPS edge

bool usrp2::usrp2::sync_to_pps ( )

Reset master time to 0 at next PPS edge

bool usrp2::usrp2::tx_16sc ( unsigned int  channel,
const std::complex< int16_t > *  samples,
size_t  nsamples,
const tx_metadata metadata 
)

transmit complex<int16_t> samples to USRP2

Parameters:
channelspecifies the channel to send them to
samplesare the samples to transmit
nsamplesis the number of samples to transmit
metadataprovides the timestamp and flags

The complex<int16_t> samples are converted to the appropriate "on the wire" representation, depending on the current USRP2 configuration. Typically, this is big-endian 16-bit I & Q.

bool usrp2::usrp2::tx_32fc ( unsigned int  channel,
const std::complex< float > *  samples,
size_t  nsamples,
const tx_metadata metadata 
)

transmit complex<float> samples to USRP2

Set transmit sample format

domain: complex or real type: floating, fixed point, or raw depth: bits per sample

Sets format over the wire for samples to USRP2.

Parameters:
channelspecifies the channel to send them to
samplesare the samples to transmit. They should be in the range [-1.0, +1.0]
nsamplesis the number of samples to transmit
metadataprovides the timestamp and flags

The complex<float> samples are converted to the appropriate "on the wire" representation, depending on the current USRP2 configuration. Typically, this is big-endian 16-bit I & Q.

bool usrp2::usrp2::tx_daughterboard_id ( int *  dbid)

Get Tx daughterboard ID.

Parameters:
[out]dbidreturns the daughterboard id.

daughterboard id >= 0 if successful, -1 if no daugherboard installed, -2 if invalid EEPROM on daughterboard.

double usrp2::usrp2::tx_freq_max ( )

return maximum Tx center frequency

double usrp2::usrp2::tx_freq_min ( )

return minimum Tx center frequency

double usrp2::usrp2::tx_gain_db_per_step ( )

return Tx gain db_per_step

double usrp2::usrp2::tx_gain_max ( )

return maximum Tx gain

double usrp2::usrp2::tx_gain_min ( )

return minimum Tx gain

int usrp2::usrp2::tx_interp ( )

Return current interpolation factor.

bool usrp2::usrp2::tx_raw ( unsigned int  channel,
const uint32_t items,
size_t  nitems,
const tx_metadata metadata 
)

transmit raw uint32_t data items to USRP2

The caller is responsible for ensuring that the items are formatted appropriately for the USRP2 and its configuration. This method is used primarily by the system itself. Users should call tx_32fc or tx_16sc instead.

Parameters:
channelspecifies the channel to send them to
itemsare the data items to transmit
nitemsis the number of items to transmit
metadataprovides the timestamp and flags
bool usrp2::usrp2::write_gpio ( int  bank,
uint16_t  value,
uint16_t  mask 
)

Set daughterboard GPIO pin values.

Parameters:
bankGPIO_TX_BANK or GPIO_RX_BANK
value16 bits, 0=low, 1=high
mask16 bits, 0=ignore, 1=set
Returns:
true iff successful

WARNING: Improper usage of this function may result in damage to the USRP2


Member Data Documentation

const unsigned int usrp2::usrp2::MAX_CHAN = 30 [static]

The documentation for this class was generated from the following file: