USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
uhd Namespace Reference

Namespaces

 _log
 
 cast
 
 convert
 
 csv
 
 math
 
 msg
 
 niusrprio
 
 transport
 
 usrp
 
 usrp_clock
 
 usrprio_rpc
 

Classes

struct  assertion_error
 
struct  async_metadata_t
 
class  atomic_uint32_t
 A 32-bit integer that can be atomically accessed. More...
 
struct  clock_config_t
 
class  device
 
class  device_addr_t
 
class  dict
 
struct  environment_error
 
struct  exception
 
struct  fs_path
 
struct  gain_fcns_t
 
class  gain_group
 
class  gps_ctrl
 
class  i2c_iface
 
struct  index_error
 
struct  io_error
 
class  io_type_t
 
struct  key_error
 
struct  lookup_error
 
class  mac_addr_t
 
struct  meta_range_t
 
class  msg_task
 
struct  not_implemented_error
 
struct  os_error
 
struct  otw_type_t
 
class  property
 
class  property_tree
 
class  range_t
 
class  ref_vector
 
class  reusable_barrier
 
struct  runtime_error
 
struct  rx_metadata_t
 
class  rx_streamer
 
struct  sensor_value_t
 
class  simple_claimer
 
struct  spi_config_t
 
class  spi_iface
 
struct  stream_args_t
 
struct  stream_cmd_t
 
struct  system_error
 
class  task
 
class  time_spec_t
 
struct  tune_request_t
 
struct  tune_result_t
 
struct  tx_metadata_t
 
class  tx_streamer
 
struct  type_error
 
class  uart_iface
 
struct  value_error
 
class  wb_iface
 

Typedefs

typedef std::vector< device_addr_tdevice_addrs_t
 A typedef for a vector of device addresses. More...
 
typedef meta_range_t gain_range_t
 
typedef meta_range_t freq_range_t
 
typedef std::vector< boost::uint8_t > byte_vector_t
 

Enumerations

enum  direction_t { RX_DIRECTION, TX_DIRECTION, DX_DIRECTION }
 
enum  endianness_t { ENDIANNESS_BIG, ENDIANNESS_LITTLE }
 

Functions

UHD_API fs_path operator/ (const fs_path &, const fs_path &)
 
UHD_API fs_path operator/ (const fs_path &, size_t)
 
UHD_API device_addrs_t separate_device_addr (const device_addr_t &dev_addr)
 Separate an indexed device address into a vector of device addresses. More...
 
UHD_API device_addr_t combine_device_addrs (const device_addrs_t &dev_addrs)
 Combine a vector of device addresses into an indexed device address. More...
 
UHD_API bool operator== (const time_spec_t &, const time_spec_t &)
 Implement equality_comparable interface. More...
 
UHD_API bool operator< (const time_spec_t &, const time_spec_t &)
 Implement less_than_comparable interface. More...
 
template<typename Range >
Range sorted (const Range &range)
 
template<typename Range >
Range reversed (const Range &range)
 
template<typename Range , typename T >
bool has (const Range &range, const T &value)
 
template<typename T >
clip (const T &val, const T &bound1, const T &bound2)
 
template<typename T , typename Range >
void assert_has (const Range &range, const T &value, const std::string &what="unknown")
 
template<typename T , typename Range >
UHD_INLINE void assert_has (const Range &range, const T &value, const std::string &what)
 
UHD_INLINE bool spin_wait_with_timeout (atomic_uint32_t &cond, boost::uint32_t value, const double timeout)
 
boost::uint16_t byteswap (boost::uint16_t)
 perform a byteswap on a 16 bit integer More...
 
boost::uint32_t byteswap (boost::uint32_t)
 perform a byteswap on a 32 bit integer More...
 
boost::uint64_t byteswap (boost::uint64_t)
 perform a byteswap on a 64 bit integer More...
 
template<typename T >
ntohx (T)
 network to host: short, long, or long-long More...
 
template<typename T >
htonx (T)
 host to network: short, long, or long-long More...
 
template<typename T >
wtohx (T)
 worknet to host: short, long, or long-long More...
 
template<typename T >
htowx (T)
 host to worknet: short, long, or long-long More...
 
UHD_API std::string get_tmp_path (void)
 Get a string representing the system's temporary directory. More...
 
UHD_API std::string get_app_path (void)
 Get a string representing the system's appdata directory. More...
 
UHD_API std::string get_pkg_path (void)
 Get a string representing the system's pkg directory. More...
 
std::vector< fs::path > get_module_paths (void)
 Get UHD library paths. More...
 
UHD_API std::string get_images_dir (const std::string search_paths)
 
UHD_API std::string find_image_path (const std::string &image_name, const std::string search_paths="")
 
UHD_API std::string find_utility (std::string name)
 
