UHD  003.001.002
Public Types | Public Member Functions | Static Public Member Functions | List of all members
uhd::device Class Referenceabstract

#include <device.hpp>

Inheritance diagram for uhd::device:
wax::obj

Public Types

enum  send_mode_t { SEND_MODE_FULL_BUFF = 0, SEND_MODE_ONE_PACKET = 1 }
 
enum  recv_mode_t { RECV_MODE_FULL_BUFF = 0, RECV_MODE_ONE_PACKET = 1 }
 
typedef boost::shared_ptr< devicesptr
 
typedef boost::function< device_addrs_t(const device_addr_t &)> find_t
 
typedef boost::function< sptr(const device_addr_t &)> make_t
 
typedef ref_vector< const void * > send_buffs_type
 Typedef for a pointer to a single, or a collection of send buffers. More...
 
typedef ref_vector< void * > recv_buffs_type
 Typedef for a pointer to a single, or a collection of recv buffers. More...
 

Public Member Functions

virtual size_t send (const send_buffs_type &buffs, size_t nsamps_per_buff, const tx_metadata_t &metadata, const io_type_t &io_type, send_mode_t send_mode, double timeout=0.1)=0
 
virtual size_t recv (const recv_buffs_type &buffs, size_t nsamps_per_buff, rx_metadata_t &metadata, const io_type_t &io_type, recv_mode_t recv_mode, double timeout=0.1)=0
 
virtual size_t get_max_send_samps_per_packet (void) const =0
 
virtual size_t get_max_recv_samps_per_packet (void) const =0
 
virtual bool recv_async_msg (async_metadata_t &async_metadata, double timeout=0.1)=0
 
- Public Member Functions inherited from wax::obj
 obj (void)
 
 obj (const obj &o)
 
template<class T >
 obj (const T &o)
 
virtual ~obj (void)
 
obj operator[] (const obj &key)
 
objoperator= (const obj &val)
 
obj get_link (void) const
 
const std::type_info & type (void) const
 
template<class T >
as (void) const
 

Static Public Member Functions

static void register_device (const find_t &find, const make_t &make)
 
static device_addrs_t find (const device_addr_t &hint)
 Find usrp devices attached to the host. More...
 
static sptr make (const device_addr_t &hint, size_t which=0)
 Create a new usrp device from the device address hint. More...
 

Detailed Description

The usrp device interface represents the usrp hardware. The api allows for discovery, configuration, and streaming.

Member Typedef Documentation

◆ find_t

typedef boost::function<device_addrs_t(const device_addr_t &)> uhd::device::find_t

◆ make_t

typedef boost::function<sptr(const device_addr_t &)> uhd::device::make_t

◆ recv_buffs_type

Typedef for a pointer to a single, or a collection of recv buffers.

◆ send_buffs_type

Typedef for a pointer to a single, or a collection of send buffers.

◆ sptr

typedef boost::shared_ptr<device> uhd::device::sptr

Member Enumeration Documentation

◆ recv_mode_t

Recv modes for the device recv routine.

Enumerator
RECV_MODE_FULL_BUFF 

Tells the recv routine to recv the entire buffer.

RECV_MODE_ONE_PACKET 

Tells the recv routine to return after one packet.

◆ send_mode_t

Send modes for the device send routine.

Enumerator
SEND_MODE_FULL_BUFF 

Tells the send routine to send the entire buffer.

SEND_MODE_ONE_PACKET 

Tells the send routine to return after one packet.

Member Function Documentation

◆ find()

static device_addrs_t uhd::device::find ( const device_addr_t hint)
static

Find usrp devices attached to the host.

The hint device address should be used to narrow down the search to particular transport types and/or transport arguments.

Parameters
hinta partially (or fully) filled in device address
Returns
a vector of device addresses for all usrps on the system

◆ get_max_recv_samps_per_packet()

virtual size_t uhd::device::get_max_recv_samps_per_packet ( void  ) const
pure virtual

Get the maximum number of samples per packet on recv.

Returns
the number of samples

◆ get_max_send_samps_per_packet()

virtual size_t uhd::device::get_max_send_samps_per_packet ( void  ) const
pure virtual

Get the maximum number of samples per packet on send.

Returns
the number of samples

◆ make()

static sptr uhd::device::make ( const device_addr_t hint,
size_t  which = 0 
)
static

Create a new usrp device from the device address hint.

The make routine will call find and pick one of the results. By default, the first result will be used to create a new device. Use the which parameter as an index into the list of results.

Parameters
hinta partially (or fully) filled in device address
whichwhich address to use when multiple are found
Returns
a shared pointer to a new device instance

◆ recv()

virtual size_t uhd::device::recv ( const recv_buffs_type buffs,
size_t  nsamps_per_buff,
rx_metadata_t metadata,
const io_type_t io_type,
recv_mode_t  recv_mode,
double  timeout = 0.1 
)
pure virtual

Receive buffers containing IF data described by the metadata.

Receive handles fragmentation as follows: If the buffer has insufficient space to hold all samples that were received in a single packet over-the-wire, then the buffer will be completely filled and the implementation will hold a pointer into the remaining portion of the packet. Subsequent calls will load from the remainder of the packet, and will flag the metadata to show that this is a fragment. The next call to receive, after the remainder becomes exahausted, will perform an over-the-wire receive as usual. See the rx metadata fragment flags and offset fields for details.

This is a blocking call and will not return until the number of samples returned have been written into each buffer. Under a timeout condition, the number of samples returned may be less than the number of samples specified.

When using the full buffer recv mode, the metadata only applies to the first packet received and written into the recv buffers. Use the one packet recv mode to get per packet metadata.

Parameters
buffsa vector of writable memory to fill with IF data
nsamps_per_buffthe size of each buffer in number of samples
metadatadata to fill describing the buffer
io_typethe type of data to fill into the buffer
recv_modetells recv how to load the buffer
timeoutthe timeout in seconds to wait for a packet
Returns
the number of samples received or 0 on error

◆ recv_async_msg()

virtual bool uhd::device::recv_async_msg ( async_metadata_t async_metadata,
double  timeout = 0.1 
)
pure virtual

Receive and asynchronous message from the device.

Parameters
async_metadatathe metadata to be filled in
timeoutthe timeout in seconds to wait for a message
Returns
true when the async_metadata is valid, false for timeout

◆ register_device()

static void uhd::device::register_device ( const find_t find,
const make_t make 
)
static

Register a device into the discovery and factory system.

Parameters
finda function that discovers devices
makea factory function that makes a device

◆ send()

virtual size_t uhd::device::send ( const send_buffs_type buffs,
size_t  nsamps_per_buff,
const tx_metadata_t metadata,
const io_type_t io_type,
send_mode_t  send_mode,
double  timeout = 0.1 
)
pure virtual

Send buffers containing IF data described by the metadata.

Send handles fragmentation as follows: If the buffer has more samples than the maximum per packet, the send method will fragment the samples across several packets. Send will respect the burst flags when fragmenting to ensure that start of burst can only be set on the first fragment and that end of burst can only be set on the final fragment. Fragmentation only applies in the full buffer send mode.

This is a blocking call and will not return until the number of samples returned have been read out of each buffer. Under a timeout condition, the number of samples returned may be less than the number of samples specified.

Parameters
buffsa vector of read-only memory containing IF data
nsamps_per_buffthe number of samples to send, per buffer
metadatadata describing the buffer's contents
io_typethe type of data loaded in the buffer
send_modetells send how to unload the buffer
timeoutthe timeout in seconds to wait on a packet
Returns
the number of samples sent

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