aboutsummaryrefslogtreecommitdiffstats
path: root/include/usrp_uhd/device.hpp
blob: ad2d3b368cc6f82f6840deabc5980ea9570133b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// Copyright 2010 Ettus Research LLC
//

#ifndef INCLUDED_USRP_UHD_DEVICE_HPP
#define INCLUDED_USRP_UHD_DEVICE_HPP

#include <usrp_uhd/device_addr.hpp>
#include <usrp_uhd/props.hpp>
#include <usrp_uhd/wax.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <vector>
#include <boost/asio/buffer.hpp>

namespace usrp_uhd{

/*!
 * The usrp device interface represents the usrp hardware.
 * The api allows for discovery, configuration, and streaming.
 */
class device : boost::noncopyable, public wax::obj{

public:
    typedef boost::shared_ptr<device> sptr;

    //argument types for send and recv raw methods
    typedef std::vector<boost::asio::const_buffer> send_args_t;
    typedef boost::function<bool(const boost::asio::const_buffer &)> recv_args_t;

    /*!
     * \brief Discover 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.
     *
     * \param hint a partially (or fully) filled in device address
     * \return a vector of device addresses for all usrps on the system
     */
    static std::vector<device_addr_t> discover(const device_addr_t & hint);

    /*!
     * \brief Create a new usrp device from the device address hint.
     *
     * The make routine will call discover 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.
     *
     * \param hint a partially (or fully) filled in device address
     * \param which which address to use when multiple are discovered
     * \return a shared pointer to a new device instance
     */
    static sptr make(const device_addr_t & hint, size_t which = 0);

    /*!
     * Constructor: Called in derived classes.
     */
    device(void);

    /*!
     * Deconstructor: called automatically by the shared pointer.
     */
    virtual ~device(void);

    /*!
     * Get the device address for this board.
     */
    device_addr_t get_device_addr(void);

    //the io interface
    virtual void send_raw(const send_args_t &) = 0;
    virtual void recv_raw(const recv_args_t &) = 0;

    //connect dsps and subdevs
    void connect(const wax::type &src, const wax::type &sink);

private:
};

} //namespace usrp_uhd

#endif /* INCLUDED_USRP_UHD_DEVICE_HPP */