UHD_API std::string print_utility_error (std::string name)
 
boost::int32_t get_process_id ()
 
boost::uint32_t get_host_id ()
 
boost::uint32_t get_process_hash ()
 
UHD_API void set_thread_priority (float priority=default_thread_priority, bool realtime=true)
 
UHD_API bool set_thread_priority_safe (float priority=default_thread_priority, bool realtime=true)
 

Detailed Description

Define common exceptions used throughout the code:

  • The python built-in exceptions were used as inspiration.
  • Exceptions inherit from std::exception to provide what().
  • Exceptions inherit from uhd::exception to provide code().

The code() provides an error code which allows the application the option of printing a cryptic error message from the 1990s.

The dynamic_clone() and dynamic_throw() methods allow us to: catch an exception by dynamic type (i.e. derived class), save it, and later rethrow it, knowing only the static type (i.e. base class), and then finally to catch it again using the derived type.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2106.html

Useful templated functions, classes, and constants. Some of these overlap with the STL, but these are created with Boost for portability. Many of the range wrapper functions come with versions of boost >= 1.43.

Typedef Documentation

◆ byte_vector_t

typedef std::vector<boost::uint8_t> uhd::byte_vector_t

Byte vector typedef for passing data in and out of I2C interfaces.

◆ device_addrs_t

typedef std::vector<device_addr_t> uhd::device_addrs_t

A typedef for a vector of device addresses.

◆ freq_range_t

◆ gain_range_t

Enumeration Type Documentation

◆ direction_t

Enumerator
RX_DIRECTION 

Receive.

TX_DIRECTION 

Transmit.

DX_DIRECTION 

Duplex.

◆ endianness_t

Enumerator
ENDIANNESS_BIG 
ENDIANNESS_LITTLE 

Function Documentation

◆ assert_has() [1/2]

template<typename T , typename Range >
UHD_INLINE void uhd::assert_has ( const Range &  range,
const T &  value,
const std::string &  what = "unknown" 
)

Check that an element is found in a container. If not, throw a meaningful assertion error. The "what" in the error will show what is being set and a list of known good values.

Parameters
rangea list of possible settings
valuean element that may be in the list
whata description of what the value is
Exceptions
assertion_errorwhen elem not in list

◆ assert_has() [2/2]

template<typename T , typename Range >
void uhd::assert_has ( const Range &  range,
const T &  value,
const std::string &  what = "unknown" 
)

Check that an element is found in a container. If not, throw a meaningful assertion error. The "what" in the error will show what is being set and a list of known good values.

Parameters
rangea list of possible settings
valuean element that may be in the list
whata description of what the value is
Exceptions
assertion_errorwhen elem not in list

◆ byteswap() [1/3]

UHD_INLINE boost::uint16_t uhd::byteswap ( boost::uint16_t  x)

perform a byteswap on a 16 bit integer

◆ byteswap() [2/3]

UHD_INLINE boost::uint32_t uhd::byteswap ( boost::uint32_t  x)

perform a byteswap on a 32 bit integer

◆ byteswap() [3/3]

UHD_INLINE boost::uint64_t uhd::byteswap ( boost::uint64_t  x)

perform a byteswap on a 64 bit integer

◆ clip()

template<typename T >
T uhd::clip ( const T &  val,
const T &  bound1,
const T &  bound2 
)
inline

A templated clip implementation.

Parameters
valthe value to clip between an upper and lower limit
bound1the upper or lower bound
bound2the upper or lower bound
Returns
the value clipped at the bounds

◆ combine_device_addrs()

UHD_API device_addr_t uhd::combine_device_addrs ( const device_addrs_t dev_addrs)

Combine a vector of device addresses into an indexed device address.

◆ find_image_path()

UHD_API std::string uhd::find_image_path ( const std::string &  image_name,
const std::string  search_paths = "" 
)

Return the full path to particular UHD binary image.

This function searches for the passed image name, and returns an absolute path to it. The returned path is guaranteed to exist. The caller can also provide a full path to the image in the argument, and this function will validate it and convert it to an absolute system path.

Parameters
image_nameThe name of the file to search for, or the full path.
search_pathsHints / paths to use when calling get_images_dir
Returns
the full system path to the file
Exceptions
exceptionuhd::io_error if the file was not found.

◆ find_utility()

UHD_API std::string uhd::find_utility ( std::string  name)

Search for the location of a particular UHD utility. The utility must be installed in the uhd/utils directory.

Parameters
thename of the utility to search for
Returns
the full system path to
Parameters

◆ get_app_path()

UHD_API std::string uhd::get_app_path ( void  )

Get a string representing the system's appdata directory.

◆ get_host_id()

boost::uint32_t uhd::get_host_id ( )

◆ get_images_dir()

