summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-30 13:32:52 +0000
committerJosh Blum <josh@joshknows.com>2010-03-30 13:32:52 +0000
commitf94fa1e464c9e2a87274c991dc6461f7f4c956d8 (patch)
tree1b88020a0dece1ae509cf3fb219b7cce487dc198 /host/include
parent29e88b3478aad89ff76363029395200a8601e667 (diff)
parent281307833c8275031bd2469e6aef3f472490749a (diff)
downloaduhd-f94fa1e464c9e2a87274c991dc6461f7f4c956d8.tar.gz
uhd-f94fa1e464c9e2a87274c991dc6461f7f4c956d8.tar.bz2
uhd-f94fa1e464c9e2a87274c991dc6461f7f4c956d8.zip
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhd into usrp_e
Conflicts: host/include/uhd/usrp/dboard_id.hpp host/lib/usrp/usrp2/usrp2_impl.cpp
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/CMakeLists.txt11
-rw-r--r--host/include/uhd/config.hpp159
-rw-r--r--host/include/uhd/device.hpp28
-rw-r--r--host/include/uhd/device_addr.hpp69
-rw-r--r--host/include/uhd/metadata.hpp61
-rw-r--r--host/include/uhd/props.hpp2
-rw-r--r--host/include/uhd/simple_device.hpp13
-rw-r--r--host/include/uhd/transport/CMakeLists.txt3
-rw-r--r--host/include/uhd/transport/if_addrs.hpp47
-rw-r--r--host/include/uhd/transport/smart_buffer.hpp2
-rw-r--r--host/include/uhd/transport/udp_simple.hpp2
-rw-r--r--host/include/uhd/transport/udp_zero_copy.hpp2
-rw-r--r--host/include/uhd/transport/vrt.hpp2
-rw-r--r--host/include/uhd/types/CMakeLists.txt32
-rw-r--r--host/include/uhd/types/clock_config.hpp50
-rw-r--r--host/include/uhd/types/device_addr.hpp70
-rw-r--r--host/include/uhd/types/dict.hpp (renamed from host/include/uhd/dict.hpp)13
-rw-r--r--host/include/uhd/types/io_type.hpp69
-rw-r--r--host/include/uhd/types/mac_addr.hpp68
-rw-r--r--host/include/uhd/types/metadata.hpp61
-rw-r--r--host/include/uhd/types/otw_type.hpp63
-rw-r--r--host/include/uhd/types/ranges.hpp (renamed from host/include/uhd/types.hpp)43
-rw-r--r--host/include/uhd/types/stream_cmd.hpp56
-rw-r--r--host/include/uhd/types/time_spec.hpp (renamed from host/include/uhd/time_spec.hpp)16
-rw-r--r--host/include/uhd/types/tune_result.hpp44
-rw-r--r--host/include/uhd/usrp/CMakeLists.txt2
-rw-r--r--host/include/uhd/usrp/dboard_id.hpp2
-rw-r--r--host/include/uhd/usrp/dboard_manager.hpp4
-rw-r--r--host/include/uhd/usrp/usrp1e.hpp5
-rw-r--r--host/include/uhd/usrp/usrp2.hpp5
-rw-r--r--host/include/uhd/utils/CMakeLists.txt26
-rw-r--r--host/include/uhd/utils/algorithm.hpp60
-rw-r--r--host/include/uhd/utils/assert.hpp (renamed from host/include/uhd/utils.hpp)74
-rw-r--r--host/include/uhd/utils/gain_handler.hpp (renamed from host/include/uhd/gain_handler.hpp)6
-rw-r--r--host/include/uhd/utils/safe_main.hpp44
-rw-r--r--host/include/uhd/utils/static.hpp37
-rw-r--r--host/include/uhd/utils/tune_helper.hpp79
-rw-r--r--host/include/uhd/wax.hpp4
38 files changed, 961 insertions, 373 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt
index 3d00462cf..b364f78cd 100644
--- a/host/include/uhd/CMakeLists.txt
+++ b/host/include/uhd/CMakeLists.txt
@@ -17,20 +17,15 @@
ADD_SUBDIRECTORY(transport)
+ADD_SUBDIRECTORY(types)
ADD_SUBDIRECTORY(usrp)
+ADD_SUBDIRECTORY(utils)
INSTALL(FILES
config.hpp
device.hpp
- device_addr.hpp
- dict.hpp
- gain_handler.hpp
- metadata.hpp
props.hpp
simple_device.hpp
- time_spec.hpp
- types.hpp
- utils.hpp
wax.hpp
- DESTINATION ${HEADER_DIR}/uhd
+ DESTINATION ${INCLUDE_DIR}/uhd
)
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 10f9c093f..941219ac7 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -1,76 +1,83 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INCLUDED_UHD_CONFIG_HPP
-#define INCLUDED_UHD_CONFIG_HPP
-
-// suppress warnings
-#include <boost/config.hpp>
-#ifdef BOOST_MSVC
-# pragma warning(push)
-//# pragma warning(disable: 4511) // copy constructor can't not be generated
-//# pragma warning(disable: 4512) // assignment operator can't not be generated
-//# pragma warning(disable: 4100) // unreferenced formal parameter
-//# pragma warning(disable: 4996) // <symbol> was declared deprecated
-//# pragma warning(disable: 4355) // 'this' : used in base member initializer list
-//# pragma warning(disable: 4706) // assignment within conditional expression
-# pragma warning(disable: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
-//# pragma warning(disable: 4127) // conditional expression is constant
-//# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
-//# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
-# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ...
-//# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
-//# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
-#endif
-
-// http://gcc.gnu.org/wiki/Visibility
-// Generic helper definitions for shared library support
-#if defined _WIN32 || defined __CYGWIN__
- #define UHD_HELPER_DLL_IMPORT __declspec(dllimport)
- #define UHD_HELPER_DLL_EXPORT __declspec(dllexport)
- #define UHD_HELPER_DLL_LOCAL
-#else
- #if __GNUC__ >= 4
- #define UHD_HELPER_DLL_IMPORT __attribute__ ((visibility("default")))
- #define UHD_HELPER_DLL_EXPORT __attribute__ ((visibility("default")))
- #define UHD_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden")))
- #else
- #define UHD_HELPER_DLL_IMPORT
- #define UHD_HELPER_DLL_EXPORT
- #define UHD_HELPER_DLL_LOCAL
- #endif
-#endif
-
-// Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL.
-// UHD_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
-// UHD_LOCAL is used for non-api symbols.
-
-#define UHD_DLL // defined here, put into configuration if we need to make static libs
-
-#ifdef UHD_DLL // defined if UHD is compiled as a DLL
- #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it)
- #define UHD_API UHD_HELPER_DLL_EXPORT
- #else
- #define UHD_API UHD_HELPER_DLL_IMPORT
- #endif // UHD_DLL_EXPORTS
- #define UHD_LOCAL UHD_HELPER_DLL_LOCAL
-#else // UHD_DLL is not defined: this means UHD is a static lib.
- #define UHD_API
- #define UHD_LOCAL
-#endif // UHD_DLL
-
-#endif /* INCLUDED_UHD_CONFIG_HPP */
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_CONFIG_HPP
+#define INCLUDED_UHD_CONFIG_HPP
+
+// suppress warnings
+#include <boost/config.hpp>
+#ifdef BOOST_MSVC
+//# pragma warning(push)
+//# pragma warning(disable: 4511) // copy constructor can't not be generated
+//# pragma warning(disable: 4512) // assignment operator can't not be generated
+//# pragma warning(disable: 4100) // unreferenced formal parameter
+//# pragma warning(disable: 4996) // <symbol> was declared deprecated
+//# pragma warning(disable: 4355) // 'this' : used in base member initializer list
+//# pragma warning(disable: 4706) // assignment within conditional expression
+# pragma warning(disable: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
+//# pragma warning(disable: 4127) // conditional expression is constant
+//# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
+//# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ...
+//# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+//# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
+#endif
+
+//define logical operators
+#ifdef BOOST_MSVC
+ #define not !
+ #define and &&
+ #define or ||
+#endif
+
+// http://gcc.gnu.org/wiki/Visibility
+// Generic helper definitions for shared library support
+#if defined _WIN32 || defined __CYGWIN__
+ #define UHD_HELPER_DLL_IMPORT __declspec(dllimport)
+ #define UHD_HELPER_DLL_EXPORT __declspec(dllexport)
+ #define UHD_HELPER_DLL_LOCAL
+#else
+ #if __GNUC__ >= 4
+ #define UHD_HELPER_DLL_IMPORT __attribute__ ((visibility("default")))
+ #define UHD_HELPER_DLL_EXPORT __attribute__ ((visibility("default")))
+ #define UHD_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden")))
+ #else
+ #define UHD_HELPER_DLL_IMPORT
+ #define UHD_HELPER_DLL_EXPORT
+ #define UHD_HELPER_DLL_LOCAL
+ #endif
+#endif
+
+// Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL.
+// UHD_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
+// UHD_LOCAL is used for non-api symbols.
+
+#define UHD_DLL // defined here, put into configuration if we need to make static libs
+
+#ifdef UHD_DLL // defined if UHD is compiled as a DLL
+ #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it)
+ #define UHD_API UHD_HELPER_DLL_EXPORT
+ #else
+ #define UHD_API UHD_HELPER_DLL_IMPORT
+ #endif // UHD_DLL_EXPORTS
+ #define UHD_LOCAL UHD_HELPER_DLL_LOCAL
+#else // UHD_DLL is not defined: this means UHD is a static lib.
+ #define UHD_API
+ #define UHD_LOCAL
+#endif // UHD_DLL
+
+#endif /* INCLUDED_UHD_CONFIG_HPP */
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp
index 13b40febe..4d4196d98 100644
--- a/host/include/uhd/device.hpp
+++ b/host/include/uhd/device.hpp
@@ -19,9 +19,9 @@
#define INCLUDED_UHD_DEVICE_HPP
#include <uhd/config.hpp>
-#include <uhd/device_addr.hpp>
-#include <uhd/props.hpp>
-#include <uhd/metadata.hpp>
+#include <uhd/types/device_addr.hpp>
+#include <uhd/types/metadata.hpp>
+#include <uhd/types/io_type.hpp>
#include <uhd/wax.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
@@ -38,22 +38,22 @@ class UHD_API device : boost::noncopyable, public wax::obj{
public:
typedef boost::shared_ptr<device> sptr;
- typedef boost::function<device_addrs_t(const device_addr_t &)> discover_t;
+ typedef boost::function<device_addrs_t(const device_addr_t &)> find_t;
typedef boost::function<sptr(const device_addr_t &)> make_t;
/*!
* Register a device into the discovery and factory system.
*
- * \param discover a function that discovers devices
+ * \param find a function that discovers devices
* \param make a factory function that makes a device
*/
static void register_device(
- const discover_t &discover,
+ const find_t &find,
const make_t &make
);
/*!
- * \brief Discover usrp devices attached to the host.
+ * \brief 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.
@@ -61,17 +61,17 @@ public:
* \param hint a partially (or fully) filled in device address
* \return a vector of device addresses for all usrps on the system
*/
- static device_addrs_t discover(const device_addr_t &hint);
+ static device_addrs_t find(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.
+ * 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.
*
* \param hint a partially (or fully) filled in device address
- * \param which which address to use when multiple are discovered
+ * \param which which address to use when multiple are found
* \return a shared pointer to a new device instance
*/
static sptr make(const device_addr_t &hint, size_t which = 0);
@@ -91,13 +91,13 @@ public:
*
* \param buff a buffer pointing to some read-only memory
* \param metadata data describing the buffer's contents
- * \param the type of data loaded in the buffer (32fc, 16sc)
+ * \param io_type the type of data loaded in the buffer
* \return the number of samples sent
*/
virtual size_t send(
const boost::asio::const_buffer &buff,
const tx_metadata_t &metadata,
- const std::string &type = "32fc"
+ const io_type_t &io_type
) = 0;
/*!
@@ -123,13 +123,13 @@ public:
*
* \param buff the buffer to fill with IF data
* \param metadata data to fill describing the buffer
- * \param the type of data to fill into the buffer (32fc, 16sc)
+ * \param io_type the type of data to fill into the buffer
* \return the number of samples received
*/
virtual size_t recv(
const boost::asio::mutable_buffer &buff,
rx_metadata_t &metadata,
- const std::string &type = "32fc"
+ const io_type_t &io_type
) = 0;
};
diff --git a/host/include/uhd/device_addr.hpp b/host/include/uhd/device_addr.hpp
deleted file mode 100644
index 7673faff0..000000000
--- a/host/include/uhd/device_addr.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INCLUDED_UHD_DEVICE_ADDR_HPP
-#define INCLUDED_UHD_DEVICE_ADDR_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/dict.hpp>
-#include <boost/cstdint.hpp>
-#include <string>
-#include <iostream>
-#include <vector>
-
-namespace uhd{
-
- /*!
- * Wrapper for an ethernet mac address.
- * Provides conversion between string and binary formats.
- */
- struct UHD_API mac_addr_t{
- boost::uint8_t mac_addr[6];
- mac_addr_t(const std::string &mac_addr_str = "00:00:00:00:00:00");
- std::string to_string(void) const;
- };
-
- /*!
- * The device address args are just a mapping of key/value string pairs.
- * When left empty, the discovery routine will try to find all usrps.
- * The discovery can be narrowed down by specifying the transport type arguments.
- *
- * For example, to access a specific usrp2 one would specify the transport type
- * ("type", "udp") and the transport args ("addr", "<resolvable_hostname_or_addr>").
- */
- typedef dict<std::string, std::string> device_addr_t;
- typedef std::vector<device_addr_t> device_addrs_t;
-
- /*!
- * Function to turn a device address into a string.
- * Just having the operator<< below should be sufficient.
- * However, boost format seems to complain with the %
- * and this is just easier because it works.
- * \param device_addr a device address instance
- * \return the string representation
- */
- namespace device_addr{
- UHD_API std::string to_string(const device_addr_t &device_addr);
- }
-
-} //namespace uhd
-
-//ability to use types with stream operators
-UHD_API std::ostream& operator<<(std::ostream &, const uhd::device_addr_t &);
-UHD_API std::ostream& operator<<(std::ostream &, const uhd::mac_addr_t &);
-
-#endif /* INCLUDED_UHD_DEVICE_ADDR_HPP */
diff --git a/host/include/uhd/metadata.hpp b/host/include/uhd/metadata.hpp
deleted file mode 100644
index 6d80f070d..000000000
--- a/host/include/uhd/metadata.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INCLUDED_UHD_METADATA_HPP
-#define INCLUDED_UHD_METADATA_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/time_spec.hpp>
-
-namespace uhd{
-
-/*!
- * RX metadata structure for describing sent IF data.
- * Includes stream ID, time specification, and fragmentation flags.
- * The receive routines will convert IF data headers into metadata.
- */
-struct UHD_API rx_metadata_t{
- boost::uint32_t stream_id;
- time_spec_t time_spec;
- bool has_stream_id;
- bool has_time_spec;
- bool is_fragment;
-
- //default constructor
- rx_metadata_t(void);
-};
-
-/*!
- * TX metadata structure for describing received IF data.
- * Includes stream ID, time specification, and burst flags.
- * The send routines will convert the metadata to IF data headers.
- */
-struct UHD_API tx_metadata_t{
- boost::uint32_t stream_id;
- time_spec_t time_spec;
- bool has_stream_id;
- bool has_time_spec;
- bool start_of_burst;
- bool end_of_burst;
-
- //default constructor
- tx_metadata_t(void);
-};
-
-} //namespace uhd
-
-#endif /* INCLUDED_UHD_METADATA_HPP */
diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp
index 41e0eff63..01746f853 100644
--- a/host/include/uhd/props.hpp
+++ b/host/include/uhd/props.hpp
@@ -76,8 +76,6 @@ namespace uhd{
MBOARD_PROP_TX_DBOARD, //ro, wax::obj
MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t
MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t
- MBOARD_PROP_PPS_SOURCE_NAMES, //ro, prop_names_t
- MBOARD_PROP_REF_SOURCE_NAMES, //ro, prop_names_t
MBOARD_PROP_TIME_NOW, //wo, time_spec_t
MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t
};
diff --git a/host/include/uhd/simple_device.hpp b/host/include/uhd/simple_device.hpp
index ad25eccdc..52928367a 100644
--- a/host/include/uhd/simple_device.hpp
+++ b/host/include/uhd/simple_device.hpp
@@ -20,7 +20,9 @@
#include <uhd/config.hpp>
#include <uhd/device.hpp>
-#include <uhd/types.hpp>
+#include <uhd/types/ranges.hpp>
+#include <uhd/types/stream_cmd.hpp>
+#include <uhd/types/tune_result.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <vector>
@@ -43,10 +45,15 @@ public:
virtual std::string get_name(void) = 0;
/*******************************************************************
+ * Timing
+ ******************************************************************/
+ virtual void set_time_now(const time_spec_t &time_spec) = 0;
+ virtual void set_time_next_pps(const time_spec_t &time_spec) = 0;
+
+ /*******************************************************************
* Streaming
******************************************************************/
- virtual void set_streaming(bool enb) = 0;
- virtual bool get_streaming(void) = 0;
+ virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0;
/*******************************************************************
* RX methods
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt
index 7f5db2128..14b5ccd29 100644
--- a/host/include/uhd/transport/CMakeLists.txt
+++ b/host/include/uhd/transport/CMakeLists.txt
@@ -17,9 +17,10 @@
INSTALL(FILES
+ if_addrs.hpp
smart_buffer.hpp
udp_simple.hpp
udp_zero_copy.hpp
vrt.hpp
- DESTINATION ${HEADER_DIR}/uhd/transport
+ DESTINATION ${INCLUDE_DIR}/uhd/transport
)
diff --git a/host/include/uhd/transport/if_addrs.hpp b/host/include/uhd/transport/if_addrs.hpp
new file mode 100644
index 000000000..fbbb35e1d
--- /dev/null
+++ b/host/include/uhd/transport/if_addrs.hpp
@@ -0,0 +1,47 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_IFADDRS_HPP
+#define INCLUDED_UHD_IFADDRS_HPP
+
+#include <uhd/config.hpp>
+#include <string>
+#include <vector>
+
+namespace uhd{ namespace transport{
+
+ /*!
+ * The address for a network interface.
+ */
+ struct UHD_API if_addrs_t{
+ std::string inet;
+ std::string mask;
+ std::string bcast;
+ if_addrs_t(void);
+ };
+
+ /*!
+ * Get a list of network interface addresses.
+ * The internal implementation is system-dependent.
+ * \return a vector of if addrs
+ */
+ UHD_API std::vector<if_addrs_t> get_if_addrs(void);
+
+}} //namespace
+
+
+#endif /* INCLUDED_UHD_IFADDRS_HPP */
diff --git a/host/include/uhd/transport/smart_buffer.hpp b/host/include/uhd/transport/smart_buffer.hpp
index 9e1032feb..a9bc259e9 100644
--- a/host/include/uhd/transport/smart_buffer.hpp
+++ b/host/include/uhd/transport/smart_buffer.hpp
@@ -18,7 +18,7 @@
#ifndef INCLUDED_UHD_TRANSPORT_SMART_BUFFER_HPP
#define INCLUDED_UHD_TRANSPORT_SMART_BUFFER_HPP
-#include <boost/asio.hpp>
+#include <boost/asio/buffer.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/host/include/uhd/transport/udp_simple.hpp b/host/include/uhd/transport/udp_simple.hpp
index 40e60d091..793ec4fd7 100644
--- a/host/include/uhd/transport/udp_simple.hpp
+++ b/host/include/uhd/transport/udp_simple.hpp
@@ -19,7 +19,7 @@
#define INCLUDED_UHD_TRANSPORT_UDP_SIMPLE_HPP
#include <uhd/config.hpp>
-#include <boost/asio.hpp>
+#include <boost/asio/buffer.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/host/include/uhd/transport/udp_zero_copy.hpp b/host/include/uhd/transport/udp_zero_copy.hpp
index 03d89b3a5..0441a8e74 100644
--- a/host/include/uhd/transport/udp_zero_copy.hpp
+++ b/host/include/uhd/transport/udp_zero_copy.hpp
@@ -20,7 +20,7 @@
#include <uhd/config.hpp>
#include <uhd/transport/smart_buffer.hpp>
-#include <boost/asio.hpp>
+#include <boost/asio/buffer.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/host/include/uhd/transport/vrt.hpp b/host/include/uhd/transport/vrt.hpp
index db2c57eba..04945b347 100644
--- a/host/include/uhd/transport/vrt.hpp
+++ b/host/include/uhd/transport/vrt.hpp
@@ -19,7 +19,7 @@
#define INCLUDED_UHD_TRANSPORT_VRT_HPP
#include <uhd/config.hpp>
-#include <uhd/metadata.hpp>
+#include <uhd/types/metadata.hpp>
#include <cstddef>
namespace uhd{ namespace transport{
diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt
new file mode 100644
index 000000000..e4cdf2cef
--- /dev/null
+++ b/host/include/uhd/types/CMakeLists.txt
@@ -0,0 +1,32 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+INSTALL(FILES
+ clock_config.hpp
+ device_addr.hpp
+ dict.hpp
+ io_type.hpp
+ mac_addr.hpp
+ metadata.hpp
+ otw_type.hpp
+ ranges.hpp
+ stream_cmd.hpp
+ time_spec.hpp
+ tune_result.hpp
+ DESTINATION ${INCLUDE_DIR}/uhd/types
+)
diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp
new file mode 100644
index 000000000..42d74ad90
--- /dev/null
+++ b/host/include/uhd/types/clock_config.hpp
@@ -0,0 +1,50 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_CLOCK_CONFIG_HPP
+#define INCLUDED_UHD_TYPES_CLOCK_CONFIG_HPP
+
+#include <uhd/config.hpp>
+
+namespace uhd{
+
+ /*!
+ * Clock configuration settings:
+ * The source for the 10MHz reference clock.
+ * The source and polarity for the PPS clock.
+ */
+ struct UHD_API clock_config_t{
+ enum ref_source_t {
+ REF_INT = 'i', //internal reference
+ REF_SMA = 's', //external sma port
+ REF_MIMO = 'm' //mimo cable (usrp2 only)
+ } ref_source;
+ enum pps_source_t {
+ PPS_INT = 'i', //there is no internal
+ PPS_SMA = 's', //external sma port
+ PPS_MIMO = 'm' //mimo cable (usrp2 only)
+ } pps_source;
+ enum pps_polarity_t {
+ PPS_NEG = 'n', //negative edge
+ PPS_POS = 'p' //positive edge
+ } pps_polarity;
+ clock_config_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_CLOCK_CONFIG_HPP */
diff --git a/host/include/uhd/types/device_addr.hpp b/host/include/uhd/types/device_addr.hpp
new file mode 100644
index 000000000..1162884fb
--- /dev/null
+++ b/host/include/uhd/types/device_addr.hpp
@@ -0,0 +1,70 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_DEVICE_ADDR_HPP
+#define INCLUDED_UHD_TYPES_DEVICE_ADDR_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/types/dict.hpp>
+#include <vector>
+#include <string>
+
+namespace uhd{
+
+ /*!
+ * Mapping of key/value pairs for locating devices on the system.
+ * When left empty, the device discovery routines will search
+ * all available transports on the system (ethernet, usb...).
+ *
+ * To narrow down the discovery process to a particular device,
+ * specify a transport key/value pair specific to your device.
+ * Ex, to find a usrp2: my_dev_addr["addr"] = <resolvable_hostname_or_ip>
+ *
+ * The device address can also be used to pass arguments into
+ * the transport layer control to set (for example) buffer sizes.
+ */
+ class UHD_API device_addr_t : public dict<std::string, std::string>{
+ public:
+
+ /*!
+ * Convert a device address into a printable string.
+ * \return string good for use with std::cout <<
+ */
+ std::string to_string(void) const;
+
+ /*!
+ * Convert the device address into an args string.
+ * The args string contains delimiter symbols.
+ * \return a string with delimiter markup
+ */
+ std::string to_args_str(void) const;
+
+ /*!
+ * Make a device address from an args string.
+ * The args string contains delimiter symbols.
+ * \param args_str the arguments string
+ * \return the new device address
+ */
+ static device_addr_t from_args_str(const std::string &args_str);
+ };
+
+ //handy typedef for a vector of device addresses
+ typedef std::vector<device_addr_t> device_addrs_t;
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_DEVICE_ADDR_HPP */
diff --git a/host/include/uhd/dict.hpp b/host/include/uhd/types/dict.hpp
index f08493952..7fb712e76 100644
--- a/host/include/uhd/dict.hpp
+++ b/host/include/uhd/types/dict.hpp
@@ -15,13 +15,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_DICT_HPP
-#define INCLUDED_UHD_DICT_HPP
+#ifndef INCLUDED_UHD_TYPES_DICT_HPP
+#define INCLUDED_UHD_TYPES_DICT_HPP
-#include <list>
-#include <vector>
-#include <stdexcept>
+#include <uhd/config.hpp>
#include <boost/foreach.hpp>
+#include <stdexcept>
+#include <vector>
+#include <list>
namespace uhd{
@@ -151,4 +152,4 @@ namespace uhd{
} //namespace uhd
-#endif /* INCLUDED_UHD_DICT_HPP */
+#endif /* INCLUDED_UHD_TYPES_DICT_HPP */
diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp
new file mode 100644
index 000000000..930394d1b
--- /dev/null
+++ b/host/include/uhd/types/io_type.hpp
@@ -0,0 +1,69 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_IO_TYPE_HPP
+#define INCLUDED_UHD_TYPES_IO_TYPE_HPP
+
+#include <uhd/config.hpp>
+
+namespace uhd{
+
+ /*!
+ * Used to specify the IO type with device send/recv.
+ */
+ class UHD_API io_type_t{
+ public:
+
+ /*!
+ * Built in IO types known to the system.
+ */
+ enum tid_t{
+ CUSTOM_TYPE = '?',
+ COMPLEX_FLOAT32 = 'f',
+ COMPLEX_INT16 = 's',
+ COMPLEX_INT8 = 'b'
+ };
+
+ /*!
+ * The size of this io type in bytes.
+ */
+ const size_t size;
+
+ /*!
+ * The type id of this io type.
+ * Good for using with switch statements.
+ */
+ const tid_t tid;
+
+ /*!
+ * Create an io type from a built-in type id.
+ * \param tid a type id known to the system
+ */
+ io_type_t(tid_t tid);
+
+ /*!
+ * Create an io type from attributes.
+ * The tid will be set to custom.
+ * \param size the size in bytes
+ */
+ io_type_t(size_t size);
+
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_IO_TYPE_HPP */
diff --git a/host/include/uhd/types/mac_addr.hpp b/host/include/uhd/types/mac_addr.hpp
new file mode 100644
index 000000000..3cd1fe86b
--- /dev/null
+++ b/host/include/uhd/types/mac_addr.hpp
@@ -0,0 +1,68 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_MAC_ADDR_HPP
+#define INCLUDED_UHD_TYPES_MAC_ADDR_HPP
+
+#include <uhd/config.hpp>
+#include <boost/cstdint.hpp>
+#include <string>
+
+namespace uhd{
+
+ /*!
+ * Wrapper for an ethernet mac address.
+ * Provides conversion between string and binary formats.
+ */
+ class UHD_API mac_addr_t{
+ public:
+ static const size_t hlen = 6;
+
+ /*!
+ * Create a mac address a byte array.
+ * \param bytes a pointer for the byte array
+ * \return a new mac address
+ */
+ static mac_addr_t from_bytes(const boost::uint8_t *bytes);
+
+ /*!
+ * Create a mac address from a string.
+ * \param mac_addr_str the string with delimiters
+ * \return a new mac address
+ */
+ static mac_addr_t from_string(const std::string &mac_addr_str);
+
+ /*!
+ * Get the byte representation of the mac address.
+ * \return a pointer to the internal byte array
+ */
+ const boost::uint8_t *to_bytes(void) const;
+
+ /*!
+ * Get the string representation of this mac address.
+ * \return a string with delimiters
+ */
+ std::string to_string(void) const;
+
+ private:
+ mac_addr_t(const boost::uint8_t *bytes); //private constructor
+ boost::uint8_t _bytes[hlen]; //internal representation
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_MAC_ADDR_HPP */
diff --git a/host/include/uhd/types/metadata.hpp b/host/include/uhd/types/metadata.hpp
new file mode 100644
index 000000000..6e93040d9
--- /dev/null
+++ b/host/include/uhd/types/metadata.hpp
@@ -0,0 +1,61 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_METADATA_HPP
+#define INCLUDED_UHD_TYPES_METADATA_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/types/time_spec.hpp>
+
+namespace uhd{
+
+ /*!
+ * RX metadata structure for describing sent IF data.
+ * Includes stream ID, time specification, and fragmentation flags.
+ * The receive routines will convert IF data headers into metadata.
+ */
+ struct UHD_API rx_metadata_t{
+ boost::uint32_t stream_id;
+ time_spec_t time_spec;
+ bool has_stream_id;
+ bool has_time_spec;
+ bool is_fragment;
+
+ //default constructor
+ rx_metadata_t(void);
+ };
+
+ /*!
+ * TX metadata structure for describing received IF data.
+ * Includes stream ID, time specification, and burst flags.
+ * The send routines will convert the metadata to IF data headers.
+ */
+ struct UHD_API tx_metadata_t{
+ boost::uint32_t stream_id;
+ time_spec_t time_spec;
+ bool has_stream_id;
+ bool has_time_spec;
+ bool start_of_burst;
+ bool end_of_burst;
+
+ //default constructor
+ tx_metadata_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_METADATA_HPP */
diff --git a/host/include/uhd/types/otw_type.hpp b/host/include/uhd/types/otw_type.hpp
new file mode 100644
index 000000000..f10664584
--- /dev/null
+++ b/host/include/uhd/types/otw_type.hpp
@@ -0,0 +1,63 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_OTW_TYPE_HPP
+#define INCLUDED_UHD_TYPES_OTW_TYPE_HPP
+
+#include <uhd/config.hpp>
+
+namespace uhd{
+
+ /*!
+ * Description for over-the-wire integers:
+ * The DSP units in the FPGA deal with signed 16-bit integers.
+ * The width and shift define the translation between OTW and DSP,
+ * defined by the following relation: otw_int = dsp_int >> shift
+ *
+ * Note: possible combinations of width, shift, and byteorder
+ * depend on the internals of the FPGA. Not all are supported!
+ */
+ struct UHD_API otw_type_t{
+
+ /*!
+ * Width of an over-the-wire integer in bits.
+ */
+ size_t width; //in bits
+
+ /*!
+ * Shift of an over-the-wire integer in bits.
+ * otw_int = dsp_int >> shift
+ * dsp_int = otw_int << shift
+ */
+ size_t shift; //in bits
+
+ /*!
+ * Constants for byte order (borrowed from numpy's dtype)
+ */
+ enum /*bo_t*/ {
+ BO_NATIVE = '=',
+ BO_LITTLE_ENDIAN = '<',
+ BO_BIG_ENDIAN = '>',
+ BO_NOT_APPLICABLE = '|'
+ } byteorder;
+
+ otw_type_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_OTW_TYPE_HPP */
diff --git a/host/include/uhd/types.hpp b/host/include/uhd/types/ranges.hpp
index 1439f57a1..a2057d1c8 100644
--- a/host/include/uhd/types.hpp
+++ b/host/include/uhd/types/ranges.hpp
@@ -15,17 +15,13 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_TYPES_HPP
-#define INCLUDED_UHD_TYPES_HPP
+#ifndef INCLUDED_UHD_TYPES_RANGES_HPP
+#define INCLUDED_UHD_TYPES_RANGES_HPP
#include <uhd/config.hpp>
-#include <string>
namespace uhd{
- typedef float gain_t; //TODO REMOVE
- typedef double freq_t; //TODO REMOVE
-
/*!
* The gain range struct describes possible gain settings.
* The mimumum gain, maximum gain, and step size are in dB.
@@ -45,39 +41,6 @@ namespace uhd{
freq_range_t(double min = 0.0, double max = 0.0);
};
- /*!
- * The tune result struct holds result of a 2-phase tuning:
- * The struct hold the result of tuning the dboard as
- * the target and actual intermediate frequency.
- * The struct hold the result of tuning the DDC/DUC as
- * the target and actual digital converter frequency.
- * It also tell us weather or not the spectrum is inverted.
- */
- struct UHD_API tune_result_t{
- double target_inter_freq;
- double actual_inter_freq;
- double target_dxc_freq;
- double actual_dxc_freq;
- bool spectrum_inverted;
- tune_result_t(void);
- };
-
- /*!
- * Clock configuration settings:
- * The source for the 10MHz reference clock.
- * The source and polarity for the PPS clock.
- * Possible settings for the reference and pps source
- * are implementation specific motherboard properties.
- * See the MBOARD_PROP_XXX_SOURCE_NAMES properties.
- */
- struct clock_config_t{
- enum polarity_t {POLARITY_NEG, POLARITY_POS};
- std::string ref_source;
- std::string pps_source;
- polarity_t pps_polarity;
- clock_config_t(void);
- };
-
} //namespace uhd
-#endif /* INCLUDED_UHD_TYPES_HPP */
+#endif /* INCLUDED_UHD_TYPES_RANGES_HPP */
diff --git a/host/include/uhd/types/stream_cmd.hpp b/host/include/uhd/types/stream_cmd.hpp
new file mode 100644
index 000000000..97a6b73ce
--- /dev/null
+++ b/host/include/uhd/types/stream_cmd.hpp
@@ -0,0 +1,56 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_STREAM_CMD_HPP
+#define INCLUDED_UHD_TYPES_STREAM_CMD_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/types/time_spec.hpp>
+
+namespace uhd{
+
+ /*!
+ * Command struct for configuration and control of streaming:
+ *
+ * A stream command defines how the device sends samples to the host.
+ * Streaming is controlled by submitting a stream command to the rx dsp.
+ * Granular control over what the device streams to the host can be
+ * achieved through submission of multiple (carefully-crafted) commands.
+ *
+ * The stream_now parameter controls when the stream begins.
+ * When true, the device will begin streaming ASAP. When false,
+ * the device will begin streaming at a time specified by time_spec.
+ *
+ * The continuous parameter controls the number of samples received.
+ * When true, the device continues streaming indefinitely. When false,
+ * the device will stream the number of samples specified by num_samps.
+ *
+ * Standard usage case:
+ * To start continuous streaming, set stream_now to true and continuous to true.
+ * To end continuous streaming, set stream_now to true and continuous to false.
+ */
+ struct UHD_API stream_cmd_t{
+ bool stream_now;
+ time_spec_t time_spec;
+ bool continuous;
+ size_t num_samps;
+ stream_cmd_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_STREAM_CMD_HPP */
diff --git a/host/include/uhd/time_spec.hpp b/host/include/uhd/types/time_spec.hpp
index c1e7cf3a1..8c8f2bc25 100644
--- a/host/include/uhd/time_spec.hpp
+++ b/host/include/uhd/types/time_spec.hpp
@@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_TIME_SPEC_HPP
-#define INCLUDED_UHD_TIME_SPEC_HPP
+#ifndef INCLUDED_UHD_TYPES_TIME_SPEC_HPP
+#define INCLUDED_UHD_TYPES_TIME_SPEC_HPP
#include <uhd/config.hpp>
#include <boost/cstdint.hpp>
@@ -35,17 +35,11 @@ namespace uhd{
boost::uint32_t ticks;
/*!
- * Create a time_spec_t that holds a wildcard time.
- * This will have implementation-specific meaning.
- */
- time_spec_t(void);
-
- /*!
* Create a time_spec_t from seconds and ticks.
- * \param new_secs the new seconds
+ * \param new_secs the new seconds (default = 0)
* \param new_ticks the new ticks (default = 0)
*/
- time_spec_t(boost::uint32_t new_secs, boost::uint32_t new_ticks = 0);
+ time_spec_t(boost::uint32_t new_secs = 0, boost::uint32_t new_ticks = 0);
/*!
* Create a time_spec_t from boost posix time.
@@ -58,4 +52,4 @@ namespace uhd{
} //namespace uhd
-#endif /* INCLUDED_UHD_TIME_SPEC_HPP */
+#endif /* INCLUDED_UHD_TYPES_TIME_SPEC_HPP */
diff --git a/host/include/uhd/types/tune_result.hpp b/host/include/uhd/types/tune_result.hpp
new file mode 100644
index 000000000..31742e1af
--- /dev/null
+++ b/host/include/uhd/types/tune_result.hpp
@@ -0,0 +1,44 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_TUNE_RESULT_HPP
+#define INCLUDED_UHD_TYPES_TUNE_RESULT_HPP
+
+#include <uhd/config.hpp>
+
+namespace uhd{
+
+ /*!
+ * The tune result struct holds result of a 2-phase tuning:
+ * The struct hold the result of tuning the dboard as
+ * the target and actual intermediate frequency.
+ * The struct hold the result of tuning the DDC/DUC as
+ * the target and actual digital converter frequency.
+ * It also tell us weather or not the spectrum is inverted.
+ */
+ struct UHD_API tune_result_t{
+ double target_inter_freq;
+ double actual_inter_freq;
+ double target_dxc_freq;
+ double actual_dxc_freq;
+ bool spectrum_inverted;
+ tune_result_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_TUNE_RESULT_HPP */
diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt
index 4e0a92365..bab01fdeb 100644
--- a/host/include/uhd/usrp/CMakeLists.txt
+++ b/host/include/uhd/usrp/CMakeLists.txt
@@ -23,5 +23,5 @@ INSTALL(FILES
dboard_manager.hpp
usrp1e.hpp
usrp2.hpp
- DESTINATION ${HEADER_DIR}/uhd/usrp
+ DESTINATION ${INCLUDE_DIR}/uhd/usrp
)
diff --git a/host/include/uhd/usrp/dboard_id.hpp b/host/include/uhd/usrp/dboard_id.hpp
index 4b2392bee..afacaf8ff 100644
--- a/host/include/uhd/usrp/dboard_id.hpp
+++ b/host/include/uhd/usrp/dboard_id.hpp
@@ -26,8 +26,6 @@ namespace uhd{ namespace usrp{
typedef boost::uint16_t dboard_id_t;
-static const dboard_id_t ID_NONE = 0xffff; //TODO: REMOVE ME
-
namespace dboard_id{
static const dboard_id_t NONE = 0xffff;
UHD_API std::string to_string(const dboard_id_t &id);
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp
index 6a105d1de..c7c091220 100644
--- a/host/include/uhd/usrp/dboard_manager.hpp
+++ b/host/include/uhd/usrp/dboard_manager.hpp
@@ -42,7 +42,7 @@ public:
/*!
* Register a dboard into the system.
- *
+ * For single subdevice boards, omit subdev_names.
* \param dboard_id the dboard id (rx or tx)
* \param dboard_ctor the dboard constructor function pointer
* \param name the canonical name for the dboard represented
@@ -52,7 +52,7 @@ public:
dboard_id_t dboard_id,
dboard_ctor_t dboard_ctor,
const std::string &name,
- const prop_names_t &subdev_names
+ const prop_names_t &subdev_names = prop_names_t(1, "")
);
/*!
diff --git a/host/include/uhd/usrp/usrp1e.hpp b/host/include/uhd/usrp/usrp1e.hpp
index f4cc39d8e..75da58453 100644
--- a/host/include/uhd/usrp/usrp1e.hpp
+++ b/host/include/uhd/usrp/usrp1e.hpp
@@ -29,12 +29,11 @@ namespace uhd{ namespace usrp{
class UHD_API usrp1e : public device{
public:
/*!
- * Discover usrp1e devices on the system via the device node.
- * This static method will be called by the device::discover.
+ * Find usrp1e devices on the system via the device node.
* \param hint a device addr with the usrp1e address filled in
* \return a vector of device addresses for all usrp1es found
*/
- static device_addrs_t discover(const device_addr_t &hint);
+ static device_addrs_t find(const device_addr_t &hint);
/*!
* Make a usrp1e from a device address.
diff --git a/host/include/uhd/usrp/usrp2.hpp b/host/include/uhd/usrp/usrp2.hpp
index 277ddc131..613b40ae3 100644
--- a/host/include/uhd/usrp/usrp2.hpp
+++ b/host/include/uhd/usrp/usrp2.hpp
@@ -29,17 +29,16 @@ namespace uhd{ namespace usrp{
class UHD_API usrp2 : public device{
public:
/*!
- * Discover usrp2 devices over the ethernet.
+ * Find usrp2 devices over the ethernet.
*
* Recommended key/value pairs for the device hint address:
* hint["addr"] = address, where address is a resolvable address
* or ip address, which may or may not be a broadcast address.
*
- * This static method will be called by the device::discover.
* \param hint a device addr with the usrp2 address filled in
* \return a vector of device addresses for all usrp2s found
*/
- static device_addrs_t discover(const device_addr_t &hint);
+ static device_addrs_t find(const device_addr_t &hint);
/*!
* Make a usrp2 from a device address.
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
new file mode 100644
index 000000000..1b673f44a
--- /dev/null
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -0,0 +1,26 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+INSTALL(FILES
+ algorithm.hpp
+ assert.hpp
+ gain_handler.hpp
+ safe_main.hpp
+ static.hpp
+ tune_helper.hpp
+ DESTINATION ${INCLUDE_DIR}/uhd/utils
+)
diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp
new file mode 100644
index 000000000..6635c8a4a
--- /dev/null
+++ b/host/include/uhd/utils/algorithm.hpp
@@ -0,0 +1,60 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_ALGORITHM_HPP
+#define INCLUDED_UHD_UTILS_ALGORITHM_HPP
+
+#include <algorithm>
+
+/*!
+ * Useful templated functions and classes that I like to pretend are part of stl
+ */
+namespace std{
+
+ template<class T, class InputIterator, class Function>
+ T reduce(InputIterator first, InputIterator last, Function fcn, T init = 0){
+ T tmp = init;
+ for ( ; first != last; ++first ){
+ tmp = fcn(tmp, *first);
+ }
+ return tmp;
+ }
+
+ template<class T, class Iterable, class Function>
+ T reduce(Iterable iterable, Function fcn, T init = 0){
+ return reduce(iterable.begin(), iterable.end(), fcn, init);
+ }
+
+ template<class T, class InputIterator>
+ bool has(InputIterator first, InputIterator last, const T &elem){
+ return last != std::find(first, last, elem);
+ }
+
+ template<class T, class Iterable>
+ bool has(const Iterable &iterable, const T &elem){
+ return has(iterable.begin(), iterable.end(), elem);
+ }
+
+ template<typename T> T signum(T n){
+ if (n < 0) return -1;
+ if (n > 0) return 1;
+ return 0;
+ }
+
+}//namespace std
+
+#endif /* INCLUDED_UHD_UTILS_ALGORITHM_HPP */
diff --git a/host/include/uhd/utils.hpp b/host/include/uhd/utils/assert.hpp
index e5333539f..842ed8dfa 100644
--- a/host/include/uhd/utils.hpp
+++ b/host/include/uhd/utils/assert.hpp
@@ -15,85 +15,31 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_UTILS_HPP
-#define INCLUDED_UHD_UTILS_HPP
+#ifndef INCLUDED_UHD_UTILS_ASSERT_HPP
+#define INCLUDED_UHD_UTILS_ASSERT_HPP
-#include <uhd/config.hpp>
+#include <uhd/utils/algorithm.hpp>
#include <boost/format.hpp>
+#include <boost/foreach.hpp>
+#include <boost/lexical_cast.hpp>
#include <boost/current_function.hpp>
#include <stdexcept>
-#include <algorithm>
-
-/*!
- * Defines a function that implements the "construct on first use" idiom
- * \param _t the type definition for the instance
- * \param _x the name of the defined function
- * \return a reference to the lazy instance
- */
-#define STATIC_INSTANCE(_t, _x) static _t &_x(){static _t _x; return _x;}
-/*!
- * Defines a static code block that will be called before main()
- * \param _x the name of the defined struct (must be unique in file)
- */
-#define STATIC_BLOCK(_x) static struct _x{_x();}_x;_x::_x()
-
-/*!
- * Useful templated functions and classes that I like to pretend are part of stl
- */
-namespace std{
+namespace uhd{
class assert_error : public std::logic_error{
public:
- explicit assert_error(const string& what_arg) : logic_error(what_arg){
+ explicit assert_error(const std::string& what_arg) : logic_error(what_arg){
/* NOP */
}
};
#define ASSERT_THROW(_x) if (not (_x)) { \
- throw std::assert_error(str(boost::format( \
+ throw uhd::assert_error(str(boost::format( \
"Assertion Failed:\n %s:%d\n %s\n ---> %s <---" \
) % __FILE__ % __LINE__ % BOOST_CURRENT_FUNCTION % std::string(#_x))); \
}
- template<class T, class InputIterator, class Function>
- T reduce(InputIterator first, InputIterator last, Function fcn, T init = 0){
- T tmp = init;
- for ( ; first != last; ++first ){
- tmp = fcn(tmp, *first);
- }
- return tmp;
- }
-
- template<class T, class Iterable, class Function>
- T reduce(Iterable iterable, Function fcn, T init = 0){
- return reduce(iterable.begin(), iterable.end(), fcn, init);
- }
-
- template<class T, class InputIterator>
- bool has(InputIterator first, InputIterator last, const T &elem){
- return last != std::find(first, last, elem);
- }
-
- template<class T, class Iterable>
- bool has(const Iterable &iterable, const T &elem){
- return has(iterable.begin(), iterable.end(), elem);
- }
-
- template<typename T> T signum(T n){
- if (n < 0) return -1;
- if (n > 0) return 1;
- return 0;
- }
-
-}//namespace std
-
-#include <boost/format.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
-
-namespace uhd{
-
/*!
* Check that an element is found in a container.
* If not, throw a meaningful assertion error.
@@ -116,7 +62,7 @@ namespace uhd{
if (e != iterable.begin()[0]) possible_values += ", ";
possible_values += boost::lexical_cast<std::string>(e);
}
- throw std::assert_error(str(boost::format(
+ throw uhd::assert_error(str(boost::format(
"Error: %s is not a valid %s. "
"Possible values are: [%s]."
)
@@ -127,4 +73,4 @@ namespace uhd{
}//namespace uhd
-#endif /* INCLUDED_UHD_UTILS_HPP */
+#endif /* INCLUDED_UHD_UTILS_ASSERT_HPP */
diff --git a/host/include/uhd/gain_handler.hpp b/host/include/uhd/utils/gain_handler.hpp
index 65d6cecf9..f4629e6a7 100644
--- a/host/include/uhd/gain_handler.hpp
+++ b/host/include/uhd/utils/gain_handler.hpp
@@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_GAIN_HANDLER_HPP
-#define INCLUDED_UHD_GAIN_HANDLER_HPP
+#ifndef INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP
+#define INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
@@ -86,5 +86,5 @@ public:
} //namespace uhd
-#endif /* INCLUDED_UHD_GAIN_HANDLER_HPP */
+#endif /* INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP */
diff --git a/host/include/uhd/utils/safe_main.hpp b/host/include/uhd/utils/safe_main.hpp
new file mode 100644
index 000000000..b682aa540
--- /dev/null
+++ b/host/include/uhd/utils/safe_main.hpp
@@ -0,0 +1,44 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
+#define INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
+
+#include <uhd/config.hpp>
+#include <iostream>
+#include <stdexcept>
+
+/*!
+ * Defines a safe wrapper that places a catch-all around main.
+ * If an exception is thrown, it prints to stderr and returns.
+ * Usage: int UHD_SAFE_MAIN(int argc, char *argv[]){ main code here }
+ * \param _argc the declaration for argc
+ * \param _argv the declaration for argv
+ */
+#define UHD_SAFE_MAIN(_argc, _argv) _main(int, char*[]); \
+int main(int argc, char *argv[]){ \
+ try { \
+ return _main(argc, argv); \
+ } catch(const std::exception &e) { \
+ std::cerr << "Error: " << e.what() << std::endl; \
+ } catch(...) { \
+ std::cerr << "Error: unknown exception" << std::endl; \
+ } \
+ return ~0; \
+} int _main(_argc, _argv)
+
+#endif /* INCLUDED_UHD_UTILS_SAFE_MAIN_HPP */
diff --git a/host/include/uhd/utils/static.hpp b/host/include/uhd/utils/static.hpp
new file mode 100644
index 000000000..c61f10884
--- /dev/null
+++ b/host/include/uhd/utils/static.hpp
@@ -0,0 +1,37 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_STATIC_HPP
+#define INCLUDED_UHD_UTILS_STATIC_HPP
+
+#include <uhd/config.hpp>
+
+/*!
+ * Defines a function that implements the "construct on first use" idiom
+ * \param _t the type definition for the instance
+ * \param _x the name of the defined function
+ * \return a reference to the lazy instance
+ */
+#define UHD_SINGLETON_FCN(_t, _x) static _t &_x(){static _t _x; return _x;}
+
+/*!
+ * Defines a static code block that will be called before main()
+ * \param _x the name of the defined struct (must be unique in file)
+ */
+#define UHD_STATIC_BLOCK(_x) static struct _x{_x();}_x;_x::_x()
+
+#endif /* INCLUDED_UHD_UTILS_STATIC_HPP */
diff --git a/host/include/uhd/utils/tune_helper.hpp b/host/include/uhd/utils/tune_helper.hpp
new file mode 100644
index 000000000..958d1eceb
--- /dev/null
+++ b/host/include/uhd/utils/tune_helper.hpp
@@ -0,0 +1,79 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_TUNE_HELPER_HPP
+#define INCLUDED_UHD_UTILS_TUNE_HELPER_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/wax.hpp>
+#include <uhd/types/tune_result.hpp>
+
+namespace uhd{
+
+/*!
+ * Tune a rx chain to the desired frequency:
+ * The IF of the subdevice is set as close as possible to
+ * the given target frequency + the LO offset (when applicable).
+ * The ddc cordic is setup to bring the IF down to baseband.
+ * \param subdev the dboard subdevice object with properties
+ * \param ddc the ddc properties object (with "if_rate", "bb_rate", "freq")
+ * \param target_freq the desired center frequency
+ * \param lo_offset an offset for the subdevice IF from center
+ * \return a tune result struct
+ */
+UHD_API tune_result_t tune_rx_subdev_and_ddc(
+ wax::obj subdev, wax::obj ddc,
+ double target_freq, double lo_offset
+);
+
+/*!
+ * Tune a rx chain to the desired frequency:
+ * Same as the above, except the LO offset
+ * is calculated based on the subdevice and BW.
+ */
+UHD_API tune_result_t tune_rx_subdev_and_ddc(
+ wax::obj subdev, wax::obj ddc, double target_freq
+);
+
+/*!
+ * Tune a tx chain to the desired frequency:
+ * The IF of the subdevice is set as close as possible to
+ * the given target frequency + the LO offset (when applicable).
+ * The duc cordic is setup to bring the baseband up to IF.
+ * \param subdev the dboard subdevice object with properties
+ * \param duc the duc properties object (with "if_rate", "bb_rate", "freq")
+ * \param target_freq the desired center frequency
+ * \param lo_offset an offset for the subdevice IF from center
+ * \return a tune result struct
+ */
+UHD_API tune_result_t tune_tx_subdev_and_duc(
+ wax::obj subdev, wax::obj duc,
+ double target_freq, double lo_offset
+);
+
+/*!
+ * Tune a tx chain to the desired frequency:
+ * Same as the above, except the LO offset
+ * is calculated based on the subdevice and BW.
+ */
+UHD_API tune_result_t tune_tx_subdev_and_duc(
+ wax::obj subdev, wax::obj duc, double target_freq
+);
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_UTILS_TUNE_HELPER_HPP */
diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp
index 30645f491..14e6734a5 100644
--- a/host/include/uhd/wax.hpp
+++ b/host/include/uhd/wax.hpp
@@ -38,6 +38,10 @@
*
* Property nesting occurs when a WAX object gets another object's link.
* This special link is obtained through a call to my_obj.get_link().
+ *
+ * Note: Do not put a class derived from wax::obj into an stl container.
+ * MSVC will compile the code, but the binaries will crash at runtime.
+ * Rather, use pointers or smart pointers to instances of the derived class.
*/
namespace wax{