aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/usrp_uhd/Makefile.am1
-rw-r--r--include/usrp_uhd/device.hpp37
-rw-r--r--include/usrp_uhd/device_addr.hpp9
-rw-r--r--include/usrp_uhd/props.hpp154
-rw-r--r--include/usrp_uhd/usrp/Makefile.am4
-rw-r--r--include/usrp_uhd/usrp/mboard/Makefile.am5
-rw-r--r--include/usrp_uhd/usrp/mboard/base.hpp32
-rw-r--r--include/usrp_uhd/usrp/mboard/test.hpp29
-rw-r--r--include/usrp_uhd/usrp/usrp.hpp37
9 files changed, 292 insertions, 16 deletions
diff --git a/include/usrp_uhd/Makefile.am b/include/usrp_uhd/Makefile.am
index 02a129484..40c7d9f99 100644
--- a/include/usrp_uhd/Makefile.am
+++ b/include/usrp_uhd/Makefile.am
@@ -10,4 +10,5 @@ this_includedir = $(includedir)/usrp_uhd
this_include_HEADERS = \
device.hpp \
device_addr.hpp \
+ props.hpp \
wax.hpp
diff --git a/include/usrp_uhd/device.hpp b/include/usrp_uhd/device.hpp
index 9d70b9ac3..ad2d3b368 100644
--- a/include/usrp_uhd/device.hpp
+++ b/include/usrp_uhd/device.hpp
@@ -6,11 +6,13 @@
#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 <sys/uio.h>
+#include <boost/asio/buffer.hpp>
namespace usrp_uhd{
@@ -18,11 +20,14 @@ namespace usrp_uhd{
* The usrp device interface represents the usrp hardware.
* The api allows for discovery, configuration, and streaming.
*/
-class device{
+class device : boost::noncopyable, public wax::obj{
public:
typedef boost::shared_ptr<device> sptr;
- typedef boost::function<bool(void *data, size_t len)> recv_hdlr_t;
+
+ //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.
@@ -33,7 +38,7 @@ public:
* \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);
+ static std::vector<device_addr_t> discover(const device_addr_t & hint);
/*!
* \brief Create a new usrp device from the device address hint.
@@ -46,27 +51,31 @@ public:
* \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);
+ 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.
*/
- ~device(void);
+ virtual ~device(void);
+
+ /*!
+ * Get the device address for this board.
+ */
+ device_addr_t get_device_addr(void);
//the io interface
- void send_raw(const std::vector<iovec> &iovs);
- void recv_raw(const recv_hdlr_t &recv_hdlr);
+ 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);
- //the properties interface
- wax::proxy props(void);
-
private:
- device(const device_addr_t& hint);
-
- wax::type d_mboard;
};
} //namespace usrp_uhd
diff --git a/include/usrp_uhd/device_addr.hpp b/include/usrp_uhd/device_addr.hpp
index c082d9f84..38c6c32dd 100644
--- a/include/usrp_uhd/device_addr.hpp
+++ b/include/usrp_uhd/device_addr.hpp
@@ -60,15 +60,20 @@ namespace usrp_uhd{
} usb_args;
struct{
std::string ifc;
- mac_addr_t mac_addr;
+ std::string mac_addr;
} eth_args;
struct{
- ip_addr_t ip_addr;
+ std::string addr;
} udp_args;
struct{
//TODO unknown for now
} gpmc_args;
+ //the discovery args are filled in by the discovery routine
+ struct{
+ uint16_t mboard_id;
+ } discovery_args;
+
/*!
* \brief Convert a usrp device_addr_t into a string representation
*/
diff --git a/include/usrp_uhd/props.hpp b/include/usrp_uhd/props.hpp
new file mode 100644
index 000000000..c66f40674
--- /dev/null
+++ b/include/usrp_uhd/props.hpp
@@ -0,0 +1,154 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#include <boost/tuple/tuple.hpp>
+#include <usrp_uhd/wax.hpp>
+#include <complex>
+#include <vector>
+
+#ifndef INCLUDED_USRP_UHD_PROPS_HPP
+#define INCLUDED_USRP_UHD_PROPS_HPP
+
+namespace usrp_uhd{
+
+ /*!
+ * A time_spec_t holds a seconds and ticks time value.
+ * The temporal width of a tick depends on the device's clock rate.
+ * The time_spec_t can be used when setting the time on devices
+ * and for controlling the start of streaming for applicable dsps.
+ */
+ struct time_spec_t{
+ uint32_t secs;
+ uint32_t ticks;
+
+ /*!
+ * Create a time_spec_t that holds a wildcard time.
+ * This will have implementation-specific meaning.
+ */
+ time_spec_t(void){
+ secs = ~0;
+ ticks = ~0;
+ }
+
+ /*!
+ * Create a time_spec_t from seconds and ticks.
+ * \param new_secs the new seconds
+ * \param new_ticks the new ticks (default = 0)
+ */
+ time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0){
+ secs = new_secs;
+ ticks = new_ticks;
+ }
+ };
+
+ //common typedefs for board properties
+ typedef float gain_t;
+ typedef double freq_t;
+
+ //scalar types
+ typedef int int_scalar_t;
+ typedef float real_scalar_t;
+ typedef std::complex<real_scalar_t> complex_scalar_t;
+
+ //vector types
+ typedef std::vector<int_scalar_t> int_vec_t;
+ typedef std::vector<real_scalar_t> real_vec_t;
+ typedef std::vector<complex_scalar_t> complex_vec_t;
+
+ //typedef for addressing indexable components
+ typedef boost::tuple<wax::type, size_t> indexed_prop_t;
+
+ /*!
+ * Possible device properties.
+ */
+ enum device_prop_t{
+ DEVICE_PROP_NAME, //ro, std::string
+ DEVICE_PROP_MBOARD, //ro, wax::obj
+ DEVICE_PROP_NUM_MBOARDS //ro, size_t
+ };
+
+ /*!
+ * Possible device mboard properties
+ */
+ enum mboard_prop_t{
+ MBOARD_PROP_NAME, //ro, std::string
+ MBOARD_PROP_MTU, //ro, size_t
+ MBOARD_PROP_CLOCK_RATE, //ro, freq_t
+ MBOARD_PROP_RX_DSP, //ro, wax::obj
+ MBOARD_PROP_NUM_RX_DSPS, //ro, size_t
+ MBOARD_PROP_TX_DSP, //ro, wax::obj
+ MBOARD_PROP_NUM_TX_DSPS, //ro, size_t
+ MBOARD_PROP_RX_DBOARD, //ro, wax::obj
+ MBOARD_PROP_NUM_RX_DBOARDS, //ro, size_t
+ MBOARD_PROP_TX_DBOARD, //ro, wax::obj
+ MBOARD_PROP_NUM_TX_DBOARDS, //ro, size_t
+ MBOARD_PROP_PPS_SOURCE, //rw, std::string (sma, mimo)
+ MBOARD_PROP_PPS_POLARITY, //rw, int, +/- 1
+ MBOARD_PROP_REF_SOURCE, //rw, std::string (int, sma, mimo)
+ MBOARD_PROP_TIME_NOW, //wo, time_spec_t
+ MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t
+ };
+
+ /*!
+ * Possible device dsp properties
+ */
+ enum dsp_prop_t{
+ DSP_PROP_NAME, //ro, std::string
+ DSP_PROP_FREQ, //rw, freq_t
+ DSP_PROP_TAPS, //rw, *_vec_t
+ DSP_PROP_RATE, //rw, *_scalar_t, decim/interp
+ DSP_PROP_SCALAR, //rw, *_scalar_t
+ DSP_PROP_ENABLED //rw, bool or time_spec_t
+ };
+
+ /*!
+ * Possible device dboard properties
+ */
+ enum dboard_prop_t{
+ DBOARD_PROP_NAME, //ro, std::string
+ DBOARD_PROP_SUBDEV, //ro, wax::obj
+ DBOARD_PROP_NUM_SUBDEVS, //ro, size_t
+ DBOARD_PROP_CODEC //ro, wax::obj
+ };
+
+ /*!
+ * Possible device codec properties
+ */
+ enum codec_prop_t{
+ CODEC_PROP_NAME, //ro, std::string
+ CODEC_PROP_GAIN, //rw, gain_t
+ CODEC_PROP_GAIN_MAX, //ro, gain_t
+ CODEC_PROP_GAIN_MIN, //ro, gain_t
+ CODEC_PROP_GAIN_STEP, //ro, gain_t
+ CODEC_PROP_NUM_GAINS, //ro, size_t
+ CODEC_PROP_CLOCK_RATE //ro, freq_t
+ };
+
+ /*!
+ * Possible device subdev properties
+ */
+ enum subdev_prop_t{
+ SUBDEV_PROP_NAME, //ro, std::string
+ SUBDEV_PROP_GAIN, //rw, gain_t
+ SUBDEV_PROP_GAIN_MAX, //ro, gain_t
+ SUBDEV_PROP_GAIN_MIN, //ro, gain_t
+ SUBDEV_PROP_GAIN_STEP, //ro, gain_t
+ SUBDEV_PROP_NUM_GAINS, //ro, size_t
+ SUBDEV_PROP_FREQ, //rw, freq_t
+ SUBDEV_PROP_FREQ_MAX, //ro, freq_t
+ SUBDEV_PROP_FREQ_MIN, //ro, freq_t
+ SUBDEV_PROP_ANTENNA, //rw, std::string
+ SUBDEV_PROP_ENABLED, //rw, bool
+ SUBDEV_PROP_QUADRATURE, //ro, bool
+ SUBDEV_PROP_IQ_SWAPPED, //ro, bool
+ SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool
+ SUBDEV_PROP_IS_TX, //ro, bool
+ SUBDEV_PROP_RSSI, //ro, gain_t
+ SUBDEV_PROP_BANDWIDTH, //rw, freq_t
+ SUBDEV_PROP_CLOCK_RATE //ro, freq_t
+ };
+
+} //namespace usrp_uhd
+
+#endif /* INCLUDED_USRP_UHD_PROPS_HPP */
diff --git a/include/usrp_uhd/usrp/Makefile.am b/include/usrp_uhd/usrp/Makefile.am
index 913f80a6d..d15eb6ddc 100644
--- a/include/usrp_uhd/usrp/Makefile.am
+++ b/include/usrp_uhd/usrp/Makefile.am
@@ -5,3 +5,7 @@
include $(top_srcdir)/Makefile.common
SUBDIRS = mboard dboard
+
+this_includedir = $(includedir)/usrp_uhd/usrp
+this_include_HEADERS = \
+ usrp.hpp
diff --git a/include/usrp_uhd/usrp/mboard/Makefile.am b/include/usrp_uhd/usrp/mboard/Makefile.am
index 66fc4dd71..3197353ce 100644
--- a/include/usrp_uhd/usrp/mboard/Makefile.am
+++ b/include/usrp_uhd/usrp/mboard/Makefile.am
@@ -5,3 +5,8 @@
include $(top_srcdir)/Makefile.common
SUBDIRS =
+
+this_includedir = $(includedir)/usrp_uhd/usrp/mboard
+this_include_HEADERS = \
+ base.hpp \
+ test.hpp
diff --git a/include/usrp_uhd/usrp/mboard/base.hpp b/include/usrp_uhd/usrp/mboard/base.hpp
new file mode 100644
index 000000000..ef455151b
--- /dev/null
+++ b/include/usrp_uhd/usrp/mboard/base.hpp
@@ -0,0 +1,32 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP
+#define INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP
+
+#include <usrp_uhd/wax.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace usrp_uhd{ namespace usrp{ namespace mboard{
+
+/*!
+ * A base class for usrp mboard objects.
+ */
+class base : boost::noncopyable, public wax::obj{
+public:
+ typedef boost::shared_ptr<base> sptr;
+ base(void);
+ ~base(void);
+
+ //TODO other api calls
+
+private:
+ virtual void get(const wax::type &, wax::type &) = 0;
+ virtual void set(const wax::type &, const wax::type &) = 0;
+};
+
+}}} //namespace
+
+#endif /* INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP */
diff --git a/include/usrp_uhd/usrp/mboard/test.hpp b/include/usrp_uhd/usrp/mboard/test.hpp
new file mode 100644
index 000000000..f3c2899cf
--- /dev/null
+++ b/include/usrp_uhd/usrp/mboard/test.hpp
@@ -0,0 +1,29 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP
+#define INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP
+
+#include <usrp_uhd/usrp/mboard/base.hpp>
+#include <usrp_uhd/device_addr.hpp>
+
+namespace usrp_uhd{ namespace usrp{ namespace mboard{
+
+/*!
+ * A test usrp mboard object.
+ * Exercises access routines for the test suite.
+ */
+class test : public base{
+public:
+ test(const device_addr_t &);
+ ~test(void);
+
+private:
+ void get(const wax::type &, wax::type &);
+ void set(const wax::type &, const wax::type &);
+};
+
+}}} //namespace
+
+#endif /* INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP */
diff --git a/include/usrp_uhd/usrp/usrp.hpp b/include/usrp_uhd/usrp/usrp.hpp
new file mode 100644
index 000000000..b280b0d40
--- /dev/null
+++ b/include/usrp_uhd/usrp/usrp.hpp
@@ -0,0 +1,37 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#include <usrp_uhd/device.hpp>
+#include <usrp_uhd/usrp/mboard/base.hpp>
+#include <vector>
+
+#ifndef INCLUDED_USRP_UHD_USRP_USRP_HPP
+#define INCLUDED_USRP_UHD_USRP_USRP_HPP
+
+namespace usrp_uhd{ namespace usrp{
+
+/*!
+ * A usrp device provides a device-level interface to usrp mboards.
+ * In most cases, a usrp device will have only one mboard.
+ * In the usrp2 mimo case, this device will have two mboards,
+ * where one talks through the other's control port.
+ */
+class usrp : public device{
+public:
+ usrp(const device_addr_t & device_addr);
+ ~usrp(void);
+
+ void send_raw(const send_args_t &);
+ void recv_raw(const recv_args_t &);
+
+private:
+ void get(const wax::type &, wax::type &);
+ void set(const wax::type &, const wax::type &);
+
+ std::vector<mboard::base::sptr> _mboards;
+};
+
+}} //namespace
+
+#endif /* INCLUDED_USRP_UHD_USRP_USRP_HPP */