UHD_API std::string uhd::get_images_dir ( const std::string  search_paths)

Return the UHD images directory path.

This function returns the UHD images installation path on this system. The returned directory path is guaranteed to exist (assuming a valid path is found). This function will look for a directory that exists using this order of precedence:

1) UHD_IMAGES_DIR environment variable 2) Any paths passed to this function via `search_paths' 3) UHD package path / share / uhd / images

The search_paths parameter may contain Windows registry keys. If no directory is found, an empty string is returned.

Parameters
search_pathsA comma-separated list of hints for paths to include.
Returns
A path string if one is found, or an empty string on failure.

◆ get_module_paths()

std::vector<fs::path> uhd::get_module_paths ( void  )

Get UHD library paths.

◆ get_pkg_path()

UHD_API std::string uhd::get_pkg_path ( void  )

Get a string representing the system's pkg directory.

◆ get_process_hash()

boost::uint32_t uhd::get_process_hash ( )

◆ get_process_id()

boost::int32_t uhd::get_process_id ( )

◆ get_tmp_path()

UHD_API std::string uhd::get_tmp_path ( void  )

Get a string representing the system's temporary directory.

◆ has()

template<typename Range , typename T >
bool uhd::has ( const Range &  range,
const T &  value 
)
inline

Is the value found within the elements in this range?

Uses std::find to search the iterable for an element.

Parameters
rangethe elements to search through
valuethe match to look for in the range
Returns
true when the value is found in the range

◆ htonx()

template<typename T >
T uhd::htonx ( )

host to network: short, long, or long-long

◆ htowx()

template<typename T >
T uhd::htowx ( )

host to worknet: short, long, or long-long

◆ ntohx()

template<typename T >
T uhd::ntohx ( )

network to host: short, long, or long-long

◆ operator/() [1/2]

UHD_API fs_path uhd::operator/ ( const fs_path ,
const fs_path  
)

◆ operator/() [2/2]

UHD_API fs_path uhd::operator/ ( const fs_path ,
size_t   
)

◆ operator<()

UHD_API bool uhd::operator< ( const time_spec_t ,
const time_spec_t  
)

Implement less_than_comparable interface.

◆ operator==()

UHD_API bool uhd::operator== ( const time_spec_t ,
const time_spec_t  
)

Implement equality_comparable interface.

◆ print_utility_error()

UHD_API std::string uhd::print_utility_error ( std::string  name)

Return an error string recommending the user run the utility. The error string will include the full path to the utility to run.

Returns
the message suggesting the use of the named utility.

◆ reversed()

template<typename Range >
Range uhd::reversed ( const Range &  range)
inline

A wrapper around std::reverse that takes a range instead of an iterator.

The elements are reversed into descending order using the less-than operator. This wrapper reverses the elements non-destructively into a new range. Based on the builtin python function reversed(...)

Parameters
rangethe range of elements to be reversed
Returns
a new range with the elements reversed

◆ separate_device_addr()

UHD_API device_addrs_t uhd::separate_device_addr ( const device_addr_t dev_addr)

Separate an indexed device address into a vector of device addresses.

◆ set_thread_priority()

UHD_API void uhd::set_thread_priority ( float  priority = default_thread_priority,
bool  realtime = true 
)

Set the scheduling priority on the current thread.

A new thread or calling process should make this call with the defailts this to enable realtime scheduling.

A priority of zero corresponds to normal priority. Positive priority values are higher than normal. Negative priority values are lower than normal.

Parameters
prioritya value between -1 and 1
realtimetrue to use realtime mode
Exceptions
exceptionon set priority failure

◆ set_thread_priority_safe()

UHD_API bool uhd::set_thread_priority_safe ( float  priority = default_thread_priority,
bool  realtime = true 
)

Set the scheduling priority on the current thread. Same as set_thread_priority but does not throw on failure.

Returns
true on success, false on failure

◆ sorted()

template<typename Range >
Range uhd::sorted ( const Range &  range)
inline

A wrapper around std::sort that takes a range instead of an iterator.

The elements are sorted into ascending order using the less-than operator. This wrapper sorts the elements non-destructively into a new range. Based on the builtin python function sorted(...)

Parameters
rangethe range of elements to be sorted
Returns
a new range with the elements sorted

◆ spin_wait_with_timeout()

UHD_INLINE bool uhd::spin_wait_with_timeout ( atomic_uint32_t cond,
boost::uint32_t  value,
const double  timeout 
)

Spin-wait on a condition with a timeout.

Parameters
condan atomic variable to compare
valuecompare to atomic for true/false
timeoutthe timeout in seconds
Returns
true for cond == value, false for timeout

◆ wtohx()

template<typename T >
T uhd::wtohx ( )

worknet to host: short, long, or long-long