aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/build_info.hpp39
-rw-r--r--host/include/uhd/cal/container.hpp34
-rw-r--r--host/include/uhd/cal/power_container.hpp19
-rw-r--r--host/include/uhd/config.hpp133
-rw-r--r--host/include/uhd/convert.hpp177
-rw-r--r--host/include/uhd/deprecated.hpp82
-rw-r--r--host/include/uhd/device.hpp43
-rw-r--r--host/include/uhd/device3.hpp50
-rw-r--r--host/include/uhd/exception.hpp398
-rw-r--r--host/include/uhd/image_loader.hpp34
-rw-r--r--host/include/uhd/property_tree.hpp67
-rw-r--r--host/include/uhd/rfnoc/block_ctrl.hpp8
-rw-r--r--host/include/uhd/rfnoc/block_ctrl_base.hpp124
-rw-r--r--host/include/uhd/rfnoc/block_id.hpp392
-rw-r--r--host/include/uhd/rfnoc/blockdef.hpp23
-rw-r--r--host/include/uhd/rfnoc/constants.hpp78
-rw-r--r--host/include/uhd/rfnoc/ddc_block_ctrl.hpp16
-rw-r--r--host/include/uhd/rfnoc/dma_fifo_block_ctrl.hpp11
-rw-r--r--host/include/uhd/rfnoc/duc_block_ctrl.hpp17
-rw-r--r--host/include/uhd/rfnoc/fir_block_ctrl.hpp10
-rw-r--r--host/include/uhd/rfnoc/graph.hpp44
-rw-r--r--host/include/uhd/rfnoc/node_ctrl_base.hpp81
-rw-r--r--host/include/uhd/rfnoc/null_block_ctrl.hpp11
-rw-r--r--host/include/uhd/rfnoc/radio_ctrl.hpp122
-rw-r--r--host/include/uhd/rfnoc/rate_node_ctrl.hpp10
-rw-r--r--host/include/uhd/rfnoc/replay_block_ctrl.hpp22
-rw-r--r--host/include/uhd/rfnoc/scalar_node_ctrl.hpp9
-rw-r--r--host/include/uhd/rfnoc/siggen_block_ctrl.hpp8
-rw-r--r--host/include/uhd/rfnoc/sink_block_ctrl_base.hpp22
-rw-r--r--host/include/uhd/rfnoc/sink_node_ctrl.hpp30
-rw-r--r--host/include/uhd/rfnoc/source_block_ctrl_base.hpp58
-rw-r--r--host/include/uhd/rfnoc/source_node_ctrl.hpp34
-rw-r--r--host/include/uhd/rfnoc/stream_sig.hpp13
-rw-r--r--host/include/uhd/rfnoc/terminator_node_ctrl.hpp3
-rw-r--r--host/include/uhd/rfnoc/tick_node_ctrl.hpp15
-rw-r--r--host/include/uhd/rfnoc/traffic_counter.hpp44
-rw-r--r--host/include/uhd/rfnoc/window_block_ctrl.hpp20
-rw-r--r--host/include/uhd/stream.hpp88
-rw-r--r--host/include/uhd/transport/bounded_buffer.hpp177
-rw-r--r--host/include/uhd/transport/buffer_pool.hpp62
-rw-r--r--host/include/uhd/transport/chdr.hpp107
-rw-r--r--host/include/uhd/transport/if_addrs.hpp39
-rw-r--r--host/include/uhd/transport/muxed_zero_copy_if.hpp13
-rw-r--r--host/include/uhd/transport/nirio/rpc/rpc_client.hpp62
-rw-r--r--host/include/uhd/transport/nirio/rpc/rpc_common.hpp105
-rw-r--r--host/include/uhd/transport/nirio/rpc/usrprio_rpc_client.hpp42
-rw-r--r--host/include/uhd/transport/nirio/rpc/usrprio_rpc_common.hpp60
-rw-r--r--host/include/uhd/transport/nirio_zero_copy.hpp19
-rw-r--r--host/include/uhd/transport/tcp_zero_copy.hpp12
-rw-r--r--host/include/uhd/transport/udp_constants.hpp5
-rw-r--r--host/include/uhd/transport/udp_simple.hpp21
-rw-r--r--host/include/uhd/transport/udp_zero_copy.hpp24
-rw-r--r--host/include/uhd/transport/usb_control.hpp17
-rw-r--r--host/include/uhd/transport/usb_device_handle.hpp17
-rw-r--r--host/include/uhd/transport/usb_zero_copy.hpp11
-rw-r--r--host/include/uhd/transport/vrt_if_packet.hpp370
-rw-r--r--host/include/uhd/transport/zero_copy.hpp345
-rw-r--r--host/include/uhd/transport/zero_copy_flow_ctrl.hpp18
-rw-r--r--host/include/uhd/transport/zero_copy_recv_offload.hpp10
-rw-r--r--host/include/uhd/types/byte_vector.hpp25
-rw-r--r--host/include/uhd/types/clock_config.hpp85
-rw-r--r--host/include/uhd/types/component_file.hpp37
-rw-r--r--host/include/uhd/types/device_addr.hpp132
-rw-r--r--host/include/uhd/types/dict.hpp260
-rw-r--r--host/include/uhd/types/direction.hpp18
-rw-r--r--host/include/uhd/types/eeprom.hpp2
-rw-r--r--host/include/uhd/types/endianness.hpp9
-rw-r--r--host/include/uhd/types/filters.hpp440
-rw-r--r--host/include/uhd/types/io_type.hpp93
-rw-r--r--host/include/uhd/types/mac_addr.hpp77
-rw-r--r--host/include/uhd/types/metadata.hpp314
-rw-r--r--host/include/uhd/types/otw_type.hpp2
-rw-r--r--host/include/uhd/types/ranges.hpp170
-rw-r--r--host/include/uhd/types/ref_vector.hpp29
-rw-r--r--host/include/uhd/types/sensors.hpp249
-rw-r--r--host/include/uhd/types/serial.hpp328
-rw-r--r--host/include/uhd/types/sid.hpp466
-rw-r--r--host/include/uhd/types/stream_cmd.hpp74
-rw-r--r--host/include/uhd/types/time_spec.hpp225
-rw-r--r--host/include/uhd/types/tune_request.hpp164
-rw-r--r--host/include/uhd/types/tune_result.hpp113
-rw-r--r--host/include/uhd/types/wb_iface.hpp5
-rw-r--r--host/include/uhd/usrp/dboard_base.hpp30
-rw-r--r--host/include/uhd/usrp/dboard_eeprom.hpp15
-rw-r--r--host/include/uhd/usrp/dboard_id.hpp117
-rw-r--r--host/include/uhd/usrp/dboard_iface.hpp63
-rw-r--r--host/include/uhd/usrp/dboard_manager.hpp99
-rw-r--r--host/include/uhd/usrp/fe_connection.hpp198
-rw-r--r--host/include/uhd/usrp/gpio_defs.hpp14
-rw-r--r--host/include/uhd/usrp/gps_ctrl.hpp52
-rw-r--r--host/include/uhd/usrp/mboard_eeprom.hpp26
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp346
-rw-r--r--host/include/uhd/usrp/subdev_spec.hpp116
-rw-r--r--host/include/uhd/usrp_clock/multi_usrp_clock.hpp17
-rw-r--r--host/include/uhd/usrp_clock/octoclock_eeprom.hpp9
-rw-r--r--host/include/uhd/utils/algorithm.hpp122
-rw-r--r--host/include/uhd/utils/assert_has.hpp33
-rw-r--r--host/include/uhd/utils/byteswap.hpp44
-rw-r--r--host/include/uhd/utils/cast.hpp33
-rw-r--r--host/include/uhd/utils/csv.hpp16
-rw-r--r--host/include/uhd/utils/dirty_tracked.hpp201
-rw-r--r--host/include/uhd/utils/gain_group.hpp30
-rw-r--r--host/include/uhd/utils/log.hpp297
-rw-r--r--host/include/uhd/utils/log_add.hpp30
-rw-r--r--host/include/uhd/utils/math.hpp380
-rw-r--r--host/include/uhd/utils/msg_task.hpp91
-rw-r--r--host/include/uhd/utils/paths.hpp110
-rw-r--r--host/include/uhd/utils/pimpl.hpp6
-rw-r--r--host/include/uhd/utils/platform.hpp14
-rw-r--r--host/include/uhd/utils/safe_call.hpp18
-rw-r--r--host/include/uhd/utils/safe_main.hpp25
-rw-r--r--host/include/uhd/utils/soft_register.hpp350
-rw-r--r--host/include/uhd/utils/static.hpp16
-rw-r--r--host/include/uhd/utils/tasks.hpp47
-rw-r--r--host/include/uhd/utils/thread.hpp81
115 files changed, 5170 insertions, 5118 deletions
diff --git a/host/include/uhd/build_info.hpp b/host/include/uhd/build_info.hpp
index 7bac2e89e..88de3ea27 100644
--- a/host/include/uhd/build_info.hpp
+++ b/host/include/uhd/build_info.hpp
@@ -8,37 +8,36 @@
#define INCLUDED_UHD_BUILD_INFO_HPP
#include <uhd/config.hpp>
-
#include <string>
namespace uhd { namespace build_info {
- //! Return the version of Boost this build was built with.
- UHD_API const std::string boost_version();
+//! Return the version of Boost this build was built with.
+UHD_API const std::string boost_version();
- //! Return the date and time (GMT) this UHD build was built.
- UHD_API const std::string build_date();
+//! Return the date and time (GMT) this UHD build was built.
+UHD_API const std::string build_date();
- //! Return the C compiler used for this build.
- UHD_API const std::string c_compiler();
+//! Return the C compiler used for this build.
+UHD_API const std::string c_compiler();
- //! Return the C++ compiler used for this build.
- UHD_API const std::string cxx_compiler();
+//! Return the C++ compiler used for this build.
+UHD_API const std::string cxx_compiler();
- //! Return the C flags passed into this build.
- UHD_API const std::string c_flags();
+//! Return the C flags passed into this build.
+UHD_API const std::string c_flags();
- //! Return the C++ flags passed into this build.
- UHD_API const std::string cxx_flags();
+//! Return the C++ flags passed into this build.
+UHD_API const std::string cxx_flags();
- //! Return the UHD components enabled for this build, comma-delimited.
- UHD_API const std::string enabled_components();
+//! Return the UHD components enabled for this build, comma-delimited.
+UHD_API const std::string enabled_components();
- //! Return the default CMake install prefix for this build.
- UHD_API const std::string install_prefix();
+//! Return the default CMake install prefix for this build.
+UHD_API const std::string install_prefix();
- //! Return the version of libusb this build was built with.
- UHD_API const std::string libusb_version();
-}}
+//! Return the version of libusb this build was built with.
+UHD_API const std::string libusb_version();
+}} // namespace uhd::build_info
#endif /* INCLUDED_UHD_BUILD_INFO_HPP */
diff --git a/host/include/uhd/cal/container.hpp b/host/include/uhd/cal/container.hpp
index 5e6c612d8..75ce566e2 100644
--- a/host/include/uhd/cal/container.hpp
+++ b/host/include/uhd/cal/container.hpp
@@ -9,18 +9,18 @@
#define INCLUDED_UHD_CAL_CONTAINER_HPP
#include <uhd/config.hpp>
-#include <boost/serialization/serialization.hpp>
-#include <boost/serialization/vector.hpp>
-#include <boost/serialization/string.hpp>
-#include <boost/serialization/map.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
+#include <boost/serialization/map.hpp>
+#include <boost/serialization/serialization.hpp>
+#include <boost/serialization/string.hpp>
+#include <boost/serialization/vector.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd {
-namespace cal {
+namespace uhd { namespace cal {
-class base_container {
+class base_container
+{
public:
typedef std::map<std::string, std::string> metadata_t;
typedef boost::shared_ptr<base_container> sptr;
@@ -37,8 +37,9 @@ public:
* The container only supports inputs of the same type to be mapped.
*
*/
-template<typename in_type, typename out_type>
-class UHD_API cal_container : public base_container {
+template <typename in_type, typename out_type>
+class UHD_API cal_container : public base_container
+{
public:
typedef std::map<in_type, out_type> container_t;
@@ -51,7 +52,7 @@ public:
* \throws uhd::assertion_error if the dimensions of the input args
* are incorrect for this container
*/
- virtual out_type get(const in_type &args) = 0;
+ virtual out_type get(const in_type& args) = 0;
/*!
* Add a data point to the container.
@@ -61,21 +62,21 @@ public:
* \param output the output of the data point mapping
* \param args input values
*/
- virtual void add(const out_type output, const in_type &args) = 0;
+ virtual void add(const out_type output, const in_type& args) = 0;
/*!
* Associate some metadata with the container.
*
* \param data a map of metadata (string -> string).
*/
- virtual void add_metadata(const metadata_t &data) = 0;
+ virtual void add_metadata(const metadata_t& data) = 0;
/*!
* Retrieve metadata from the container.
*
* \returns map of metadata.
*/
- virtual const metadata_t &get_metadata() = 0;
+ virtual const metadata_t& get_metadata() = 0;
public:
typedef boost::archive::text_iarchive iarchive_type;
@@ -84,11 +85,10 @@ public:
protected:
friend class boost::serialization::access;
- virtual void serialize(iarchive_type & ar, const unsigned int) = 0;
- virtual void serialize(oarchive_type & ar, const unsigned int) = 0;
+ virtual void serialize(iarchive_type& ar, const unsigned int) = 0;
+ virtual void serialize(oarchive_type& ar, const unsigned int) = 0;
};
-} // namespace cal
-} // namespace uhd
+}} // namespace uhd::cal
#endif /* INCLUDED_UHD_CAL_CONTAINER_HPP */
diff --git a/host/include/uhd/cal/power_container.hpp b/host/include/uhd/cal/power_container.hpp
index 564a28018..052c68e6c 100644
--- a/host/include/uhd/cal/power_container.hpp
+++ b/host/include/uhd/cal/power_container.hpp
@@ -8,14 +8,14 @@
#ifndef INCLUDED_UHD_CAL_POWER_CONTAINER_HPP
#define INCLUDED_UHD_CAL_POWER_CONTAINER_HPP
-#include <uhd/config.hpp>
#include <uhd/cal/container.hpp>
+#include <uhd/config.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd {
-namespace cal {
+namespace uhd { namespace cal {
-class UHD_API power_container : public cal_container<std::vector<double>, double> {
+class UHD_API power_container : public cal_container<std::vector<double>, double>
+{
public:
typedef boost::shared_ptr<power_container> sptr;
@@ -35,7 +35,7 @@ public:
* \throws uhd::assertion_error if the number of input values are incorrect
* for the container type
*/
- virtual double get(const std::vector<double> &args) = 0;
+ virtual double get(const std::vector<double>& args) = 0;
/*!
* Add a data point to the container.
@@ -46,24 +46,23 @@ public:
* \param output the output of the data point mapping
* \param args input values
*/
- virtual void add(const double output, const std::vector<double> &args) = 0;
+ virtual void add(const double output, const std::vector<double>& args) = 0;
/*!
* Associate some metadata with the container.
*
* \param data a map of metadata (string -> string).
*/
- virtual void add_metadata(const metadata_t &data) = 0;
+ virtual void add_metadata(const metadata_t& data) = 0;
/*!
* Retrieve metadata from the container.
*
* \returns map of metadata.
*/
- virtual const metadata_t &get_metadata() = 0;
+ virtual const metadata_t& get_metadata() = 0;
};
-} // namespace cal
-} // namespace uhd
+}} // namespace uhd::cal
#endif /* INCLUDED_UHD_CAL_POWER_CONTAINER_HPP */
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index e7b48e5d8..dee0716f4 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -18,99 +18,106 @@
//# 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 : 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 : 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
-# pragma warning(disable: 4250) // 'class' : inherits 'method' via dominance
-# pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
+//# 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
+# pragma warning(disable : 4250) // 'class' : inherits 'method' via dominance
+# pragma warning( \
+ disable : 4200) // nonstandard extension used : zero-sized array in struct/union
// define logical operators
-#include <ciso646>
+# include <ciso646>
// define ssize_t
-#include <cstddef>
+# include <cstddef>
typedef ptrdiff_t ssize_t;
-#endif //BOOST_MSVC
+#endif // BOOST_MSVC
-//define cross platform attribute macros
+// define cross platform attribute macros
#if defined(BOOST_MSVC)
- #define UHD_EXPORT __declspec(dllexport)
- #define UHD_IMPORT __declspec(dllimport)
- #define UHD_INLINE __forceinline
- #define UHD_FORCE_INLINE __forceinline
- #define UHD_DEPRECATED __declspec(deprecated)
- #define UHD_ALIGNED(x) __declspec(align(x))
- #define UHD_UNUSED(x) x
+# define UHD_EXPORT __declspec(dllexport)
+# define UHD_IMPORT __declspec(dllimport)
+# define UHD_INLINE __forceinline
+# define UHD_FORCE_INLINE __forceinline
+# define UHD_DEPRECATED __declspec(deprecated)
+# define UHD_ALIGNED(x) __declspec(align(x))
+# define UHD_UNUSED(x) x
#elif defined(__MINGW32__)
- #define UHD_EXPORT __declspec(dllexport)
- #define UHD_IMPORT __declspec(dllimport)
- #define UHD_INLINE inline
- #define UHD_FORCE_INLINE inline
- #define UHD_DEPRECATED __declspec(deprecated)
- #define UHD_ALIGNED(x) __declspec(align(x))
- #define UHD_UNUSED(x) x __attribute__((unused))
+# define UHD_EXPORT __declspec(dllexport)
+# define UHD_IMPORT __declspec(dllimport)
+# define UHD_INLINE inline
+# define UHD_FORCE_INLINE inline
+# define UHD_DEPRECATED __declspec(deprecated)
+# define UHD_ALIGNED(x) __declspec(align(x))
+# define UHD_UNUSED(x) x __attribute__((unused))
#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_EXPORT __attribute__((visibility("default")))
- #define UHD_IMPORT __attribute__((visibility("default")))
- #define UHD_INLINE inline __attribute__((always_inline))
- #define UHD_FORCE_INLINE inline __attribute__((always_inline))
- #define UHD_DEPRECATED __attribute__((deprecated))
- #define UHD_ALIGNED(x) __attribute__((aligned(x)))
- #define UHD_UNUSED(x) x __attribute__((unused))
+# define UHD_EXPORT __attribute__((visibility("default")))
+# define UHD_IMPORT __attribute__((visibility("default")))
+# define UHD_INLINE inline __attribute__((always_inline))
+# define UHD_FORCE_INLINE inline __attribute__((always_inline))
+# define UHD_DEPRECATED __attribute__((deprecated))
+# define UHD_ALIGNED(x) __attribute__((aligned(x)))
+# define UHD_UNUSED(x) x __attribute__((unused))
#elif defined(__clang__)
- #define UHD_EXPORT __attribute__((visibility("default")))
- #define UHD_IMPORT __attribute__((visibility("default")))
- #define UHD_INLINE inline __attribute__((always_inline))
- #define UHD_FORCE_INLINE inline __attribute__((always_inline))
- #define UHD_DEPRECATED __attribute__((deprecated))
- #define UHD_ALIGNED(x) __attribute__((aligned(x)))
- #define UHD_UNUSED(x) x __attribute__((unused))
+# define UHD_EXPORT __attribute__((visibility("default")))
+# define UHD_IMPORT __attribute__((visibility("default")))
+# define UHD_INLINE inline __attribute__((always_inline))
+# define UHD_FORCE_INLINE inline __attribute__((always_inline))
+# define UHD_DEPRECATED __attribute__((deprecated))
+# define UHD_ALIGNED(x) __attribute__((aligned(x)))
+# define UHD_UNUSED(x) x __attribute__((unused))
#else
- #define UHD_EXPORT
- #define UHD_IMPORT
- #define UHD_INLINE inline
- #define UHD_FORCE_INLINE inline
- #define UHD_DEPRECATED
- #define UHD_ALIGNED(x)
- #define UHD_UNUSED(x) x
+# define UHD_EXPORT
+# define UHD_IMPORT
+# define UHD_INLINE inline
+# define UHD_FORCE_INLINE inline
+# define UHD_DEPRECATED
+# define UHD_ALIGNED(x)
+# define UHD_UNUSED(x) x
#endif
// Define API declaration macro
#ifdef UHD_STATIC_LIB
- #define UHD_API
+# define UHD_API
#else
- #ifdef UHD_DLL_EXPORTS
- #define UHD_API UHD_EXPORT
- #else
- #define UHD_API UHD_IMPORT
- #endif // UHD_DLL_EXPORTS
+# ifdef UHD_DLL_EXPORTS
+# define UHD_API UHD_EXPORT
+# else
+# define UHD_API UHD_IMPORT
+# endif // UHD_DLL_EXPORTS
#endif // UHD_STATIC_LIB
#ifdef UHD_RFNOC_ENABLED
- #define UHD_RFNOC_API UHD_API
+# define UHD_RFNOC_API UHD_API
#else
- #define UHD_RFNOC_API
+# define UHD_RFNOC_API
#endif // UHD_RFNOC_ENABLED
// Platform defines for conditional parts of headers:
// Taken from boost/config/select_platform_config.hpp,
// however, we define macros, not strings for platforms.
-#if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GLIBC__)) && !defined(_CRAYC) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
- #define UHD_PLATFORM_LINUX
+#if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GLIBC__)) \
+ && !defined(_CRAYC) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
+# define UHD_PLATFORM_LINUX
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- #define UHD_PLATFORM_WIN32
+# define UHD_PLATFORM_WIN32
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
- #define UHD_PLATFORM_MACOS
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
- #define UHD_PLATFORM_BSD
+# define UHD_PLATFORM_MACOS
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \
+ || defined(__FreeBSD_kernel__)
+# define UHD_PLATFORM_BSD
#endif
// Define 'stringize' preprocessor macros. The stringize macro, XSTR, takes
@@ -118,9 +125,9 @@ typedef ptrdiff_t ssize_t;
// There are two different versions because MSVC handles this syntax a bit
// differently than other compilers.
#if defined(BOOST_MSVC)
- #define XSTR(x,...) #x
+# define XSTR(x, ...) # x
#else
- #define XSTR(x...) #x
+# define XSTR(x...) # x
#endif
#define STR(x) XSTR(x)
diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp
index 64cebe945..3af7cc47b 100644
--- a/host/include/uhd/convert.hpp
+++ b/host/include/uhd/convert.hpp
@@ -10,99 +10,96 @@
#include <uhd/config.hpp>
#include <uhd/types/ref_vector.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/operators.hpp>
+#include <boost/shared_ptr.hpp>
#include <string>
-namespace uhd{ namespace convert{
-
- //! A conversion class that implements a conversion from inputs -> outputs.
- class converter{
- public:
- typedef boost::shared_ptr<converter> sptr;
- typedef uhd::ref_vector<void *> output_type;
- typedef uhd::ref_vector<const void *> input_type;
-
- virtual ~converter(void) = 0;
-
- //! Set the scale factor (used in floating point conversions)
- virtual void set_scalar(const double) = 0;
-
- //! The public conversion method to convert inputs -> outputs
- UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num){
- if (num != 0) (*this)(in, out, num);
- }
-
- private:
- //! Callable method: input vectors, output vectors, num samples
- //
- // This is the guts of the converter. When deriving new converter types,
- // this is where the actual conversion routines go.
- //
- // \param in Pointers to the input buffers
- // \param out Pointers to the output buffers
- // \param num Number of items in the input buffers to convert
- virtual void operator()(const input_type& in, const output_type& out, const size_t num) = 0;
- };
-
- //! Conversion factory function typedef
- typedef boost::function<converter::sptr(void)> function_type;
-
- //! Priority of conversion routines
- typedef int priority_type;
-
- //! Identify a conversion routine in the registry
- struct UHD_API id_type : boost::equality_comparable<id_type>{
- std::string input_format;
- size_t num_inputs;
- std::string output_format;
- size_t num_outputs;
- std::string to_pp_string(void) const;
- std::string to_string(void) const;
- };
-
- //! Implement equality_comparable interface
- UHD_API bool operator==(const id_type &, const id_type &);
-
- /*!
- * Register a converter function.
- *
- * Converters with higher priority are given preference.
- *
- * \param id identify the conversion
- * \param fcn makes a new converter
- * \param prio the function priority
- */
- UHD_API void register_converter(
- const id_type &id,
- const function_type &fcn,
- const priority_type prio
- );
-
- /*!
- * Get a converter factory function.
- * \param id identify the conversion
- * \param prio the desired prio or -1 for best
- * \return the converter factory function
- */
- UHD_API function_type get_converter(
- const id_type &id,
- const priority_type prio = -1
- );
-
- /*!
- * Register the size of a particular item.
- * \param format the item format
- * \param size the size in bytes
- */
- UHD_API void register_bytes_per_item(
- const std::string &format, const size_t size
- );
-
- //! Convert an item format to a size in bytes
- UHD_API size_t get_bytes_per_item(const std::string &format);
-
-}} //namespace
+namespace uhd { namespace convert {
+
+//! A conversion class that implements a conversion from inputs -> outputs.
+class converter
+{
+public:
+ typedef boost::shared_ptr<converter> sptr;
+ typedef uhd::ref_vector<void*> output_type;
+ typedef uhd::ref_vector<const void*> input_type;
+
+ virtual ~converter(void) = 0;
+
+ //! Set the scale factor (used in floating point conversions)
+ virtual void set_scalar(const double) = 0;
+
+ //! The public conversion method to convert inputs -> outputs
+ UHD_INLINE void conv(const input_type& in, const output_type& out, const size_t num)
+ {
+ if (num != 0)
+ (*this)(in, out, num);
+ }
+
+private:
+ //! Callable method: input vectors, output vectors, num samples
+ //
+ // This is the guts of the converter. When deriving new converter types,
+ // this is where the actual conversion routines go.
+ //
+ // \param in Pointers to the input buffers
+ // \param out Pointers to the output buffers
+ // \param num Number of items in the input buffers to convert
+ virtual void operator()(
+ const input_type& in, const output_type& out, const size_t num) = 0;
+};
+
+//! Conversion factory function typedef
+typedef boost::function<converter::sptr(void)> function_type;
+
+//! Priority of conversion routines
+typedef int priority_type;
+
+//! Identify a conversion routine in the registry
+struct UHD_API id_type : boost::equality_comparable<id_type>
+{
+ std::string input_format;
+ size_t num_inputs;
+ std::string output_format;
+ size_t num_outputs;
+ std::string to_pp_string(void) const;
+ std::string to_string(void) const;
+};
+
+//! Implement equality_comparable interface
+UHD_API bool operator==(const id_type&, const id_type&);
+
+/*!
+ * Register a converter function.
+ *
+ * Converters with higher priority are given preference.
+ *
+ * \param id identify the conversion
+ * \param fcn makes a new converter
+ * \param prio the function priority
+ */
+UHD_API void register_converter(
+ const id_type& id, const function_type& fcn, const priority_type prio);
+
+/*!
+ * Get a converter factory function.
+ * \param id identify the conversion
+ * \param prio the desired prio or -1 for best
+ * \return the converter factory function
+ */
+UHD_API function_type get_converter(const id_type& id, const priority_type prio = -1);
+
+/*!
+ * Register the size of a particular item.
+ * \param format the item format
+ * \param size the size in bytes
+ */
+UHD_API void register_bytes_per_item(const std::string& format, const size_t size);
+
+//! Convert an item format to a size in bytes
+UHD_API size_t get_bytes_per_item(const std::string& format);
+
+}} // namespace uhd::convert
#endif /* INCLUDED_UHD_CONVERT_HPP */
diff --git a/host/include/uhd/deprecated.hpp b/host/include/uhd/deprecated.hpp
index 91635f8ca..0eeefecee 100644
--- a/host/include/uhd/deprecated.hpp
+++ b/host/include/uhd/deprecated.hpp
@@ -10,58 +10,58 @@
//
#ifndef INCLUDED_UHD_TYPES_OTW_TYPE_HPP
-#define INCLUDED_UHD_TYPES_OTW_TYPE_HPP
+# define INCLUDED_UHD_TYPES_OTW_TYPE_HPP
-#include <uhd/config.hpp>
-#include <cstddef>
+# include <uhd/config.hpp>
+# include <cstddef>
-namespace uhd{
+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
+{
/*!
- * 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!
+ * Width of an over-the-wire integer in bits.
*/
- struct UHD_API otw_type_t{
+ size_t width; // in bits
- /*!
- * 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
+ /*!
+ * 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 = int('='),
- BO_LITTLE_ENDIAN = int('<'),
- BO_BIG_ENDIAN = int('>'),
- BO_NOT_APPLICABLE = int('|')
- } byteorder;
+ /*!
+ * Constants for byte order (borrowed from numpy's dtype)
+ */
+ enum /*bo_t*/ {
+ BO_NATIVE = int('='),
+ BO_LITTLE_ENDIAN = int('<'),
+ BO_BIG_ENDIAN = int('>'),
+ BO_NOT_APPLICABLE = int('|')
+ } byteorder;
- /*!
- * Get the sample size of this otw type.
- * \return the size of a sample in bytes
- */
- size_t get_sample_size(void) const;
+ /*!
+ * Get the sample size of this otw type.
+ * \return the size of a sample in bytes
+ */
+ size_t get_sample_size(void) const;
- otw_type_t(void);
- };
+ otw_type_t(void);
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_OTW_TYPE_HPP */
-#include <uhd/types/io_type.hpp> //wish it was in here
#include <uhd/types/clock_config.hpp> //wish it was in here
+#include <uhd/types/io_type.hpp> //wish it was in here
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp
index e0f8e3b60..9aecdc088 100644
--- a/host/include/uhd/device.hpp
+++ b/host/include/uhd/device.hpp
@@ -9,35 +9,31 @@
#define INCLUDED_UHD_DEVICE_HPP
#include <uhd/config.hpp>
-#include <uhd/stream.hpp>
#include <uhd/deprecated.hpp>
#include <uhd/property_tree.hpp>
+#include <uhd/stream.hpp>
#include <uhd/types/device_addr.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
-namespace uhd{
+namespace uhd {
-class property_tree; //forward declaration
+class property_tree; // forward declaration
/*!
* The device interface represents the hardware.
* The API allows for discovery, configuration, and streaming.
*/
-class UHD_API device : boost::noncopyable{
-
+class UHD_API device : boost::noncopyable
+{
public:
typedef boost::shared_ptr<device> sptr;
- typedef boost::function<device_addrs_t(const device_addr_t &)> find_t;
- typedef boost::function<sptr(const device_addr_t &)> make_t;
+ typedef boost::function<device_addrs_t(const device_addr_t&)> find_t;
+ typedef boost::function<sptr(const device_addr_t&)> make_t;
//! Device type, used as a filter in make
- enum device_filter_t {
- ANY,
- USRP,
- CLOCK
- };
+ enum device_filter_t { ANY, USRP, CLOCK };
virtual ~device(void) = 0;
/*!
@@ -48,10 +44,7 @@ public:
* \param filter include only USRP devices, clock devices, or both
*/
static void register_device(
- const find_t &find,
- const make_t &make,
- const device_filter_t filter
- );
+ const find_t& find, const make_t& make, const device_filter_t filter);
/*!
* \brief Find devices attached to the host.
@@ -63,7 +56,7 @@ public:
* \param filter an optional filter to exclude USRP or clock devices
* \return a vector of device addresses for all devices on the system
*/
- static device_addrs_t find(const device_addr_t &hint, device_filter_t filter = ANY);
+ static device_addrs_t find(const device_addr_t& hint, device_filter_t filter = ANY);
/*!
* \brief Create a new device from the device address hint.
@@ -79,21 +72,22 @@ public:
* \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, device_filter_t filter = ANY, size_t which = 0);
+ static sptr make(
+ const device_addr_t& hint, device_filter_t filter = ANY, size_t which = 0);
/*! \brief Make a new receive streamer from the streamer arguments
*
* Note: There can always only be one streamer. When calling get_rx_stream()
* a second time, the first streamer must be destroyed beforehand.
*/
- virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
+ virtual rx_streamer::sptr get_rx_stream(const stream_args_t& args) = 0;
/*! \brief Make a new transmit streamer from the streamer arguments
*
* Note: There can always only be one streamer. When calling get_tx_stream()
* a second time, the first streamer must be destroyed beforehand.
*/
- virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
+ virtual tx_streamer::sptr get_tx_stream(const stream_args_t& args) = 0;
/*!
* Receive and asynchronous message from the device.
@@ -102,8 +96,7 @@ public:
* \return true when the async_metadata is valid, false for timeout
*/
virtual bool recv_async_msg(
- async_metadata_t &async_metadata, double timeout = 0.1
- ) = 0;
+ async_metadata_t& async_metadata, double timeout = 0.1) = 0;
//! Get access to the underlying property structure
uhd::property_tree::sptr get_tree(void) const;
@@ -116,6 +109,6 @@ protected:
device_filter_t _type;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_DEVICE_HPP */
diff --git a/host/include/uhd/device3.hpp b/host/include/uhd/device3.hpp
index af304d37d..8dca2bc47 100644
--- a/host/include/uhd/device3.hpp
+++ b/host/include/uhd/device3.hpp
@@ -9,10 +9,10 @@
#define INCLUDED_UHD_DEVICE3_HPP
#include <uhd/device.hpp>
-#include <uhd/rfnoc/graph.hpp>
#include <uhd/rfnoc/block_ctrl_base.hpp>
-#include <boost/units/detail/utility.hpp>
+#include <uhd/rfnoc/graph.hpp>
#include <boost/thread/mutex.hpp>
+#include <boost/units/detail/utility.hpp>
#include <vector>
namespace uhd {
@@ -24,15 +24,15 @@ namespace uhd {
* - They support RFNoC (RF Network-on-Chip).
* - Data transport uses the compressed VITA (CVITA/CHDR) data format.
*/
-class UHD_API device3 : public uhd::device {
-
- public:
+class UHD_API device3 : public uhd::device
+{
+public:
typedef boost::shared_ptr<device3> sptr;
//! Same as uhd::device::make(), but will fail if not actually a device3
- static sptr make(const device_addr_t &hint, const size_t which = 0);
+ static sptr make(const device_addr_t& hint, const size_t which = 0);
- virtual rfnoc::graph::sptr create_graph(const std::string &name="") = 0;
+ virtual rfnoc::graph::sptr create_graph(const std::string& name = "") = 0;
/*! Reset blocks after a stream.
*
@@ -46,15 +46,14 @@ class UHD_API device3 : public uhd::device {
* \return true if a block with the specified id exists
* \note this access is not thread safe if peformed during block enumeration
*/
- bool has_block(const rfnoc::block_id_t &block_id) const;
+ bool has_block(const rfnoc::block_id_t& block_id) const;
/*! Same as has_block(), but with a type check.
*
* \return true if a block of type T with the specified id exists
* \note this access is not thread safe if peformed during block enumeration
*/
- template <typename T>
- bool has_block(const rfnoc::block_id_t &block_id) const
+ template <typename T> bool has_block(const rfnoc::block_id_t& block_id) const
{
if (has_block(block_id)) {
return bool(boost::dynamic_pointer_cast<T>(get_block_ctrl(block_id)));
@@ -71,7 +70,7 @@ class UHD_API device3 : public uhd::device {
* \param block_id Canonical block name (e.g. "0/FFT_1").
* \note this access is not thread safe if peformed during block enumeration
*/
- rfnoc::block_ctrl_base::sptr get_block_ctrl(const rfnoc::block_id_t &block_id) const;
+ rfnoc::block_ctrl_base::sptr get_block_ctrl(const rfnoc::block_id_t& block_id) const;
/*! Same as get_block_ctrl(), but with a type cast.
*
@@ -82,19 +81,22 @@ class UHD_API device3 : public uhd::device {
*
* \code{.cpp}
* // Assume DEV is a device3::sptr
- * uhd::rfnoc::my_block_ctrl::sptr block_controller = get_block_ctrl<my_block_ctrl>("0/MyBlock_0");
+ * uhd::rfnoc::my_block_ctrl::sptr block_controller =
+ * get_block_ctrl<my_block_ctrl>("0/MyBlock_0");
* block_controller->my_own_block_method();
* \endcode
* \note this access is not thread safe if peformed during block enumeration
*/
template <typename T>
- boost::shared_ptr<T> get_block_ctrl(const rfnoc::block_id_t &block_id) const
+ boost::shared_ptr<T> get_block_ctrl(const rfnoc::block_id_t& block_id) const
{
- boost::shared_ptr<T> blk = boost::dynamic_pointer_cast<T>(get_block_ctrl(block_id));
+ boost::shared_ptr<T> blk =
+ boost::dynamic_pointer_cast<T>(get_block_ctrl(block_id));
if (blk) {
return blk;
} else {
- throw uhd::lookup_error(str(boost::format("This device does not have a block of type %s with ID: %s")
+ throw uhd::lookup_error(str(
+ boost::format("This device does not have a block of type %s with ID: %s")
% boost::units::detail::demangle(typeid(T).name())
% block_id.to_string()));
}
@@ -108,16 +110,16 @@ class UHD_API device3 : public uhd::device {
* use the templated version of this function, e.g.
* \code{.cpp}
* // Assume DEV is a device3::sptr
- * null_block_ctrl::sptr null_block = DEV->find_blocks<null_block_ctrl>("NullSrcSink");
- * \endcode
- * \note this access is not thread safe if peformed during block enumeration
+ * null_block_ctrl::sptr null_block =
+ * DEV->find_blocks<null_block_ctrl>("NullSrcSink"); \endcode \note this access is not
+ * thread safe if peformed during block enumeration
*/
- std::vector<rfnoc::block_id_t> find_blocks(const std::string &block_id_hint) const;
+ std::vector<rfnoc::block_id_t> find_blocks(const std::string& block_id_hint) const;
/*! Type-cast version of find_blocks().
*/
template <typename T>
- std::vector<rfnoc::block_id_t> find_blocks(const std::string &block_id_hint) const
+ std::vector<rfnoc::block_id_t> find_blocks(const std::string& block_id_hint) const
{
std::vector<rfnoc::block_id_t> all_block_ids = find_blocks(block_id_hint);
std::vector<rfnoc::block_id_t> filt_block_ids;
@@ -129,15 +131,15 @@ class UHD_API device3 : public uhd::device {
return filt_block_ids;
}
- protected:
+protected:
//! List of *all* RFNoC blocks available on this device.
// It is the responsibility of the deriving class to make
// sure this gets correctly populated.
- std::vector< rfnoc::block_ctrl_base::sptr > _rfnoc_block_ctrl;
+ std::vector<rfnoc::block_ctrl_base::sptr> _rfnoc_block_ctrl;
//! Mutex to protect access to members
- boost::mutex _block_ctrl_mutex;
+ boost::mutex _block_ctrl_mutex;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_DEVICE3_HPP */
diff --git a/host/include/uhd/exception.hpp b/host/include/uhd/exception.hpp
index 727c09697..7189015a0 100644
--- a/host/include/uhd/exception.hpp
+++ b/host/include/uhd/exception.hpp
@@ -30,200 +30,220 @@
*
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2106.html
*/
-namespace uhd{
-
- /*! Base class of all UHD-specific exceptions.
- */
- struct UHD_API exception : std::runtime_error{
- exception(const std::string &what);
- virtual unsigned code(void) const = 0;
- virtual exception *dynamic_clone(void) const = 0;
- virtual void dynamic_throw(void) const = 0;
- };
-
- /*! Raised when an assert statement fails.
- *
- * This includes our own assertion macros, such as UHD_ASSERT_THROW().
- */
- struct UHD_API assertion_error : exception{
- assertion_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual assertion_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! The base class for exceptions that are raised when a key or index is
- * invalid.
- */
- struct UHD_API lookup_error : exception{
- lookup_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual lookup_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when a sequence index is out of range.
- */
- struct UHD_API index_error : lookup_error{
- index_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual index_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when a dictionary-like object is trying to be indexed by an
- * invalid key.
- *
- * This includes the property tree.
- */
- struct UHD_API key_error : lookup_error{
- key_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual key_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when an operation or function is executed with a value of
- * incorrect type.
- *
- * This might occur when values are being passed around as strings, but the
- * underlying code will need convert to a native type.
- */
- struct UHD_API type_error : exception{
- type_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual type_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when an operation or function receives an argument that has the
- * right type but an inappropriate or invalid value, and no other exception
- * is more specific.
- */
- struct UHD_API value_error : exception{
- value_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual value_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when a value is inappropriate because it can't be narrowed as
- * required.
- *
- * Mostly raised by uhd::narrow()
- */
- struct UHD_API narrowing_error : value_error{
- narrowing_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual narrowing_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when an error is detected that doesn't fall into any of the
- * categories.
- */
- struct UHD_API runtime_error : exception{
- runtime_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual runtime_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when an error occurs during a USB transaction.
- */
- struct UHD_API usb_error : runtime_error{
- int _code;
- usb_error(int code, const std::string &what);
- virtual unsigned code(void) const { return _code; };
- virtual usb_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when a function is stubbed out but doesn't actually do anything
- * useful.
- */
- struct UHD_API not_implemented_error : runtime_error{
- not_implemented_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual not_implemented_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
+namespace uhd {
- /*! Base class for errors that occur outside of UHD.
- */
- struct UHD_API environment_error : exception{
- environment_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual environment_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when an I/O operation fails for an I/O-related reason.
- */
- struct UHD_API io_error : environment_error{
- io_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual io_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*! Raised when a function returns a system-related error.
- */
- struct UHD_API os_error : environment_error{
- os_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual os_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
+/*! Base class of all UHD-specific exceptions.
+ */
+struct UHD_API exception : std::runtime_error
+{
+ exception(const std::string& what);
+ virtual unsigned code(void) const = 0;
+ virtual exception* dynamic_clone(void) const = 0;
+ virtual void dynamic_throw(void) const = 0;
+};
+
+/*! Raised when an assert statement fails.
+ *
+ * This includes our own assertion macros, such as UHD_ASSERT_THROW().
+ */
+struct UHD_API assertion_error : exception
+{
+ assertion_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual assertion_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! The base class for exceptions that are raised when a key or index is
+ * invalid.
+ */
+struct UHD_API lookup_error : exception
+{
+ lookup_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual lookup_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a sequence index is out of range.
+ */
+struct UHD_API index_error : lookup_error
+{
+ index_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual index_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a dictionary-like object is trying to be indexed by an
+ * invalid key.
+ *
+ * This includes the property tree.
+ */
+struct UHD_API key_error : lookup_error
+{
+ key_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual key_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when an operation or function is executed with a value of
+ * incorrect type.
+ *
+ * This might occur when values are being passed around as strings, but the
+ * underlying code will need convert to a native type.
+ */
+struct UHD_API type_error : exception
+{
+ type_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual type_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when an operation or function receives an argument that has the
+ * right type but an inappropriate or invalid value, and no other exception
+ * is more specific.
+ */
+struct UHD_API value_error : exception
+{
+ value_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual value_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a value is inappropriate because it can't be narrowed as
+ * required.
+ *
+ * Mostly raised by uhd::narrow()
+ */
+struct UHD_API narrowing_error : value_error
+{
+ narrowing_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual narrowing_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when an error is detected that doesn't fall into any of the
+ * categories.
+ */
+struct UHD_API runtime_error : exception
+{
+ runtime_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual runtime_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when an error occurs during a USB transaction.
+ */
+struct UHD_API usb_error : runtime_error
+{
+ int _code;
+ usb_error(int code, const std::string& what);
+ virtual unsigned code(void) const
+ {
+ return _code;
+ };
+ virtual usb_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a function is stubbed out but doesn't actually do anything
+ * useful.
+ */
+struct UHD_API not_implemented_error : runtime_error
+{
+ not_implemented_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual not_implemented_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Base class for errors that occur outside of UHD.
+ */
+struct UHD_API environment_error : exception
+{
+ environment_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual environment_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when an I/O operation fails for an I/O-related reason.
+ */
+struct UHD_API io_error : environment_error
+{
+ io_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual io_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a function returns a system-related error.
+ */
+struct UHD_API os_error : environment_error
+{
+ os_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual os_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! \deprecated
+ */
+struct UHD_API system_error : exception
+{
+ system_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual system_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*! Raised when a parser encounters a syntax error.
+ *
+ * Within UHD, this is limited to Noc-Script execution.
+ */
+struct UHD_API syntax_error : exception
+{
+ syntax_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual syntax_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
- /*! \deprecated
- */
- struct UHD_API system_error : exception{
- system_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual system_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
+/*!
+ * Create a formatted string with throw-site information.
+ * Fills in the function name, file name, and line number.
+ * \param what the std::exception message
+ * \return the formatted exception message
+ */
+#define UHD_THROW_SITE_INFO(what) \
+ std::string(std::string(what) + "\n" + " in " + std::string(BOOST_CURRENT_FUNCTION) \
+ + "\n" + " at " + std::string(__FILE__) + ":" \
+ + BOOST_STRINGIZE(__LINE__) + "\n")
- /*! Raised when a parser encounters a syntax error.
- *
- * Within UHD, this is limited to Noc-Script execution.
- */
- struct UHD_API syntax_error : exception{
- syntax_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual syntax_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
+/*!
+ * Throws an invalid code path exception with throw-site information.
+ * Use this macro in places that code execution is not supposed to go.
+ */
+#define UHD_THROW_INVALID_CODE_PATH() \
+ throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
- /*!
- * Create a formatted string with throw-site information.
- * Fills in the function name, file name, and line number.
- * \param what the std::exception message
- * \return the formatted exception message
- */
- #define UHD_THROW_SITE_INFO(what) std::string( \
- std::string(what) + "\n" + \
- " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
- " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
- )
-
- /*!
- * Throws an invalid code path exception with throw-site information.
- * Use this macro in places that code execution is not supposed to go.
- */
- #define UHD_THROW_INVALID_CODE_PATH() \
- throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
-
- /*!
- * Assert the result of the code evaluation.
- * If the code evaluates to false, throw an assertion error.
- * \param code the code that resolved to a boolean
- */
- #define UHD_ASSERT_THROW(code) {if (not (code)) \
- throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
+/*!
+ * Assert the result of the code evaluation.
+ * If the code evaluates to false, throw an assertion error.
+ * \param code the code that resolved to a boolean
+ */
+#define UHD_ASSERT_THROW(code) \
+ { \
+ if (not(code)) \
+ throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
}
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_EXCEPTION_HPP */
diff --git a/host/include/uhd/image_loader.hpp b/host/include/uhd/image_loader.hpp
index 6556bbdd8..3b4b9133e 100644
--- a/host/include/uhd/image_loader.hpp
+++ b/host/include/uhd/image_loader.hpp
@@ -8,21 +8,19 @@
#ifndef INCLUDED_UHD_IMAGE_LOADER_HPP
#define INCLUDED_UHD_IMAGE_LOADER_HPP
-#include <string>
-
-#include <boost/function.hpp>
-#include <boost/noncopyable.hpp>
-
#include <uhd/config.hpp>
#include <uhd/types/device_addr.hpp>
+#include <boost/function.hpp>
+#include <boost/noncopyable.hpp>
+#include <string>
-namespace uhd{
-
-class UHD_API image_loader : boost::noncopyable{
+namespace uhd {
+class UHD_API image_loader : boost::noncopyable
+{
public:
-
- typedef struct{
+ typedef struct
+ {
uhd::device_addr_t args;
bool load_firmware;
bool load_fpga;
@@ -48,7 +46,7 @@ public:
* device and expect the default image(s) to be loaded, but the specific
* model of the device cannot be determined beyond a category.
*/
- typedef boost::function<bool(const image_loader_args_t &)> loader_fcn_t;
+ typedef boost::function<bool(const image_loader_args_t&)> loader_fcn_t;
//! Register an image loader
/*!
@@ -56,17 +54,15 @@ public:
* \param loader_fcn the loader function for the given device
* \param recovery_instructions instructions on how to restore a device
*/
- static void register_image_loader(
- const std::string &device_type,
- const loader_fcn_t &loader_fcn,
- const std::string &recovery_instructions
- );
+ static void register_image_loader(const std::string& device_type,
+ const loader_fcn_t& loader_fcn,
+ const std::string& recovery_instructions);
//! Load firmware and/or FPGA onto a device
/*!
* \param image_loader_args arguments to pass into image loading function
*/
- static bool load(const image_loader_args_t &image_loader_args);
+ static bool load(const image_loader_args_t& image_loader_args);
//! Get the instructions on how to recovery a particular device
/*!
@@ -75,9 +71,9 @@ public:
* \param device_type the "type=foo" value given in an --args option
* \return recovery instructions
*/
- static std::string get_recovery_instructions(const std::string &device_type);
+ static std::string get_recovery_instructions(const std::string& device_type);
};
-}
+} // namespace uhd
#endif /* INCLUDED_UHD_IMAGE_LOADER_HPP */
diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp
index 84466e62a..173398986 100644
--- a/host/include/uhd/property_tree.hpp
+++ b/host/include/uhd/property_tree.hpp
@@ -9,12 +9,12 @@
#define INCLUDED_UHD_PROPERTY_TREE_HPP
#include <uhd/config.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
#include <vector>
-namespace uhd{
+namespace uhd {
/*!
* A templated property interface for holding the state
@@ -63,11 +63,12 @@ namespace uhd{
* - T must have a copy constructor
* - T must have an assignment operator
*/
-template <typename T> class property : boost::noncopyable{
+template <typename T> class property : boost::noncopyable
+{
public:
- typedef boost::function<void(const T &)> subscriber_type;
+ typedef boost::function<void(const T&)> subscriber_type;
typedef boost::function<T(void)> publisher_type;
- typedef boost::function<T(const T &)> coercer_type;
+ typedef boost::function<T(const T&)> coercer_type;
virtual ~property<T>(void) = 0;
@@ -81,7 +82,7 @@ public:
* \return a reference to this property for chaining
* \throws uhd::assertion_error if called more than once
*/
- virtual property<T> &set_coercer(const coercer_type &coercer) = 0;
+ virtual property<T>& set_coercer(const coercer_type& coercer) = 0;
/*!
* Register a publisher into the property.
@@ -93,7 +94,7 @@ public:
* \return a reference to this property for chaining
* \throws uhd::assertion_error if called more than once
*/
- virtual property<T> &set_publisher(const publisher_type &publisher) = 0;
+ virtual property<T>& set_publisher(const publisher_type& publisher) = 0;
/*!
* Register a subscriber into the property.
@@ -104,7 +105,7 @@ public:
* \param subscriber the subscriber callback function
* \return a reference to this property for chaining
*/
- virtual property<T> &add_desired_subscriber(const subscriber_type &subscriber) = 0;
+ virtual property<T>& add_desired_subscriber(const subscriber_type& subscriber) = 0;
/*!
* Register a subscriber into the property.
@@ -115,7 +116,7 @@ public:
* \param subscriber the subscriber callback function
* \return a reference to this property for chaining
*/
- virtual property<T> &add_coerced_subscriber(const subscriber_type &subscriber) = 0;
+ virtual property<T>& add_coerced_subscriber(const subscriber_type& subscriber) = 0;
/*!
* Update calls all subscribers w/ the current value.
@@ -123,7 +124,7 @@ public:
* \return a reference to this property for chaining
* \throws uhd::assertion_error
*/
- virtual property<T> &update(void) = 0;
+ virtual property<T>& update(void) = 0;
/*!
* Set the new value and call all the necessary subscribers.
@@ -137,7 +138,7 @@ public:
* \return a reference to this property for chaining
* \throws uhd::assertion_error
*/
- virtual property<T> &set(const T &value) = 0;
+ virtual property<T>& set(const T& value) = 0;
/*!
* Set a coerced value and call all subscribers.
@@ -150,7 +151,7 @@ public:
* \return a reference to this property for chaining
* \throws uhd::assertion_error
*/
- virtual property<T> &set_coerced(const T &value) = 0;
+ virtual property<T>& set_coerced(const T& value) = 0;
/*!
* Get the current value of this property.
@@ -179,8 +180,8 @@ public:
virtual bool empty(void) const = 0;
};
-template <typename T>
-property<T>::~property(void){
+template <typename T> property<T>::~property(void)
+{
/* NOP */
}
@@ -191,21 +192,23 @@ property<T>::~property(void){
* Notice: we do not declare UHD_API on the whole structure
* because MSVC will do weird things with std::string and linking.
*/
-struct fs_path : std::string{
+struct fs_path : std::string
+{
UHD_API fs_path(void);
- UHD_API fs_path(const char *);
- UHD_API fs_path(const std::string &);
+ UHD_API fs_path(const char*);
+ UHD_API fs_path(const std::string&);
UHD_API std::string leaf(void) const;
UHD_API fs_path branch_path(void) const;
};
-UHD_API fs_path operator/(const fs_path &, const fs_path &);
-UHD_API fs_path operator/(const fs_path &, size_t);
+UHD_API fs_path operator/(const fs_path&, const fs_path&);
+UHD_API fs_path operator/(const fs_path&, size_t);
/*!
* The property tree provides a file system structure for accessing properties.
*/
-class UHD_API property_tree : boost::noncopyable{
+class UHD_API property_tree : boost::noncopyable
+{
public:
typedef boost::shared_ptr<property_tree> sptr;
@@ -217,35 +220,33 @@ public:
static sptr make(void);
//! Get a subtree with a new root starting at path
- virtual sptr subtree(const fs_path &path) const = 0;
+ virtual sptr subtree(const fs_path& path) const = 0;
//! Remove a property or directory (recursive)
- virtual void remove(const fs_path &path) = 0;
+ virtual void remove(const fs_path& path) = 0;
//! True if the path exists in the tree
- virtual bool exists(const fs_path &path) const = 0;
+ virtual bool exists(const fs_path& path) const = 0;
//! Get an iterable to all things in the given path
- virtual std::vector<std::string> list(const fs_path &path) const = 0;
+ virtual std::vector<std::string> list(const fs_path& path) const = 0;
//! Create a new property entry in the tree
- template <typename T> property<T> &create(
- const fs_path &path,
- coerce_mode_t coerce_mode = AUTO_COERCE);
+ template <typename T>
+ property<T>& create(const fs_path& path, coerce_mode_t coerce_mode = AUTO_COERCE);
//! Get access to a property in the tree
- template <typename T> property<T> &access(const fs_path &path);
+ template <typename T> property<T>& access(const fs_path& path);
private:
//! Internal create property with wild-card type
- virtual void _create(const fs_path &path, const boost::shared_ptr<void> &prop) = 0;
+ virtual void _create(const fs_path& path, const boost::shared_ptr<void>& prop) = 0;
//! Internal access property with wild-card type
- virtual boost::shared_ptr<void> &_access(const fs_path &path) const = 0;
-
+ virtual boost::shared_ptr<void>& _access(const fs_path& path) const = 0;
};
-} //namespace uhd
+} // namespace uhd
#include <uhd/property_tree.ipp>
diff --git a/host/include/uhd/rfnoc/block_ctrl.hpp b/host/include/uhd/rfnoc/block_ctrl.hpp
index 9a8c5f8ec..c26ee0f85 100644
--- a/host/include/uhd/rfnoc/block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/block_ctrl.hpp
@@ -8,11 +8,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief This is the default implementation of a block_ctrl_base.
*
@@ -20,7 +19,8 @@ namespace uhd {
* can be set by sr_write(). The default behaviour of functions is documented
* in uhd::rfnoc::block_ctrl_base.
*/
-class UHD_RFNOC_API block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
// Required macro in RFNoC block classes
diff --git a/host/include/uhd/rfnoc/block_ctrl_base.hpp b/host/include/uhd/rfnoc/block_ctrl_base.hpp
index 4b97fa185..0bf701810 100644
--- a/host/include/uhd/rfnoc/block_ctrl_base.hpp
+++ b/host/include/uhd/rfnoc/block_ctrl_base.hpp
@@ -9,36 +9,34 @@
#define INCLUDED_LIBUHD_BLOCK_CTRL_BASE_HPP
#include <uhd/property_tree.hpp>
+#include <uhd/rfnoc/block_id.hpp>
+#include <uhd/rfnoc/blockdef.hpp>
+#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
+#include <uhd/rfnoc/stream_sig.hpp>
#include <uhd/stream.hpp>
#include <uhd/types/sid.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/wb_iface.hpp>
#include <uhd/utils/static.hpp>
-#include <uhd/rfnoc/node_ctrl_base.hpp>
-#include <uhd/rfnoc/block_id.hpp>
-#include <uhd/rfnoc/stream_sig.hpp>
-#include <uhd/rfnoc/blockdef.hpp>
-#include <uhd/rfnoc/constants.hpp>
-#include <boost/shared_ptr.hpp>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
-namespace uhd {
- namespace rfnoc {
- // Forward declarations
- class ctrl_iface;
- namespace nocscript {
- class block_iface;
- }
+namespace uhd { namespace rfnoc {
+// Forward declarations
+class ctrl_iface;
+namespace nocscript {
+class block_iface;
+}
// TODO: Move this out of public section
struct make_args_t
{
- make_args_t(const std::string &key="") :
- device_index(0),
- block_name(""),
- block_key(key)
- {}
+ make_args_t(const std::string& key = "")
+ : device_index(0), block_name(""), block_key(key)
+ {
+ }
//! A valid interface that allows us to read and write registers
std::map<size_t, boost::shared_ptr<ctrl_iface> > ctrl_ifaces;
@@ -58,25 +56,21 @@ struct make_args_t
//! This macro must be put in the public section of an RFNoC
// block class
-#define UHD_RFNOC_BLOCK_OBJECT(class_name) \
- typedef boost::shared_ptr< class_name > sptr;
+#define UHD_RFNOC_BLOCK_OBJECT(class_name) typedef boost::shared_ptr<class_name> sptr;
//! Shorthand for block constructor
#define UHD_RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \
- CLASS_NAME##_impl( \
- const make_args_t &make_args \
- ) : block_ctrl_base(make_args)
+ CLASS_NAME##_impl(const make_args_t& make_args) : block_ctrl_base(make_args)
//! This macro must be placed inside a block implementation file
// after the class definition
-#define UHD_RFNOC_BLOCK_REGISTER(CLASS_NAME, BLOCK_NAME) \
- block_ctrl_base::sptr CLASS_NAME##_make( \
- const make_args_t &make_args \
- ) { \
- return block_ctrl_base::sptr(new CLASS_NAME##_impl(make_args)); \
- } \
- UHD_STATIC_BLOCK(register_rfnoc_##CLASS_NAME) \
- { \
+#define UHD_RFNOC_BLOCK_REGISTER(CLASS_NAME, BLOCK_NAME) \
+ block_ctrl_base::sptr CLASS_NAME##_make(const make_args_t& make_args) \
+ { \
+ return block_ctrl_base::sptr(new CLASS_NAME##_impl(make_args)); \
+ } \
+ UHD_STATIC_BLOCK(register_rfnoc_##CLASS_NAME) \
+ { \
uhd::rfnoc::block_ctrl_base::register_block(&CLASS_NAME##_make, BLOCK_NAME); \
}
@@ -97,7 +91,7 @@ public:
* Types
**********************************************************************/
typedef boost::shared_ptr<block_ctrl_base> sptr;
- typedef boost::function<sptr(const make_args_t &)> make_t;
+ typedef boost::function<sptr(const make_args_t&)> make_t;
/***********************************************************************
* Factory functions
@@ -113,7 +107,7 @@ public:
* \param name A unique block name, e.g. 'FFT'. If a block has this block name,
* it will use \p make to generate the block controller class.
*/
- static void register_block(const make_t &make, const std::string &name);
+ static void register_block(const make_t& make, const std::string& name);
/*!
* \brief Create a block controller class given a NoC-ID or a block name.
@@ -129,7 +123,7 @@ public:
* \param noc_id The 64-Bit NoC-ID.
* \return a shared pointer to a new device instance
*/
- static sptr make(const make_args_t &make_args, uint64_t noc_id = ~0);
+ static sptr make(const make_args_t& make_args, uint64_t noc_id = ~0);
/***********************************************************************
* Block Communication and Control
@@ -139,15 +133,21 @@ public:
/*! Returns the 16-Bit address for this block.
*/
- uint32_t get_address(size_t block_port=0);
+ uint32_t get_address(size_t block_port = 0);
/*! Returns the unique block ID for this block (e.g. "0/FFT_1").
*/
- block_id_t get_block_id() const { return _block_id; };
+ block_id_t get_block_id() const
+ {
+ return _block_id;
+ };
/*! Shorthand for get_block_id().to_string()
*/
- std::string unique_id() const { return _block_id.to_string(); };
+ std::string unique_id() const
+ {
+ return _block_id.to_string();
+ };
/***********************************************************************
* FPGA control & communication
@@ -178,7 +178,7 @@ public:
* \throw uhd::key_error if \p reg is not a valid register name
*
*/
- void sr_write(const std::string &reg, const uint32_t data, const size_t port = 0);
+ void sr_write(const std::string& reg, const uint32_t data, const size_t port = 0);
/*! Allows reading one register on the settings bus (64-Bit version).
*
@@ -221,7 +221,7 @@ public:
* \returns the readback value.
* \throws uhd::key_error if \p reg is not a valid register name
*/
- uint64_t user_reg_read64(const std::string &reg, const size_t port = 0);
+ uint64_t user_reg_read64(const std::string& reg, const size_t port = 0);
/*! Allows reading one user-defined register (32-Bit version).
*
@@ -247,7 +247,7 @@ public:
* \throws uhd::key_error if \p reg is not a valid register name
* \param port Port from which to read
*/
- uint32_t user_reg_read32(const std::string &reg, const size_t port = 0);
+ uint32_t user_reg_read32(const std::string& reg, const size_t port = 0);
/*! Sets a command time for all future command packets.
@@ -255,7 +255,7 @@ public:
* \throws uhd::assertion_error if the underlying interface does not
* actually support timing.
*/
- void set_command_time(const time_spec_t &time_spec, const size_t port = ANY_PORT);
+ void set_command_time(const time_spec_t& time_spec, const size_t port = ANY_PORT);
/*! Returns the current command time for all future command packets.
*
@@ -307,15 +307,16 @@ public:
* Note that this function will silently ignore any keys in \p args that
* aren't already registered as block arguments.
*/
- void set_args(const uhd::device_addr_t &args, const size_t port = 0);
+ void set_args(const uhd::device_addr_t& args, const size_t port = 0);
//! Set a specific block argument. \p val is converted to the corresponding
// data type using by looking up its type in the block definition.
- void set_arg(const std::string &key, const std::string &val, const size_t port = 0);
+ void set_arg(const std::string& key, const std::string& val, const size_t port = 0);
//! Direct access to set a block argument.
template <typename T>
- void set_arg(const std::string &key, const T &val, const size_t port = 0) {
+ void set_arg(const std::string& key, const T& val, const size_t port = 0)
+ {
_tree->access<T>(get_arg_path(key, port) / "value").set(val);
}
@@ -323,40 +324,40 @@ public:
uhd::device_addr_t get_args(const size_t port = 0) const;
//! Return a single block argument in string format.
- std::string get_arg(const std::string &key, const size_t port = 0) const;
+ std::string get_arg(const std::string& key, const size_t port = 0) const;
//! Direct access to get a block argument.
- template <typename T>
- T get_arg(const std::string &key, const size_t port = 0) const {
+ template <typename T> T get_arg(const std::string& key, const size_t port = 0) const
+ {
return _tree->access<T>(get_arg_path(key, port) / "value").get();
}
- std::string get_arg_type(const std::string &key, const size_t port = 0) const;
+ std::string get_arg_type(const std::string& key, const size_t port = 0) const;
protected:
/***********************************************************************
* Structors
**********************************************************************/
- block_ctrl_base(void) {}; // To allow pure virtual (interface) sub-classes
+ block_ctrl_base(void){}; // To allow pure virtual (interface) sub-classes
virtual ~block_ctrl_base();
/*! Constructor. This is only called from the internal block factory!
*
* \param make_args All arguments to this constructor are passed in this object.
- * Its details are subject to change. Use the UHD_RFNOC_BLOCK_CONSTRUCTOR()
- * macro to set up your block's constructor in a portable fashion.
+ * Its details are subject to change. Use the
+ * UHD_RFNOC_BLOCK_CONSTRUCTOR() macro to set up your block's constructor in a
+ * portable fashion.
*/
- block_ctrl_base(
- const make_args_t &make_args
- );
+ block_ctrl_base(const make_args_t& make_args);
/***********************************************************************
* Helpers
**********************************************************************/
- stream_sig_t _resolve_port_def(const blockdef::port_t &port_def) const;
+ stream_sig_t _resolve_port_def(const blockdef::port_t& port_def) const;
//! Return the property tree path to a block argument \p key on \p port
- uhd::fs_path get_arg_path(const std::string &key, size_t port = 0) const {
+ uhd::fs_path get_arg_path(const std::string& key, size_t port = 0) const
+ {
return _root_path / "args" / port / key;
};
@@ -373,7 +374,8 @@ protected:
//! Override this function if your block needs to specially handle
// setting the command time
- virtual void _set_command_time(const time_spec_t &time_spec, const size_t port = ANY_PORT);
+ virtual void _set_command_time(
+ const time_spec_t& time_spec, const size_t port = ANY_PORT);
/***********************************************************************
* Protected members
**********************************************************************/
@@ -389,11 +391,9 @@ protected:
private:
//! Helper function to initialize the port definition nodes in the prop tree
- void _init_port_defs(
- const std::string &direction,
- blockdef::ports_t ports,
- const size_t first_port_index=0
- );
+ void _init_port_defs(const std::string& direction,
+ blockdef::ports_t ports,
+ const size_t first_port_index = 0);
//! Helper function to initialize the block args (used by ctor only)
void _init_block_args();
diff --git a/host/include/uhd/rfnoc/block_id.hpp b/host/include/uhd/rfnoc/block_id.hpp
index 126f3be25..8c4884807 100644
--- a/host/include/uhd/rfnoc/block_id.hpp
+++ b/host/include/uhd/rfnoc/block_id.hpp
@@ -14,187 +14,223 @@
#include <string>
namespace uhd {
- struct fs_path;
-
- namespace rfnoc {
-
- /*!
- * Identifies an RFNoC block.
- *
- * An RFNoC block ID is a string such as: 0/FFT_1
- *
- * The rules for formatting such a string are:
- *
- * DEVICE/BLOCKNAME_COUNTER
- *
- * DEVICE: Identifies the device (usually the motherboard index)
- * BLOCKNAME: A name given to this block
- * COUNTER: If is are more than one block with a BLOCKNAME, this counts up.
- *
- * So, 0/FFT_1 means we're addressing the second block called FFT
- * on the first device.
- *
- * This class can represent these block IDs.
- */
- class UHD_RFNOC_API block_id_t
- {
- public:
- block_id_t();
- block_id_t(const std::string &block_str);
- //! \param device_no Device number
- //! \param block_name Block name
- //! \param block_ctr Which block of this type is this on this device?
- block_id_t(const size_t device_no, const std::string &block_name, const size_t block_ctr=0);
-
- //! Return a string like this: "0/FFT_1" (includes all components, if set)
- std::string to_string() const;
-
- //! Check if a given string is valid as a block name.
- //
- // Note: This only applies to the block *name*, not the entire block ID.
- // Examples:
- // * is_valid_blockname("FFT") will return true.
- // * is_valid_blockname("FIR_Filter") will return false, because an underscore
- // is not allowed in a block name.
- //
- // Internally, this matches the string with uhd::rfnoc::VALID_BLOCKNAME_REGEX.
- static bool is_valid_blockname(const std::string &block_name);
-
- //! Check if a given string is valid as a block ID.
- //
- // Note: This does necessary require a complete complete ID. If this returns
- // true, then it is a valid input for block_id_t::match().
- //
- // Examples:
- // * is_valid_block_id("FFT") will return true.
- // * is_valid_block_id("0/Filter_1") will return true.
- // * is_valid_block_id("0/Filter_Foo") will return false.
- //
- // Internally, this matches the string with uhd::rfnoc::VALID_BLOCKID_REGEX.
- static bool is_valid_block_id(const std::string &block_id);
-
- //! Check if block_str matches this block.
- //
- // A match is a less strict version of equality.
- // Less specific block IDs will match more specific ones,
- // e.g. "FFT" will match "0/FFT_1", "1/FFT_2", etc.
- // "FFT_1" will only match the former, etc.
- bool match(const std::string &block_str);
-
- // Getters
-
- //! Short for to_string()
- std::string get() const { return to_string(); };
-
- //! Like get(), but only returns the local part ("FFT_1")
- std::string get_local() const;
-
- //! Returns the property tree root for this block (e.g. "/mboards/0/xbar/FFT_1/")
- uhd::fs_path get_tree_root() const;
-
- //! Return device number
- size_t get_device_no() const { return _device_no; };
-
- //! Return block count
- size_t get_block_count() const { return _block_ctr; };
-
- //! Return block name
- std::string get_block_name() const { return _block_name; };
-
- // Setters
-
- //! Set from string such as "0/FFT_1", "FFT_0", ...
- // Returns true if successful (i.e. if string valid)
- bool set(const std::string &new_name);
-
- //! Sets from individual compontents, like calling set_device_no(), set_block_name()
- // and set_block_count() one after another, only if \p block_name is invalid, stops
- // and returns false before chaning anything
- bool set(const size_t device_no, const std::string &block_name, const size_t block_ctr=0);
-
- //! Set the device number
- void set_device_no(size_t device_no) { _device_no = device_no; };
-
- //! Set the block name. Will return false if invalid block string.
- bool set_block_name(const std::string &block_name);
-
- //! Set the block count.
- void set_block_count(size_t count) { _block_ctr = count; };
-
- // Overloaded operators
-
- //! Assignment: Works like set(std::string)
- block_id_t operator = (const std::string &new_name) {
- set(new_name);
- return *this;
- }
-
- bool operator == (const block_id_t &block_id) const {
- return (_device_no == block_id.get_device_no())
- and (_block_name == block_id.get_block_name())
- and (_block_ctr == block_id.get_block_count());
- }
-
- bool operator != (const block_id_t &block_id) const {
- return not (*this == block_id);
- }
-
- bool operator < (const block_id_t &block_id) const {
- return (
- _device_no < block_id.get_device_no()
- or (_device_no == block_id.get_device_no() and _block_name < block_id.get_block_name())
- or (_device_no == block_id.get_device_no() and _block_name == block_id.get_block_name() and _block_ctr < block_id.get_block_count())
- );
- }
-
- bool operator > (const block_id_t &block_id) const {
- return (
- _device_no > block_id.get_device_no()
- or (_device_no == block_id.get_device_no() and _block_name > block_id.get_block_name())
- or (_device_no == block_id.get_device_no() and _block_name == block_id.get_block_name() and _block_ctr > block_id.get_block_count())
- );
- }
-
- //! Check if a string matches the entire block ID (not like match())
- bool operator == (const std::string &block_id_str) const {
- return get() == block_id_str;
- }
-
- //! Check if a string matches the entire block ID (not like match())
- bool operator == (const char *block_id_str) const {
- std::string comp = std::string(block_id_str);
- return *this == comp;
- }
-
- //! Type-cast operator does the same as to_string()
- operator std::string() const {
- return to_string();
- }
-
- //! Increment the block count ("FFT_1" -> "FFT_2")
- block_id_t operator++() {
- _block_ctr++;
- return *this;
- }
-
- //! Increment the block count ("FFT_1" -> "FFT_2")
- block_id_t operator++(int) {
- _block_ctr++;
- return *this;
- }
-
- private:
- size_t _device_no;
- std::string _block_name;
- size_t _block_ctr;
+struct fs_path;
+
+namespace rfnoc {
+
+/*!
+ * Identifies an RFNoC block.
+ *
+ * An RFNoC block ID is a string such as: 0/FFT_1
+ *
+ * The rules for formatting such a string are:
+ *
+ * DEVICE/BLOCKNAME_COUNTER
+ *
+ * DEVICE: Identifies the device (usually the motherboard index)
+ * BLOCKNAME: A name given to this block
+ * COUNTER: If is are more than one block with a BLOCKNAME, this counts up.
+ *
+ * So, 0/FFT_1 means we're addressing the second block called FFT
+ * on the first device.
+ *
+ * This class can represent these block IDs.
+ */
+class UHD_RFNOC_API block_id_t
+{
+public:
+ block_id_t();
+ block_id_t(const std::string& block_str);
+ //! \param device_no Device number
+ //! \param block_name Block name
+ //! \param block_ctr Which block of this type is this on this device?
+ block_id_t(const size_t device_no,
+ const std::string& block_name,
+ const size_t block_ctr = 0);
+
+ //! Return a string like this: "0/FFT_1" (includes all components, if set)
+ std::string to_string() const;
+
+ //! Check if a given string is valid as a block name.
+ //
+ // Note: This only applies to the block *name*, not the entire block ID.
+ // Examples:
+ // * is_valid_blockname("FFT") will return true.
+ // * is_valid_blockname("FIR_Filter") will return false, because an underscore
+ // is not allowed in a block name.
+ //
+ // Internally, this matches the string with uhd::rfnoc::VALID_BLOCKNAME_REGEX.
+ static bool is_valid_blockname(const std::string& block_name);
+
+ //! Check if a given string is valid as a block ID.
+ //
+ // Note: This does necessary require a complete complete ID. If this returns
+ // true, then it is a valid input for block_id_t::match().
+ //
+ // Examples:
+ // * is_valid_block_id("FFT") will return true.
+ // * is_valid_block_id("0/Filter_1") will return true.
+ // * is_valid_block_id("0/Filter_Foo") will return false.
+ //
+ // Internally, this matches the string with uhd::rfnoc::VALID_BLOCKID_REGEX.
+ static bool is_valid_block_id(const std::string& block_id);
+
+ //! Check if block_str matches this block.
+ //
+ // A match is a less strict version of equality.
+ // Less specific block IDs will match more specific ones,
+ // e.g. "FFT" will match "0/FFT_1", "1/FFT_2", etc.
+ // "FFT_1" will only match the former, etc.
+ bool match(const std::string& block_str);
+
+ // Getters
+
+ //! Short for to_string()
+ std::string get() const
+ {
+ return to_string();
+ };
+
+ //! Like get(), but only returns the local part ("FFT_1")
+ std::string get_local() const;
+
+ //! Returns the property tree root for this block (e.g. "/mboards/0/xbar/FFT_1/")
+ uhd::fs_path get_tree_root() const;
+
+ //! Return device number
+ size_t get_device_no() const
+ {
+ return _device_no;
+ };
+
+ //! Return block count
+ size_t get_block_count() const
+ {
+ return _block_ctr;
+ };
+
+ //! Return block name
+ std::string get_block_name() const
+ {
+ return _block_name;
+ };
+
+ // Setters
+
+ //! Set from string such as "0/FFT_1", "FFT_0", ...
+ // Returns true if successful (i.e. if string valid)
+ bool set(const std::string& new_name);
+
+ //! Sets from individual compontents, like calling set_device_no(), set_block_name()
+ // and set_block_count() one after another, only if \p block_name is invalid, stops
+ // and returns false before chaning anything
+ bool set(const size_t device_no,
+ const std::string& block_name,
+ const size_t block_ctr = 0);
+
+ //! Set the device number
+ void set_device_no(size_t device_no)
+ {
+ _device_no = device_no;
};
- //! Shortcut for << block_id.to_string()
- inline std::ostream& operator<< (std::ostream& out, block_id_t block_id) {
- out << block_id.to_string();
- return out;
+ //! Set the block name. Will return false if invalid block string.
+ bool set_block_name(const std::string& block_name);
+
+ //! Set the block count.
+ void set_block_count(size_t count)
+ {
+ _block_ctr = count;
+ };
+
+ // Overloaded operators
+
+ //! Assignment: Works like set(std::string)
+ block_id_t operator=(const std::string& new_name)
+ {
+ set(new_name);
+ return *this;
+ }
+
+ bool operator==(const block_id_t& block_id) const
+ {
+ return (_device_no == block_id.get_device_no())
+ and (_block_name == block_id.get_block_name())
+ and (_block_ctr == block_id.get_block_count());
+ }
+
+ bool operator!=(const block_id_t& block_id) const
+ {
+ return not(*this == block_id);
+ }
+
+ bool operator<(const block_id_t& block_id) const
+ {
+ return (_device_no < block_id.get_device_no()
+ or (_device_no == block_id.get_device_no()
+ and _block_name < block_id.get_block_name())
+ or (_device_no == block_id.get_device_no()
+ and _block_name == block_id.get_block_name()
+ and _block_ctr < block_id.get_block_count()));
+ }
+
+ bool operator>(const block_id_t& block_id) const
+ {
+ return (_device_no > block_id.get_device_no()
+ or (_device_no == block_id.get_device_no()
+ and _block_name > block_id.get_block_name())
+ or (_device_no == block_id.get_device_no()
+ and _block_name == block_id.get_block_name()
+ and _block_ctr > block_id.get_block_count()));
+ }
+
+ //! Check if a string matches the entire block ID (not like match())
+ bool operator==(const std::string& block_id_str) const
+ {
+ return get() == block_id_str;
+ }
+
+ //! Check if a string matches the entire block ID (not like match())
+ bool operator==(const char* block_id_str) const
+ {
+ std::string comp = std::string(block_id_str);
+ return *this == comp;
+ }
+
+ //! Type-cast operator does the same as to_string()
+ operator std::string() const
+ {
+ return to_string();
+ }
+
+ //! Increment the block count ("FFT_1" -> "FFT_2")
+ block_id_t operator++()
+ {
+ _block_ctr++;
+ return *this;
+ }
+
+ //! Increment the block count ("FFT_1" -> "FFT_2")
+ block_id_t operator++(int)
+ {
+ _block_ctr++;
+ return *this;
}
-}} //namespace uhd::rfnoc
+private:
+ size_t _device_no;
+ std::string _block_name;
+ size_t _block_ctr;
+};
+
+//! Shortcut for << block_id.to_string()
+inline std::ostream& operator<<(std::ostream& out, block_id_t block_id)
+{
+ out << block_id.to_string();
+ return out;
+}
+
+} // namespace rfnoc
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_BLOCK_ID_HPP */
diff --git a/host/include/uhd/rfnoc/blockdef.hpp b/host/include/uhd/rfnoc/blockdef.hpp
index 43845aa7d..30c5219e1 100644
--- a/host/include/uhd/rfnoc/blockdef.hpp
+++ b/host/include/uhd/rfnoc/blockdef.hpp
@@ -8,12 +8,12 @@
#ifndef INCLUDED_LIBUHD_RFNOC_BLOCKDEF_HPP
#define INCLUDED_LIBUHD_RFNOC_BLOCKDEF_HPP
-#include <stdint.h>
-#include <boost/enable_shared_from_this.hpp>
#include <uhd/config.hpp>
#include <uhd/types/device_addr.hpp>
-#include <vector>
+#include <stdint.h>
+#include <boost/enable_shared_from_this.hpp>
#include <set>
+#include <vector>
namespace uhd { namespace rfnoc {
@@ -31,17 +31,18 @@ public:
// to describe what kind of connection is allowed for this port.
//
// All the keys listed in PORT_ARGS will be available in this class.
- class port_t : public uhd::dict<std::string, std::string> {
- public:
+ class port_t : public uhd::dict<std::string, std::string>
+ {
+ public:
//! A list of args a port can have.
static const device_addr_t PORT_ARGS;
port_t();
//! Checks if the value at \p key is a variable (e.g. '$fftlen')
- bool is_variable(const std::string &key) const;
+ bool is_variable(const std::string& key) const;
//! Checks if the value at \p key is a keyword (e.g. '%vlen')
- bool is_keyword(const std::string &key) const;
+ bool is_keyword(const std::string& key) const;
//! Basic validity check of this port definition. Variables and
// keywords are not resolved.
bool is_valid() const;
@@ -51,8 +52,9 @@ public:
typedef std::vector<port_t> ports_t;
//! Describes arguments in a block definition.
- class arg_t : public uhd::dict<std::string, std::string> {
- public:
+ class arg_t : public uhd::dict<std::string, std::string>
+ {
+ public:
//! A list of args an argument can have.
static const device_addr_t ARG_ARGS;
static const std::set<std::string> VALID_TYPES;
@@ -63,7 +65,6 @@ public:
bool is_valid() const;
//! Returns a string with the most important keys
std::string to_string() const;
-
};
typedef std::vector<arg_t> args_t;
@@ -92,7 +93,7 @@ public:
//! Return the one NoC that is valid for this block
virtual uint64_t noc_id() const = 0;
- virtual ports_t get_input_ports() = 0;
+ virtual ports_t get_input_ports() = 0;
virtual ports_t get_output_ports() = 0;
//! Returns the full list of port numbers used
diff --git a/host/include/uhd/rfnoc/constants.hpp b/host/include/uhd/rfnoc/constants.hpp
index 8c97fa220..9d9295809 100644
--- a/host/include/uhd/rfnoc/constants.hpp
+++ b/host/include/uhd/rfnoc/constants.hpp
@@ -9,12 +9,11 @@
#define INCLUDED_LIBUHD_RFNOC_CONSTANTS_HPP
#include <uhd/types/dict.hpp>
-#include <boost/assign/list_of.hpp>
#include <stdint.h>
+#include <boost/assign/list_of.hpp>
#include <string>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
// All these configure the XML reader
//! Where the RFNoC block/component definition files lie, relative to UHD_PKG_DIR
@@ -24,11 +23,11 @@ static const std::string XML_PATH_ENV = "UHD_RFNOC_DIR";
//! If the block name can't be automatically detected, this name is used
static const std::string DEFAULT_BLOCK_NAME = "Block";
-static const uint64_t DEFAULT_NOC_ID = 0xFFFFFFFFFFFFFFFF;
-static const size_t NOC_SHELL_COMPAT_MAJOR = 5;
-static const size_t NOC_SHELL_COMPAT_MINOR = 0;
+static const uint64_t DEFAULT_NOC_ID = 0xFFFFFFFFFFFFFFFF;
+static const size_t NOC_SHELL_COMPAT_MAJOR = 5;
+static const size_t NOC_SHELL_COMPAT_MINOR = 0;
-static const size_t MAX_PACKET_SIZE = 8000; // bytes
+static const size_t MAX_PACKET_SIZE = 8000; // bytes
static const size_t DEFAULT_PACKET_SIZE = 1456; // bytes
// One line in FPGA is 64 Bits
@@ -44,57 +43,60 @@ static const size_t DEFAULT_FC_TX_RESPONSE_FREQ = 8; // ACKs per flow control wi
// Why not 100% full? Because we need to have some headroom to account for the inaccuracy
// when computing the window size. We compute the flow control window based on the frame
// size but the buffer can have overhead due to things like UDP headers, page alignment,
-// housekeeping info, etc. This number has to be transport agnostic so 20% of headroom is safe.
+// housekeeping info, etc. This number has to be transport agnostic so 20% of headroom is
+// safe.
static const double DEFAULT_FC_RX_SW_BUFF_FULL_FACTOR = 0.80;
// Common settings registers.
-static const uint32_t SR_FLOW_CTRL_BYTES_PER_ACK = 1;
-static const uint32_t SR_FLOW_CTRL_WINDOW_SIZE = 2;
-static const uint32_t SR_FLOW_CTRL_EN = 3;
-static const uint32_t SR_ERROR_POLICY = 4;
-static const uint32_t SR_BLOCK_SID = 5; // TODO rename to SRC_SID
-static const uint32_t SR_NEXT_DST_SID = 6;
-static const uint32_t SR_RESP_IN_DST_SID = 7;
-static const uint32_t SR_RESP_OUT_DST_SID = 8;
-static const uint32_t SR_FLOW_CTRL_PKT_LIMIT = 9;
-
-static const uint32_t SR_READBACK_ADDR = 124;
-static const uint32_t SR_READBACK = 127;
-
-static const uint32_t SR_CLEAR_RX_FC = 125;
-static const uint32_t SR_CLEAR_TX_FC = 126;
+static const uint32_t SR_FLOW_CTRL_BYTES_PER_ACK = 1;
+static const uint32_t SR_FLOW_CTRL_WINDOW_SIZE = 2;
+static const uint32_t SR_FLOW_CTRL_EN = 3;
+static const uint32_t SR_ERROR_POLICY = 4;
+static const uint32_t SR_BLOCK_SID = 5; // TODO rename to SRC_SID
+static const uint32_t SR_NEXT_DST_SID = 6;
+static const uint32_t SR_RESP_IN_DST_SID = 7;
+static const uint32_t SR_RESP_OUT_DST_SID = 8;
+static const uint32_t SR_FLOW_CTRL_PKT_LIMIT = 9;
+
+static const uint32_t SR_READBACK_ADDR = 124;
+static const uint32_t SR_READBACK = 127;
+
+static const uint32_t SR_CLEAR_RX_FC = 125;
+static const uint32_t SR_CLEAR_TX_FC = 126;
//! Settings register readback
enum settingsbus_reg_t {
- SR_READBACK_REG_ID = 0,
- SR_READBACK_REG_GLOBAL_PARAMS = 1,
- SR_READBACK_REG_FIFOSIZE = 2, // fifo size
- SR_READBACK_REG_MTU = 3,
+ SR_READBACK_REG_ID = 0,
+ SR_READBACK_REG_GLOBAL_PARAMS = 1,
+ SR_READBACK_REG_FIFOSIZE = 2, // fifo size
+ SR_READBACK_REG_MTU = 3,
SR_READBACK_REG_BLOCKPORT_SIDS = 4,
- SR_READBACK_REG_USER = 5,
- SR_READBACK_COMPAT = 6
+ SR_READBACK_REG_USER = 5,
+ SR_READBACK_COMPAT = 6
};
// AXI stream configuration bus (output master bus of axi wrapper) registers
-static const uint32_t AXI_WRAPPER_BASE = 128;
-static const uint32_t AXIS_CONFIG_BUS = AXI_WRAPPER_BASE+1; // tdata with tvalid asserted
-static const uint32_t AXIS_CONFIG_BUS_TLAST = AXI_WRAPPER_BASE+2; // tdata with tvalid & tlast asserted
+static const uint32_t AXI_WRAPPER_BASE = 128;
+static const uint32_t AXIS_CONFIG_BUS =
+ AXI_WRAPPER_BASE + 1; // tdata with tvalid asserted
+static const uint32_t AXIS_CONFIG_BUS_TLAST =
+ AXI_WRAPPER_BASE + 2; // tdata with tvalid & tlast asserted
static const size_t CMD_FIFO_SIZE = 128; // Lines == multiples of 8 bytes
// Named settings registers
-static const uhd::dict<std::string, uint32_t> DEFAULT_NAMED_SR = boost::assign::map_list_of
- ("AXIS_CONFIG_BUS", AXIS_CONFIG_BUS)
- ("AXIS_CONFIG_BUS_TLAST", AXIS_CONFIG_BUS_TLAST)
-;
+static const uhd::dict<std::string, uint32_t> DEFAULT_NAMED_SR =
+ boost::assign::map_list_of("AXIS_CONFIG_BUS", AXIS_CONFIG_BUS)(
+ "AXIS_CONFIG_BUS_TLAST", AXIS_CONFIG_BUS_TLAST);
// Block ports
-static const size_t ANY_PORT = size_t(~0);
+static const size_t ANY_PORT = size_t(~0);
static const size_t MAX_NUM_PORTS = 16;
// Regular expressions
static const std::string VALID_BLOCKNAME_REGEX = "[A-Za-z][A-Za-z0-9]*";
-static const std::string VALID_BLOCKID_REGEX = "(?:(\\d+)(?:/))?([A-Za-z][A-Za-z0-9]*)(?:(?:_)(\\d\\d?))?";
+static const std::string VALID_BLOCKID_REGEX =
+ "(?:(\\d+)(?:/))?([A-Za-z][A-Za-z0-9]*)(?:(?:_)(\\d\\d?))?";
}} /* namespace uhd::rfnoc */
diff --git a/host/include/uhd/rfnoc/ddc_block_ctrl.hpp b/host/include/uhd/rfnoc/ddc_block_ctrl.hpp
index daca3b8d3..2a261db00 100644
--- a/host/include/uhd/rfnoc/ddc_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/ddc_block_ctrl.hpp
@@ -8,13 +8,12 @@
#ifndef INCLUDED_LIBUHD_RFNOC_DDC_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_DDC_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
#include <uhd/rfnoc/rate_node_ctrl.hpp>
#include <uhd/rfnoc/scalar_node_ctrl.hpp>
+#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief DDC block controller
*
@@ -24,11 +23,10 @@ namespace uhd {
*
* It also includes a CORDIC component to shift signals in frequency.
*/
-class UHD_RFNOC_API ddc_block_ctrl :
- public source_block_ctrl_base,
- public sink_block_ctrl_base,
- public rate_node_ctrl,
- public scalar_node_ctrl
+class UHD_RFNOC_API ddc_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base,
+ public rate_node_ctrl,
+ public scalar_node_ctrl
{
public:
UHD_RFNOC_BLOCK_OBJECT(ddc_block_ctrl)
diff --git a/host/include/uhd/rfnoc/dma_fifo_block_ctrl.hpp b/host/include/uhd/rfnoc/dma_fifo_block_ctrl.hpp
index 74ab1ec15..093e2ef91 100644
--- a/host/include/uhd/rfnoc/dma_fifo_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/dma_fifo_block_ctrl.hpp
@@ -8,11 +8,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_DMA_FIFO_BLOCK_HPP
#define INCLUDED_LIBUHD_RFNOC_DMA_FIFO_BLOCK_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Block controller for a DMA FIFO block.
*
@@ -24,13 +23,15 @@ namespace uhd {
* bank.
*
*/
-class UHD_RFNOC_API dma_fifo_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API dma_fifo_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
UHD_RFNOC_BLOCK_OBJECT(dma_fifo_block_ctrl)
//! Configure the base address and depth of the FIFO (in bytes).
- virtual void resize(const uint32_t base_addr, const uint32_t depth, const size_t chan) = 0;
+ virtual void resize(
+ const uint32_t base_addr, const uint32_t depth, const size_t chan) = 0;
//! Returns the base address of the FIFO (in bytes).
uint32_t get_base_addr(const size_t chan) const;
diff --git a/host/include/uhd/rfnoc/duc_block_ctrl.hpp b/host/include/uhd/rfnoc/duc_block_ctrl.hpp
index 13eac5812..b24f7af26 100644
--- a/host/include/uhd/rfnoc/duc_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/duc_block_ctrl.hpp
@@ -8,13 +8,12 @@
#ifndef INCLUDED_LIBUHD_RFNOC_DUC_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_DUC_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
#include <uhd/rfnoc/rate_node_ctrl.hpp>
#include <uhd/rfnoc/scalar_node_ctrl.hpp>
+#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief DUC block controller
*
@@ -24,11 +23,10 @@ namespace uhd {
*
* It also includes a CORDIC component to shift signals in frequency.
*/
-class UHD_RFNOC_API duc_block_ctrl :
- public source_block_ctrl_base,
- public sink_block_ctrl_base,
- public rate_node_ctrl,
- public scalar_node_ctrl
+class UHD_RFNOC_API duc_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base,
+ public rate_node_ctrl,
+ public scalar_node_ctrl
{
public:
UHD_RFNOC_BLOCK_OBJECT(duc_block_ctrl)
@@ -38,4 +36,3 @@ public:
}} /* namespace uhd::rfnoc */
#endif /* INCLUDED_LIBUHD_RFNOC_DUC_BLOCK_CTRL_HPP */
-
diff --git a/host/include/uhd/rfnoc/fir_block_ctrl.hpp b/host/include/uhd/rfnoc/fir_block_ctrl.hpp
index 3fd93620d..67a6a958b 100644
--- a/host/include/uhd/rfnoc/fir_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/fir_block_ctrl.hpp
@@ -7,11 +7,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_fir_block_ctrl_HPP
#define INCLUDED_LIBUHD_RFNOC_fir_block_ctrl_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Block controller for the standard FIR RFNoC block.
*
@@ -24,7 +23,8 @@ namespace uhd {
* It will perform one FFT operation per incoming packet, treating it
* as a vector of samples.
*/
-class UHD_RFNOC_API fir_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API fir_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
UHD_RFNOC_BLOCK_OBJECT(fir_block_ctrl)
@@ -34,7 +34,7 @@ public:
// The length of \p taps must correspond the number of taps
// in this block. If it's shorter, zeros will be padded.
// If it's longer, throws a uhd::value_error.
- virtual void set_taps(const std::vector<int> &taps) = 0;
+ virtual void set_taps(const std::vector<int>& taps) = 0;
//! Returns the number of filter taps in this block.
virtual size_t get_n_taps() const = 0;
diff --git a/host/include/uhd/rfnoc/graph.hpp b/host/include/uhd/rfnoc/graph.hpp
index f6620d39b..b3372e389 100644
--- a/host/include/uhd/rfnoc/graph.hpp
+++ b/host/include/uhd/rfnoc/graph.hpp
@@ -8,9 +8,9 @@
#ifndef INCLUDED_LIBUHD_RFNOC_GRAPH_HPP
#define INCLUDED_LIBUHD_RFNOC_GRAPH_HPP
-#include <boost/noncopyable.hpp>
#include <uhd/rfnoc/block_id.hpp>
#include <uhd/types/sid.hpp>
+#include <boost/noncopyable.hpp>
namespace uhd { namespace rfnoc {
@@ -19,7 +19,8 @@ class graph : boost::noncopyable
public:
typedef boost::shared_ptr<uhd::rfnoc::graph> sptr;
- /*! Connect a RFNOC block with block ID \p src_block to another with block ID \p dst_block.
+ /*! Connect a RFNOC block with block ID \p src_block to another with block ID \p
+ * dst_block.
*
* This will:
* - Check if this connection is valid (IO signatures, see if types match)
@@ -27,22 +28,17 @@ public:
* - Configure SID for the upstream block
* - Register the upstream block in the downstream block
*/
- virtual void connect(
- const block_id_t &src_block,
- size_t src_block_port,
- const block_id_t &dst_block,
- size_t dst_block_port,
- const size_t pkt_size = 0
- ) = 0;
+ virtual void connect(const block_id_t& src_block,
+ size_t src_block_port,
+ const block_id_t& dst_block,
+ size_t dst_block_port,
+ const size_t pkt_size = 0) = 0;
/*! Shorthand for connect().
*
* Using default ports for both source and destination.
*/
- virtual void connect(
- const block_id_t &src_block,
- const block_id_t &dst_block
- ) = 0;
+ virtual void connect(const block_id_t& src_block, const block_id_t& dst_block) = 0;
/*! Anonymous connection.
*
@@ -53,13 +49,11 @@ public:
* \param dst_sid SID to route traffic to
* \param buf_size_dst_bytes Destination window buffer in bytes
*/
- virtual void connect_src(
- const block_id_t &src_block,
- const size_t src_block_port,
- const uhd::sid_t dst_sid,
- const size_t buf_size_dst_bytes,
- const size_t pkt_size_
- ) = 0;
+ virtual void connect_src(const block_id_t& src_block,
+ const size_t src_block_port,
+ const uhd::sid_t dst_sid,
+ const size_t buf_size_dst_bytes,
+ const size_t pkt_size_) = 0;
/*! Anonymous connection
*
@@ -69,15 +63,13 @@ public:
* \param dst_block_port Destination (sink) block port
* \param bytes_per_ack Flow control frequency in bytes
*/
- virtual void connect_sink(
- const block_id_t &sink_block,
- const size_t dst_block_port,
- const size_t bytes_per_ack
- ) = 0;
+ virtual void connect_sink(const block_id_t& sink_block,
+ const size_t dst_block_port,
+ const size_t bytes_per_ack) = 0;
virtual std::string get_name() const = 0;
};
-}}; /* name space uhd::rfnoc */
+}}; // namespace uhd::rfnoc
#endif /* INCLUDED_LIBUHD_RFNOC_GRAPH_HPP */
diff --git a/host/include/uhd/rfnoc/node_ctrl_base.hpp b/host/include/uhd/rfnoc/node_ctrl_base.hpp
index 791f74afd..0fed28bed 100644
--- a/host/include/uhd/rfnoc/node_ctrl_base.hpp
+++ b/host/include/uhd/rfnoc/node_ctrl_base.hpp
@@ -8,19 +8,18 @@
#ifndef INCLUDED_LIBUHD_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_NODE_CTRL_BASE_HPP
-#include <uhd/types/device_addr.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/types/device_addr.hpp>
#include <uhd/utils/log.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/utility.hpp>
+#include <stdint.h>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
#include <map>
#include <set>
-#include <stdint.h>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
#define UHD_RFNOC_BLOCK_TRACE() UHD_LOGGER_TRACE("RFNOC")
@@ -28,7 +27,8 @@ namespace uhd {
*
*/
class UHD_RFNOC_API node_ctrl_base;
-class node_ctrl_base : boost::noncopyable, public boost::enable_shared_from_this<node_ctrl_base>
+class node_ctrl_base : boost::noncopyable,
+ public boost::enable_shared_from_this<node_ctrl_base>
{
public:
/***********************************************************************
@@ -36,8 +36,8 @@ public:
**********************************************************************/
typedef boost::shared_ptr<node_ctrl_base> sptr;
typedef boost::weak_ptr<node_ctrl_base> wptr;
- typedef std::map< size_t, wptr > node_map_t;
- typedef std::pair< size_t, wptr > node_map_pair_t;
+ typedef std::map<size_t, wptr> node_map_t;
+ typedef std::pair<size_t, wptr> node_map_pair_t;
/***********************************************************************
* Node control
@@ -52,8 +52,14 @@ public:
*/
virtual void clear();
- node_map_t list_downstream_nodes() { return _downstream_nodes; };
- node_map_t list_upstream_nodes() { return _upstream_nodes; };
+ node_map_t list_downstream_nodes()
+ {
+ return _downstream_nodes;
+ };
+ node_map_t list_upstream_nodes()
+ {
+ return _upstream_nodes;
+ };
/*! Disconnect this node from all neighbouring nodes.
*/
@@ -109,7 +115,8 @@ public:
* Search only goes downstream.
*/
template <typename T>
- UHD_INLINE std::vector< boost::shared_ptr<T> > find_downstream_node(bool active_only = false)
+ UHD_INLINE std::vector<boost::shared_ptr<T> > find_downstream_node(
+ bool active_only = false)
{
return _find_child_node<T, true>(active_only);
}
@@ -117,7 +124,8 @@ public:
/*! Same as find_downstream_node(), but only search upstream.
*/
template <typename T>
- UHD_INLINE std::vector< boost::shared_ptr<T> > find_upstream_node(bool active_only = false)
+ UHD_INLINE std::vector<boost::shared_ptr<T> > find_upstream_node(
+ bool active_only = false)
{
return _find_child_node<T, false>(active_only);
}
@@ -136,22 +144,26 @@ public:
*/
template <typename T, typename value_type>
UHD_INLINE value_type find_downstream_unique_property(
- boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
- value_type null_value,
- const std::set< boost::shared_ptr<T> > &exclude_nodes=std::set< boost::shared_ptr<T> >()
- ) {
- return _find_unique_property<T, value_type, true>(get_property, null_value, exclude_nodes);
+ boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
+ value_type null_value,
+ const std::set<boost::shared_ptr<T> >& exclude_nodes =
+ std::set<boost::shared_ptr<T> >())
+ {
+ return _find_unique_property<T, value_type, true>(
+ get_property, null_value, exclude_nodes);
}
/*! Like find_downstream_unique_property(), but searches upstream.
*/
template <typename T, typename value_type>
UHD_INLINE value_type find_upstream_unique_property(
- boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
- value_type null_value,
- const std::set< boost::shared_ptr<T> > &exclude_nodes=std::set< boost::shared_ptr<T> >()
- ) {
- return _find_unique_property<T, value_type, false>(get_property, null_value, exclude_nodes);
+ boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
+ value_type null_value,
+ const std::set<boost::shared_ptr<T> >& exclude_nodes =
+ std::set<boost::shared_ptr<T> >())
+ {
+ return _find_unique_property<T, value_type, false>(
+ get_property, null_value, exclude_nodes);
}
protected:
@@ -159,7 +171,10 @@ protected:
* Structors
**********************************************************************/
node_ctrl_base(void) {}
- virtual ~node_ctrl_base() { disconnect(); }
+ virtual ~node_ctrl_base()
+ {
+ disconnect();
+ }
/***********************************************************************
* Protected members
@@ -204,9 +219,7 @@ protected:
* See also uhd::rfnoc::source_node_ctrl::_register_downstream_node().
*/
virtual void _register_downstream_node(
- node_ctrl_base::sptr downstream_node,
- size_t port
- );
+ node_ctrl_base::sptr downstream_node, size_t port);
/*! Registers another node as upstream of this node, connected to a given port.
*
@@ -214,10 +227,7 @@ protected:
* a source node.
* See also uhd::rfnoc::sink_node_ctrl::_register_upstream_node().
*/
- virtual void _register_upstream_node(
- node_ctrl_base::sptr upstream_node,
- size_t port
- );
+ virtual void _register_upstream_node(node_ctrl_base::sptr upstream_node, size_t port);
private:
/*! Implements the search algorithm for find_downstream_node() and
@@ -229,7 +239,7 @@ private:
* \param downstream Set to true if search goes downstream, false for upstream.
*/
template <typename T, bool downstream>
- std::vector< boost::shared_ptr<T> > _find_child_node(bool active_only = false);
+ std::vector<boost::shared_ptr<T> > _find_child_node(bool active_only = false);
/*! Implements the search algorithm for find_downstream_unique_property() and
* find_upstream_unique_property().
@@ -241,10 +251,9 @@ private:
*/
template <typename T, typename value_type, bool downstream>
value_type _find_unique_property(
- boost::function<value_type(boost::shared_ptr<T>, size_t)> get_property,
- value_type NULL_VALUE,
- const std::set< boost::shared_ptr<T> > &exclude_nodes
- );
+ boost::function<value_type(boost::shared_ptr<T>, size_t)> get_property,
+ value_type NULL_VALUE,
+ const std::set<boost::shared_ptr<T> >& exclude_nodes);
/*! Stores the remote port number of a downstream connection.
*/
diff --git a/host/include/uhd/rfnoc/null_block_ctrl.hpp b/host/include/uhd/rfnoc/null_block_ctrl.hpp
index 18ff7cea1..1406fd219 100644
--- a/host/include/uhd/rfnoc/null_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/null_block_ctrl.hpp
@@ -7,11 +7,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_NULL_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_NULL_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Provide access to a 'null block'.
*
@@ -45,7 +44,7 @@ public:
static const uint32_t SR_ENABLE_STREAM = 131;
static const size_t DEFAULT_LINES_PER_PACKET = 32;
- static const size_t BYTES_PER_LINE = 8;
+ static const size_t BYTES_PER_LINE = 8;
//! Custom function to set the rate at which data is produced.
// Note: This is 'cycles per line', so the bit rate is actually
@@ -56,11 +55,11 @@ public:
// \param The rate you want to set this to
// \param The clock rate of this block's clock domain
// \returns the actual line rate (will find closest possible).
- virtual double set_line_rate(double rate, double clock_rate=166.6e6) = 0;
+ virtual double set_line_rate(double rate, double clock_rate = 166.6e6) = 0;
//! Return the current line rate. Equivalent to reading line_rate/value
// from the property tree.
- virtual double get_line_rate(double clock_rate=166.6e6) const = 0;
+ virtual double get_line_rate(double clock_rate = 166.6e6) const = 0;
}; /* class null_block_ctrl*/
diff --git a/host/include/uhd/rfnoc/radio_ctrl.hpp b/host/include/uhd/rfnoc/radio_ctrl.hpp
index 28ba9264b..4f8f3bb1d 100644
--- a/host/include/uhd/rfnoc/radio_ctrl.hpp
+++ b/host/include/uhd/rfnoc/radio_ctrl.hpp
@@ -8,31 +8,29 @@
#ifndef INCLUDED_LIBUHD_RFNOC_RADIO_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_RADIO_CTRL_HPP
-#include <uhd/types/ranges.hpp>
-#include <uhd/types/direction.hpp>
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
#include <uhd/rfnoc/rate_node_ctrl.hpp>
-#include <uhd/rfnoc/tick_node_ctrl.hpp>
#include <uhd/rfnoc/scalar_node_ctrl.hpp>
+#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/terminator_node_ctrl.hpp>
+#include <uhd/rfnoc/tick_node_ctrl.hpp>
+#include <uhd/types/direction.hpp>
+#include <uhd/types/ranges.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Block controller for all RFNoC-based radio blocks
*/
-class UHD_RFNOC_API radio_ctrl :
- public source_block_ctrl_base,
- public sink_block_ctrl_base,
- public rate_node_ctrl,
- public tick_node_ctrl,
- public terminator_node_ctrl
+class UHD_RFNOC_API radio_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base,
+ public rate_node_ctrl,
+ public tick_node_ctrl,
+ public terminator_node_ctrl
{
public:
UHD_RFNOC_BLOCK_OBJECT(radio_ctrl)
- virtual ~radio_ctrl(){}
+ virtual ~radio_ctrl() {}
//! A wildcard channel index
@@ -69,7 +67,7 @@ public:
*
* \throws uhd::value_error if \p ant is not a valid value.
*/
- virtual void set_tx_antenna(const std::string &ant, const size_t chan) = 0;
+ virtual void set_tx_antenna(const std::string& ant, const size_t chan) = 0;
/*! Return the selected RX antenna for channel \p chan.
*
@@ -81,7 +79,7 @@ public:
*
* \throws uhd::value_error if \p ant is not a valid value.
*/
- virtual void set_rx_antenna(const std::string &ant, const size_t chan) = 0;
+ virtual void set_rx_antenna(const std::string& ant, const size_t chan) = 0;
/*! Return the current transmit LO frequency on channel \p chan.
*
@@ -163,10 +161,7 @@ public:
*
* \return The actual bandwidth value
*/
- virtual double set_tx_bandwidth(
- const double bandwidth,
- const size_t chan
- ) = 0;
+ virtual double set_tx_bandwidth(const double bandwidth, const size_t chan) = 0;
/*! Return the analog filter bandwidth channel \p chan
*
@@ -189,7 +184,7 @@ public:
* time in alignment with a certain reference time, use
* set_time_next_pps().
*/
- virtual void set_time_now(const time_spec_t &time_spec) = 0;
+ virtual void set_time_now(const time_spec_t& time_spec) = 0;
/*! Set the time registers at the next pps tick.
*
@@ -202,7 +197,7 @@ public:
*
* \param time_spec the time to latch into the timekeeper
*/
- virtual void set_time_next_pps(const time_spec_t &time_spec) = 0;
+ virtual void set_time_next_pps(const time_spec_t& time_spec) = 0;
/*! Get the current time in the timekeeper registers.
*
@@ -241,12 +236,10 @@ public:
* \param value the new value for this GPIO bank
* \param mask the bit mask to effect which pins are changed
*/
- virtual void set_gpio_attr(
- const std::string &bank,
- const std::string &attr,
- const uint32_t value,
- const uint32_t mask
- ) = 0;
+ virtual void set_gpio_attr(const std::string& bank,
+ const std::string& attr,
+ const uint32_t value,
+ const uint32_t mask) = 0;
/*!
* Get a GPIO attribute on a particular GPIO bank.
@@ -263,7 +256,7 @@ public:
* \param attr the name of a GPIO attribute
* \return the value set for this attribute
*/
- virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr) = 0;
+ virtual uint32_t get_gpio_attr(const std::string& bank, const std::string& attr) = 0;
/**************************************************************************
* LO Controls
@@ -283,7 +276,8 @@ public:
* \param chan the channel index 0 to N-1
* \return a vector of strings for possible settings
*/
- virtual std::vector<std::string> get_rx_lo_sources(const std::string &name, const size_t chan) = 0;
+ virtual std::vector<std::string> get_rx_lo_sources(
+ const std::string& name, const size_t chan) = 0;
/*!
* Get the LO frequency range of the RX LO.
@@ -293,7 +287,8 @@ public:
* \param chan the channel index 0 to N-1
* \return a frequency range object
*/
- virtual freq_range_t get_rx_lo_freq_range(const std::string &name, const size_t chan) = 0;
+ virtual freq_range_t get_rx_lo_freq_range(
+ const std::string& name, const size_t chan) = 0;
/*!
* Set the LO source for a channel.
@@ -304,7 +299,8 @@ public:
* \param name the name of the LO stage to update
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_lo_source(const std::string &src, const std::string &name, const size_t chan) = 0;
+ virtual void set_rx_lo_source(
+ const std::string& src, const std::string& name, const size_t chan) = 0;
/*!
* Get the currently set LO source.
@@ -314,7 +310,8 @@ public:
* \param chan the channel index 0 to N-1
* \return the configured LO source
*/
- virtual const std::string get_rx_lo_source(const std::string &name, const size_t chan) = 0;
+ virtual const std::string get_rx_lo_source(
+ const std::string& name, const size_t chan) = 0;
/*!
* Set whether the LO used by the usrp device is exported
@@ -324,14 +321,15 @@ public:
* \param name the name of the LO stage to update
* \param chan the channel index 0 to N-1 for the source channel
*/
- virtual void set_rx_lo_export_enabled(bool enabled, const std::string &name, const size_t chan) = 0;
+ virtual void set_rx_lo_export_enabled(
+ bool enabled, const std::string& name, const size_t chan) = 0;
/*!
* Returns true if the currently selected LO is being exported.
* \param name the name of the LO stage to query
* \param chan the channel index 0 to N-1
*/
- virtual bool get_rx_lo_export_enabled(const std::string &name, const size_t chan) = 0;
+ virtual bool get_rx_lo_export_enabled(const std::string& name, const size_t chan) = 0;
/*!
* Set the RX LO frequency (Advanced).
@@ -340,7 +338,8 @@ public:
* \param chan the channel index 0 to N-1
* \return a coerced LO frequency
*/
- virtual double set_rx_lo_freq(double freq, const std::string &name, const size_t chan) = 0;
+ virtual double set_rx_lo_freq(
+ double freq, const std::string& name, const size_t chan) = 0;
/*!
* Get the current RX LO frequency (Advanced).
@@ -350,7 +349,7 @@ public:
* \param chan the channel index 0 to N-1
* \return the configured LO frequency
*/
- virtual double get_rx_lo_freq(const std::string &name, const size_t chan) = 0;
+ virtual double get_rx_lo_freq(const std::string& name, const size_t chan) = 0;
/*! Get a list of possible LO stage names
*
@@ -368,9 +367,7 @@ public:
* \return a vector of strings for possible settings
*/
virtual std::vector<std::string> get_tx_lo_sources(
- const std::string &name,
- const size_t chan
- ) = 0;
+ const std::string& name, const size_t chan) = 0;
/*!
* Get the LO frequency range of the tx LO.
@@ -381,9 +378,7 @@ public:
* \return a frequency range object
*/
virtual freq_range_t get_tx_lo_freq_range(
- const std::string &name,
- const size_t chan
- ) = 0;
+ const std::string& name, const size_t chan) = 0;
/*!
* Set the LO source for a channel.
@@ -395,10 +390,7 @@ public:
* \param chan the channel index 0 to N-1
*/
virtual void set_tx_lo_source(
- const std::string &src,
- const std::string &name,
- const size_t chan
- ) = 0;
+ const std::string& src, const std::string& name, const size_t chan) = 0;
/*!
* Get the currently set LO source.
@@ -409,9 +401,7 @@ public:
* \return the configured LO source
*/
virtual const std::string get_tx_lo_source(
- const std::string &name,
- const size_t chan
- ) = 0;
+ const std::string& name, const size_t chan) = 0;
/*!
* Set whether the LO used by the usrp device is exported
@@ -422,20 +412,14 @@ public:
* \param chan the channel index 0 to N-1 for the source channel
*/
virtual void set_tx_lo_export_enabled(
- const bool enabled,
- const std::string &name,
- const size_t chan
- ) = 0;
+ const bool enabled, const std::string& name, const size_t chan) = 0;
/*!
* Returns true if the currently selected LO is being exported.
* \param name the name of the LO stage to query
* \param chan the channel index 0 to N-1
*/
- virtual bool get_tx_lo_export_enabled(
- const std::string &name,
- const size_t chan
- ) = 0;
+ virtual bool get_tx_lo_export_enabled(const std::string& name, const size_t chan) = 0;
/*! Set the tx LO frequency (Advanced).
*
@@ -447,10 +431,7 @@ public:
* \return a coerced LO frequency
*/
virtual double set_tx_lo_freq(
- const double freq,
- const std::string &name,
- const size_t chan
- ) = 0;
+ const double freq, const std::string& name, const size_t chan) = 0;
/*! Get the current TX LO frequency (Advanced).
*
@@ -463,16 +444,13 @@ public:
* \param chan the channel index 0 to N-1
* \return the configured LO frequency
*/
- virtual double get_tx_lo_freq(
- const std::string &name,
- const size_t chan
- ) = 0;
+ virtual double get_tx_lo_freq(const std::string& name, const size_t chan) = 0;
/**************************************************************************
* Time and clock control
*************************************************************************/
- /*!
+ /*!
* Set the time source for this radio.
*
* May affect other radio blocks.
@@ -480,7 +458,7 @@ public:
* \param source A string representing the time source
* \throws uhd::value_error if the value can't be applied
*/
- virtual void set_time_source(const std::string &source) = 0;
+ virtual void set_time_source(const std::string& source) = 0;
/*!
* Get the currently set time source.
@@ -503,7 +481,7 @@ public:
*
* \param source a string representing the clock source
*/
- virtual void set_clock_source(const std::string &source) = 0;
+ virtual void set_clock_source(const std::string& source) = 0;
/*!
* Get the currently set clock source.
@@ -525,11 +503,13 @@ public:
* map to channels 0 and 1 respectively. A BasicRX boards has alphabetical
* frontends (A, B) which map to channels differently.
*/
- virtual size_t get_chan_from_dboard_fe(const std::string &fe, const uhd::direction_t dir) = 0;
+ virtual size_t get_chan_from_dboard_fe(
+ const std::string& fe, const uhd::direction_t dir) = 0;
/*! The inverse function to get_chan_from_dboard_fe()
*/
- virtual std::string get_dboard_fe_from_chan(const size_t chan, const uhd::direction_t dir) = 0;
+ virtual std::string get_dboard_fe_from_chan(
+ const size_t chan, const uhd::direction_t dir) = 0;
/*! Enable or disable the setting of timestamps on Rx.
*/
diff --git a/host/include/uhd/rfnoc/rate_node_ctrl.hpp b/host/include/uhd/rfnoc/rate_node_ctrl.hpp
index 71ebf3927..f04af11f4 100644
--- a/host/include/uhd/rfnoc/rate_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/rate_node_ctrl.hpp
@@ -8,11 +8,10 @@
#ifndef INCLUDED_LIBUHD_RATE_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_RATE_NODE_CTRL_BASE_HPP
-#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Sampling-rate-aware node control
*
@@ -45,12 +44,11 @@ public:
* and then return that value multiplied by the decimation factor.
*
*/
- virtual double get_input_samp_rate(size_t port=ANY_PORT);
- virtual double get_output_samp_rate(size_t port=ANY_PORT);
+ virtual double get_input_samp_rate(size_t port = ANY_PORT);
+ virtual double get_output_samp_rate(size_t port = ANY_PORT);
}; /* class rate_node_ctrl */
}} /* namespace uhd::rfnoc */
#endif /* INCLUDED_LIBUHD_RATE_NODE_CTRL_BASE_HPP */
-
diff --git a/host/include/uhd/rfnoc/replay_block_ctrl.hpp b/host/include/uhd/rfnoc/replay_block_ctrl.hpp
index ba49a6a7d..639d31595 100644
--- a/host/include/uhd/rfnoc/replay_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/replay_block_ctrl.hpp
@@ -7,11 +7,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_REPLAY_BLOCK_HPP
#define INCLUDED_LIBUHD_RFNOC_REPLAY_BLOCK_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Replay block controller
*
@@ -25,23 +24,26 @@ namespace uhd {
* memory, usually an off-chip DRAM.
*
*/
-class UHD_RFNOC_API replay_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API replay_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
UHD_RFNOC_BLOCK_OBJECT(replay_block_ctrl)
//! Configure the base address and size of the record buffer region (in bytes).
- virtual void config_record(const uint32_t base_addr, const uint32_t size, const size_t chan) = 0;
-
+ virtual void config_record(
+ const uint32_t base_addr, const uint32_t size, const size_t chan) = 0;
+
//! Configure the base address and size of the playback buffer region (in bytes).
- virtual void config_play(const uint32_t base_addr, const uint32_t size, const size_t chan) = 0;
+ virtual void config_play(
+ const uint32_t base_addr, const uint32_t size, const size_t chan) = 0;
//! Restarts recording at the beginning of the record buffer
virtual void record_restart(const size_t chan) = 0;
//! Returns the base address of the record buffer (in bytes).
virtual uint32_t get_record_addr(const size_t chan) = 0;
-
+
//! Returns the base address of the playback buffer (in bytes).
virtual uint32_t get_play_addr(const size_t chan) = 0;
@@ -50,7 +52,7 @@ public:
//! Returns the current fullness of the record buffer (in bytes).
virtual uint32_t get_record_fullness(const size_t chan) = 0;
-
+
//! Returns the size of the playback buffer (in bytes).
virtual uint32_t get_play_size(const size_t chan) = 0;
@@ -62,7 +64,7 @@ public:
//! Halts playback and clears the playback command FIFO
virtual void play_halt(const size_t chan) = 0;
-
+
}; /* class replay_block_ctrl*/
}} /* namespace uhd::rfnoc */
diff --git a/host/include/uhd/rfnoc/scalar_node_ctrl.hpp b/host/include/uhd/rfnoc/scalar_node_ctrl.hpp
index e428f76fb..910a94b0c 100644
--- a/host/include/uhd/rfnoc/scalar_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/scalar_node_ctrl.hpp
@@ -8,11 +8,10 @@
#ifndef INCLUDED_LIBUHD_SCALAR_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_SCALAR_NODE_CTRL_BASE_HPP
-#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Scaling node control
*
@@ -45,7 +44,7 @@ public:
*
* \param port Port Number
*/
- virtual double get_input_scale_factor(size_t port=ANY_PORT);
+ virtual double get_input_scale_factor(size_t port = ANY_PORT);
/*! Returns the scaling factor for this block on output.
*
@@ -54,7 +53,7 @@ public:
*
* \param port Port Number
*/
- virtual double get_output_scale_factor(size_t port=ANY_PORT);
+ virtual double get_output_scale_factor(size_t port = ANY_PORT);
}; /* class scalar_node_ctrl */
diff --git a/host/include/uhd/rfnoc/siggen_block_ctrl.hpp b/host/include/uhd/rfnoc/siggen_block_ctrl.hpp
index 3d21ca258..c58d3490d 100644
--- a/host/include/uhd/rfnoc/siggen_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/siggen_block_ctrl.hpp
@@ -7,13 +7,13 @@
#ifndef INCLUDED_LIBUHD_RFNOC_SIGGEN_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_SIGGEN_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
-class UHD_RFNOC_API siggen_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API siggen_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
UHD_RFNOC_BLOCK_OBJECT(siggen_block_ctrl)
diff --git a/host/include/uhd/rfnoc/sink_block_ctrl_base.hpp b/host/include/uhd/rfnoc/sink_block_ctrl_base.hpp
index 959148b7f..a2d4685be 100644
--- a/host/include/uhd/rfnoc/sink_block_ctrl_base.hpp
+++ b/host/include/uhd/rfnoc/sink_block_ctrl_base.hpp
@@ -11,8 +11,7 @@
#include <uhd/rfnoc/block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_node_ctrl.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Extends block_ctrl_base with input capabilities.
*
@@ -41,7 +40,7 @@ public:
* \returns The stream signature for port \p block_port
* \throws uhd::runtime_error if \p block_port is not a valid port
*/
- stream_sig_t get_input_signature(size_t block_port=0) const;
+ stream_sig_t get_input_signature(size_t block_port = 0) const;
/*! Return a list of valid input ports.
*/
@@ -62,7 +61,7 @@ public:
*
* Returns the size of the buffer in bytes.
*/
- size_t get_fifo_size(size_t block_port=0) const;
+ size_t get_fifo_size(size_t block_port = 0) const;
/*! Configure flow control for incoming streams.
*
@@ -77,21 +76,18 @@ public:
*
* \param bytes Send an ACK after this many bytes have been consumed.
* Setting this to zero disables flow control acknowledgement.
- * \param block_port Set up flow control for a stream coming in on this particular block port.
+ * \param block_port Set up flow control for a stream coming in on this particular
+ * block port.
*/
virtual void configure_flow_control_in(
- const size_t bytes,
- const size_t block_port=0
- );
+ const size_t bytes, const size_t block_port = 0);
/*! Configure the behaviour for errors on incoming packets
* (e.g. sequence errors).
*
*
*/
- virtual void set_error_policy(
- const std::string &policy
- );
+ virtual void set_error_policy(const std::string& policy);
protected:
/***********************************************************************
@@ -101,9 +97,7 @@ protected:
* the port has an input signature.
*/
virtual size_t _request_input_port(
- const size_t suggested_port,
- const uhd::device_addr_t &args
- ) const;
+ const size_t suggested_port, const uhd::device_addr_t& args) const;
}; /* class sink_block_ctrl_base */
diff --git a/host/include/uhd/rfnoc/sink_node_ctrl.hpp b/host/include/uhd/rfnoc/sink_node_ctrl.hpp
index e080035f1..22100f4c5 100644
--- a/host/include/uhd/rfnoc/sink_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/sink_node_ctrl.hpp
@@ -8,13 +8,12 @@
#ifndef INCLUDED_LIBUHD_SINK_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_SINK_NODE_CTRL_BASE_HPP
-#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/sink_node_ctrl.hpp>
#include <boost/thread.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Abstract class for sink nodes.
*
@@ -28,8 +27,8 @@ public:
* Types
**********************************************************************/
typedef boost::shared_ptr<sink_node_ctrl> sptr;
- typedef std::map< size_t, boost::weak_ptr<sink_node_ctrl> > node_map_t;
- typedef std::pair< size_t, boost::weak_ptr<sink_node_ctrl> > node_map_pair_t;
+ typedef std::map<size_t, boost::weak_ptr<sink_node_ctrl> > node_map_t;
+ typedef std::pair<size_t, boost::weak_ptr<sink_node_ctrl> > node_map_pair_t;
/***********************************************************************
* Sink block controls
@@ -48,11 +47,9 @@ public:
*
* \returns The actual port number used.
*/
- size_t connect_upstream(
- node_ctrl_base::sptr upstream_node,
- size_t port=ANY_PORT,
- const uhd::device_addr_t &args=uhd::device_addr_t()
- );
+ size_t connect_upstream(node_ctrl_base::sptr upstream_node,
+ size_t port = ANY_PORT,
+ const uhd::device_addr_t& args = uhd::device_addr_t());
/*! Call this function to notify a node about its streamer activity.
*
@@ -64,7 +61,6 @@ public:
protected:
-
/*! Ask for a port number to connect an upstream block to.
*
* Typically, this will be overridden for custom behaviour.
@@ -94,16 +90,15 @@ protected:
* \returns A valid input port, or ANY_PORT on failure.
*/
virtual size_t _request_input_port(
- const size_t suggested_port,
- const uhd::device_addr_t &args
- ) const;
+ const size_t suggested_port, const uhd::device_addr_t& args) const;
private:
/*! Makes connecting something to the input thread-safe.
*/
boost::mutex _input_mutex;
- /*! Register a node upstream of this one (i.e., a node that can send data to this node).
+ /*! Register a node upstream of this one (i.e., a node that can send data to this
+ * node).
*
* By definition, the upstream node must of type source_node_ctrl.
*
@@ -113,10 +108,7 @@ private:
* \param upstream_node A pointer to the node instantiation
* \param port Port number the upstream node is connected to
*/
- void _register_upstream_node(
- node_ctrl_base::sptr upstream_node,
- size_t port
- );
+ void _register_upstream_node(node_ctrl_base::sptr upstream_node, size_t port);
}; /* class sink_node_ctrl */
diff --git a/host/include/uhd/rfnoc/source_block_ctrl_base.hpp b/host/include/uhd/rfnoc/source_block_ctrl_base.hpp
index 4f54a72c6..c0a8494c1 100644
--- a/host/include/uhd/rfnoc/source_block_ctrl_base.hpp
+++ b/host/include/uhd/rfnoc/source_block_ctrl_base.hpp
@@ -11,8 +11,7 @@
#include <uhd/rfnoc/block_ctrl_base.hpp>
#include <uhd/rfnoc/source_node_ctrl.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Extends block_ctrl_base with receive capabilities.
*
@@ -22,7 +21,8 @@ namespace uhd {
* data *from* this block.
*/
class UHD_RFNOC_API source_block_ctrl_base;
-class source_block_ctrl_base : virtual public block_ctrl_base, virtual public source_node_ctrl
+class source_block_ctrl_base : virtual public block_ctrl_base,
+ virtual public source_node_ctrl
{
public:
typedef boost::shared_ptr<source_block_ctrl_base> sptr;
@@ -50,9 +50,11 @@ public:
* See also register_upstream_block().
*
* \param stream_cmd The stream command.
- * \param chan Channel for which this command is meant (data shall be produced on this channel).
+ * \param chan Channel for which this command is meant (data shall be produced on this
+ * channel).
*/
- virtual void issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd, const size_t chan=0);
+ virtual void issue_stream_cmd(
+ const uhd::stream_cmd_t& stream_cmd, const size_t chan = 0);
/***********************************************************************
* Stream signatures
@@ -67,7 +69,7 @@ public:
* \returns The stream signature for port \p block_port
* \throws uhd::runtime_error if \p block_port is not a valid port
*/
- stream_sig_t get_output_signature(size_t block_port=0) const;
+ stream_sig_t get_output_signature(size_t block_port = 0) const;
/*! Return a list of valid output ports.
*/
@@ -85,10 +87,7 @@ public:
* to register SR_NEXT_DST of this blocks settings bus. The value will also
* have bit 16 set to 1, since some blocks require this to respect this value.
*/
- virtual void set_destination(
- uint32_t next_address,
- size_t output_block_port = 0
- );
+ virtual void set_destination(uint32_t next_address, size_t output_block_port = 0);
/*! Configure flow control for outgoing streams.
*
@@ -97,26 +96,25 @@ public:
*
* Override this function if your block has port-specific flow control settings.
*
- * \param enable_output Enable flow control module's output. If disabled, no packets will be output
- * regardless of flow control state.
- * \param buf_size_bytes The size of the downstream block's input FIFO size in number of bytes. Setting
- * this to zero disables byte based flow control. If both byte based flow control and
- * the packet limit are set to zero, the block will then produce data as fast as it can.
- * \b Warning: This can cause head-of-line blocking, and potentially lock up your device!
- * \param pkt_limit Limit the maximum number of packets in flight. Setting this to zero disables packet limiting.
- * Usually kept disabled except for special case connections (such as DMA) that support only
- * a finite number of packets in flight.
+ * \param enable_output Enable flow control module's output. If disabled, no packets
+ * will be output regardless of flow control state. \param buf_size_bytes The size of
+ * the downstream block's input FIFO size in number of bytes. Setting this to zero
+ * disables byte based flow control. If both byte based flow control and the packet
+ * limit are set to zero, the block will then produce data as fast as it can. \b
+ * Warning: This can cause head-of-line blocking, and potentially lock up your device!
+ * \param pkt_limit Limit the maximum number of packets in flight. Setting this to
+ * zero disables packet limiting. Usually kept disabled except for special case
+ * connections (such as DMA) that support only a finite number of packets in flight.
* \param block_port Specify on which outgoing port this setting is valid.
- * \param sid The SID for which this is valid. This is meant for cases where the outgoing block port is
- * not sufficient to set the flow control, and as such is rarely used.
+ * \param sid The SID for which this is valid. This is meant for cases where the
+ * outgoing block port is not sufficient to set the flow control, and as such is
+ * rarely used.
*/
- virtual void configure_flow_control_out(
- const bool enable_output,
- const size_t buf_size_bytes,
- const size_t pkt_limit=0,
- const size_t block_port=0,
- const uhd::sid_t &sid=uhd::sid_t()
- );
+ virtual void configure_flow_control_out(const bool enable_output,
+ const size_t buf_size_bytes,
+ const size_t pkt_limit = 0,
+ const size_t block_port = 0,
+ const uhd::sid_t& sid = uhd::sid_t());
protected:
@@ -127,9 +125,7 @@ protected:
* the port has an output signature.
*/
virtual size_t _request_output_port(
- const size_t suggested_port,
- const uhd::device_addr_t &args
- ) const;
+ const size_t suggested_port, const uhd::device_addr_t& args) const;
}; /* class source_block_ctrl_base */
diff --git a/host/include/uhd/rfnoc/source_node_ctrl.hpp b/host/include/uhd/rfnoc/source_node_ctrl.hpp
index a0e8dbe9d..1dcc1ecfb 100644
--- a/host/include/uhd/rfnoc/source_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/source_node_ctrl.hpp
@@ -8,13 +8,12 @@
#ifndef INCLUDED_LIBUHD_SOURCE_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_SOURCE_NODE_CTRL_BASE_HPP
-#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <boost/thread.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Abstract class for source nodes.
*
@@ -28,8 +27,8 @@ public:
* Types
**********************************************************************/
typedef boost::shared_ptr<source_node_ctrl> sptr;
- typedef std::map< size_t, boost::weak_ptr<source_node_ctrl> > node_map_t;
- typedef std::pair< size_t, boost::weak_ptr<source_node_ctrl> > node_map_pair_t;
+ typedef std::map<size_t, boost::weak_ptr<source_node_ctrl> > node_map_t;
+ typedef std::pair<size_t, boost::weak_ptr<source_node_ctrl> > node_map_pair_t;
/***********************************************************************
* Source block controls
@@ -39,9 +38,7 @@ public:
* \param chan Channel Index
*/
virtual void issue_stream_cmd(
- const uhd::stream_cmd_t &stream_cmd,
- const size_t chan=0
- ) = 0;
+ const uhd::stream_cmd_t& stream_cmd, const size_t chan = 0) = 0;
/*! Connect another node downstream of this node.
*
@@ -57,11 +54,9 @@ public:
*
* \returns The actual port number used.
*/
- size_t connect_downstream(
- node_ctrl_base::sptr downstream_node,
- size_t port=ANY_PORT,
- const uhd::device_addr_t &args=uhd::device_addr_t()
- );
+ size_t connect_downstream(node_ctrl_base::sptr downstream_node,
+ size_t port = ANY_PORT,
+ const uhd::device_addr_t& args = uhd::device_addr_t());
/*! Call this function to notify a node about its streamer activity.
*
@@ -72,7 +67,6 @@ public:
virtual void set_rx_streamer(bool active, const size_t port);
protected:
-
/*! Ask for a port number to connect a downstream block to.
*
* See sink_node_ctrl::_request_input_port(). This is the same
@@ -84,9 +78,7 @@ protected:
* \returns A valid input port, or ANY_PORT on failure.
*/
virtual size_t _request_output_port(
- const size_t suggested_port,
- const uhd::device_addr_t &args
- ) const;
+ const size_t suggested_port, const uhd::device_addr_t& args) const;
private:
@@ -94,7 +86,8 @@ private:
*/
boost::mutex _output_mutex;
- /*! Register a node downstream of this one (i.e., a node that receives data from this node).
+ /*! Register a node downstream of this one (i.e., a node that receives data from this
+ * node).
*
* By definition, the upstream node must of type sink_node_ctrl.
*
@@ -104,10 +97,7 @@ private:
* \param downstream_node A pointer to the node instantiation
* \param port Port number the downstream node is connected to
*/
- void _register_downstream_node(
- node_ctrl_base::sptr downstream_node,
- size_t port
- );
+ void _register_downstream_node(node_ctrl_base::sptr downstream_node, size_t port);
}; /* class source_node_ctrl */
diff --git a/host/include/uhd/rfnoc/stream_sig.hpp b/host/include/uhd/rfnoc/stream_sig.hpp
index 4a5128a43..3b8482781 100644
--- a/host/include/uhd/rfnoc/stream_sig.hpp
+++ b/host/include/uhd/rfnoc/stream_sig.hpp
@@ -8,8 +8,8 @@
#ifndef INCLUDED_LIBUHD_RFNOC_STREAMSIG_HPP
#define INCLUDED_LIBUHD_RFNOC_STREAMSIG_HPP
-#include <iostream>
#include <uhd/config.hpp>
+#include <iostream>
namespace uhd { namespace rfnoc {
@@ -20,8 +20,9 @@ namespace uhd { namespace rfnoc {
* so, some attributes may be left undefined (e.g., a FIFO block
* works for any item type, so it doesn't need to set it).
*/
-class UHD_RFNOC_API stream_sig_t {
- public:
+class UHD_RFNOC_API stream_sig_t
+{
+public:
/***********************************************************************
* Structors
***********************************************************************/
@@ -63,11 +64,13 @@ class UHD_RFNOC_API stream_sig_t {
*
* \return true if streams are compatible
*/
- static bool is_compatible(const stream_sig_t &output_sig, const stream_sig_t &input_sig);
+ static bool is_compatible(
+ const stream_sig_t& output_sig, const stream_sig_t& input_sig);
};
//! Shortcut for << stream_sig.to_string()
-UHD_INLINE std::ostream& operator<< (std::ostream& out, stream_sig_t stream_sig) {
+UHD_INLINE std::ostream& operator<<(std::ostream& out, stream_sig_t stream_sig)
+{
out << stream_sig.to_string().c_str();
return out;
}
diff --git a/host/include/uhd/rfnoc/terminator_node_ctrl.hpp b/host/include/uhd/rfnoc/terminator_node_ctrl.hpp
index 56ff3a3c1..5909a6367 100644
--- a/host/include/uhd/rfnoc/terminator_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/terminator_node_ctrl.hpp
@@ -10,8 +10,7 @@
#include <uhd/rfnoc/node_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Abstract class for terminator nodes (i.e. nodes that terminate
* the flow graph).
diff --git a/host/include/uhd/rfnoc/tick_node_ctrl.hpp b/host/include/uhd/rfnoc/tick_node_ctrl.hpp
index 0b288274f..da75a209f 100644
--- a/host/include/uhd/rfnoc/tick_node_ctrl.hpp
+++ b/host/include/uhd/rfnoc/tick_node_ctrl.hpp
@@ -8,11 +8,10 @@
#ifndef INCLUDED_LIBUHD_TICK_NODE_CTRL_BASE_HPP
#define INCLUDED_LIBUHD_TICK_NODE_CTRL_BASE_HPP
-#include <uhd/rfnoc/node_ctrl_base.hpp>
#include <uhd/rfnoc/constants.hpp>
+#include <uhd/rfnoc/node_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Tick-rate-aware node control
*
@@ -45,12 +44,14 @@ public:
* or it's a tick rate defined by an adjacent block.
* In that case, performs a graph search to figure out the tick rate.
*/
- double get_tick_rate(
- const std::set< node_ctrl_base::sptr > &_explored_nodes=std::set< node_ctrl_base::sptr >()
- );
+ double get_tick_rate(const std::set<node_ctrl_base::sptr>& _explored_nodes =
+ std::set<node_ctrl_base::sptr>());
protected:
- virtual double _get_tick_rate() { return RATE_UNDEFINED; };
+ virtual double _get_tick_rate()
+ {
+ return RATE_UNDEFINED;
+ };
}; /* class tick_node_ctrl */
diff --git a/host/include/uhd/rfnoc/traffic_counter.hpp b/host/include/uhd/rfnoc/traffic_counter.hpp
index bff04e38e..9a0546f17 100644
--- a/host/include/uhd/rfnoc/traffic_counter.hpp
+++ b/host/include/uhd/rfnoc/traffic_counter.hpp
@@ -9,47 +9,42 @@
#include <uhd/property_tree.hpp>
#include <stdint.h>
-#include <memory>
-#include <functional>
#include <type_traits>
+#include <functional>
+#include <memory>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
class traffic_counter
{
public:
typedef std::shared_ptr<traffic_counter> sptr;
- typedef std::function<void(const uint32_t addr, const uint32_t data)> write_reg_fn_t ;
- typedef std::function<uint64_t(const uint32_t addr)> read_reg_fn_t ;
+ typedef std::function<void(const uint32_t addr, const uint32_t data)> write_reg_fn_t;
+ typedef std::function<uint64_t(const uint32_t addr)> read_reg_fn_t;
- traffic_counter(
- uhd::property_tree::sptr tree,
+ traffic_counter(uhd::property_tree::sptr tree,
uhd::fs_path root_path,
write_reg_fn_t write_reg_fn,
- read_reg_fn_t read_reg_fn
- ) :
- _write_reg_fn(write_reg_fn),
- _read_reg_fn(read_reg_fn)
+ read_reg_fn_t read_reg_fn)
+ : _write_reg_fn(write_reg_fn), _read_reg_fn(read_reg_fn)
{
- const uint32_t id_reg_offset = 0;
+ const uint32_t id_reg_offset = 0;
const uint32_t first_counter_offset = 1;
- const uint64_t traffic_counter_id = 0x712AFF1C00000000ULL;
+ const uint64_t traffic_counter_id = 0x712AFF1C00000000ULL;
// Check traffic counter id to determine if it's present
const uint64_t id = _read_reg_fn(id_reg_offset);
// If present, add properties
- if (id == traffic_counter_id)
- {
- tree->create<bool>(root_path/"traffic_counter/enable")
+ if (id == traffic_counter_id) {
+ tree->create<bool>(root_path / "traffic_counter/enable")
.add_coerced_subscriber([this](const bool enable) {
- uint32_t val = enable? 1 : 0;
+ uint32_t val = enable ? 1 : 0;
return _write_reg_fn(0, val);
- }).set(false);
+ })
+ .set(false);
- const char* counters[] = {
- "bus_clock_ticks",
+ const char* counters[] = {"bus_clock_ticks",
"xbar_to_shell_xfer_count",
"xbar_to_shell_pkt_count",
"shell_to_xbar_xfer_count",
@@ -60,16 +55,17 @@ public:
"ce_to_shell_pkt_count"};
for (size_t i = 0; i < std::extent<decltype(counters)>::value; i++) {
- tree->create<uint64_t>(root_path/"traffic_counter"/counters[i])
+ tree->create<uint64_t>(root_path / "traffic_counter" / counters[i])
.set_publisher([this, i, first_counter_offset]() {
- return _read_reg_fn(i+first_counter_offset);
+ return _read_reg_fn(i + first_counter_offset);
});
}
}
}
+
private:
write_reg_fn_t _write_reg_fn;
- read_reg_fn_t _read_reg_fn;
+ read_reg_fn_t _read_reg_fn;
};
}} /* namespace uhd::rfnoc */
diff --git a/host/include/uhd/rfnoc/window_block_ctrl.hpp b/host/include/uhd/rfnoc/window_block_ctrl.hpp
index 093b34e67..ee5439b40 100644
--- a/host/include/uhd/rfnoc/window_block_ctrl.hpp
+++ b/host/include/uhd/rfnoc/window_block_ctrl.hpp
@@ -7,11 +7,10 @@
#ifndef INCLUDED_LIBUHD_RFNOC_WINDOW_BLOCK_CTRL_HPP
#define INCLUDED_LIBUHD_RFNOC_WINDOW_BLOCK_CTRL_HPP
-#include <uhd/rfnoc/source_block_ctrl_base.hpp>
#include <uhd/rfnoc/sink_block_ctrl_base.hpp>
+#include <uhd/rfnoc/source_block_ctrl_base.hpp>
-namespace uhd {
- namespace rfnoc {
+namespace uhd { namespace rfnoc {
/*! \brief Block controller for the standard windowing RFNoC block.
*
@@ -24,22 +23,23 @@ namespace uhd {
* It will perform one window operation per incoming packet, treating it
* as a vector of samples.
*/
-class UHD_RFNOC_API window_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base
+class UHD_RFNOC_API window_block_ctrl : public source_block_ctrl_base,
+ public sink_block_ctrl_base
{
public:
UHD_RFNOC_BLOCK_OBJECT(window_block_ctrl)
- static const size_t MAX_COEFF_VAL = 32767;
- static const uint32_t SR_WINDOW_LEN = 131; // Note: AXI config bus uses 129 & 130
- static const uint32_t RB_MAX_WINDOW_LEN = 0;
- static const uint32_t AXIS_WINDOW_LOAD = AXIS_CONFIG_BUS+0; // 2*0+0
- static const uint32_t AXIS_WINDOW_LOAD_TLAST = AXIS_CONFIG_BUS+1; // 2*0+1
+ static const size_t MAX_COEFF_VAL = 32767;
+ static const uint32_t SR_WINDOW_LEN = 131; // Note: AXI config bus uses 129 & 130
+ static const uint32_t RB_MAX_WINDOW_LEN = 0;
+ static const uint32_t AXIS_WINDOW_LOAD = AXIS_CONFIG_BUS + 0; // 2*0+0
+ static const uint32_t AXIS_WINDOW_LOAD_TLAST = AXIS_CONFIG_BUS + 1; // 2*0+1
//! Configure the window coefficients
//
// \p coeffs size determines the window length. If it longer than
// the maximum window length, throws a uhd::value_error.
- virtual void set_window(const std::vector<int> &coeffs) = 0;
+ virtual void set_window(const std::vector<int>& coeffs) = 0;
//! Returns the maximum window length.
virtual size_t get_max_len() const = 0;
diff --git a/host/include/uhd/stream.hpp b/host/include/uhd/stream.hpp
index 757198dde..133893cf9 100644
--- a/host/include/uhd/stream.hpp
+++ b/host/include/uhd/stream.hpp
@@ -9,16 +9,16 @@
#define INCLUDED_UHD_STREAM_HPP
#include <uhd/config.hpp>
-#include <uhd/types/metadata.hpp>
#include <uhd/types/device_addr.hpp>
-#include <uhd/types/stream_cmd.hpp>
+#include <uhd/types/metadata.hpp>
#include <uhd/types/ref_vector.hpp>
-#include <boost/utility.hpp>
+#include <uhd/types/stream_cmd.hpp>
#include <boost/shared_ptr.hpp>
-#include <vector>
+#include <boost/utility.hpp>
#include <string>
+#include <vector>
-namespace uhd{
+namespace uhd {
/*!
* A struct of parameters to construct a streamer.
@@ -55,13 +55,11 @@ namespace uhd{
* stream_args.args["block_port2"] = "1";
* \endcode
*/
-struct UHD_API stream_args_t{
-
+struct UHD_API stream_args_t
+{
//! Convenience constructor for streamer args
- stream_args_t(
- const std::string &cpu = "",
- const std::string &otw = ""
- ){
+ stream_args_t(const std::string& cpu = "", const std::string& otw = "")
+ {
cpu_format = cpu;
otw_format = otw;
}
@@ -95,12 +93,12 @@ struct UHD_API stream_args_t{
* - s16 - R16_1 R16_0
* - s8 - R8_3 R8_2 R8_1 R8_0
*
- * Setting the OTW ("over-the-wire") format is, in theory, transparent to the application,
- * but changing this can have some side effects. Using less bits for example (e.g. when going
- * from `otw_format` `sc16` to `sc8`) will reduce the dynamic range, and increases quantization
- * noise. On the other hand, it reduces the load on the data link and thus allows more bandwidth
- * (a USRP N210 can work with 25 MHz bandwidth for 16-Bit complex samples, and 50 MHz for 8-Bit
- * complex samples).
+ * Setting the OTW ("over-the-wire") format is, in theory, transparent to the
+ * application, but changing this can have some side effects. Using less bits for
+ * example (e.g. when going from `otw_format` `sc16` to `sc8`) will reduce the dynamic
+ * range, and increases quantization noise. On the other hand, it reduces the load on
+ * the data link and thus allows more bandwidth (a USRP N210 can work with 25 MHz
+ * bandwidth for 16-Bit complex samples, and 50 MHz for 8-Bit complex samples).
*/
std::string otw_format;
@@ -113,16 +111,17 @@ struct UHD_API stream_args_t{
* Set the "fullscale" to scale the samples in the host to the
* expected input range and/or output range of your application.
*
- * - peak: specifies a fractional sample level to calculate scaling with the sc8 wire format.
- * When using sc8 samples over the wire, the device must scale samples
- * (both on the host and in the device) to satisfy the dynamic range needs.
- * The peak value specifies a fraction of the maximum sample level (1.0 = 100%).
- * Set peak to max_sample_level/full_scale_level to ensure optimum dynamic range.
+ * - peak: specifies a fractional sample level to calculate scaling with the sc8 wire
+ * format. When using sc8 samples over the wire, the device must scale samples (both
+ * on the host and in the device) to satisfy the dynamic range needs. The peak value
+ * specifies a fraction of the maximum sample level (1.0 = 100%). Set peak to
+ * max_sample_level/full_scale_level to ensure optimum dynamic range.
*
* - underflow_policy: how the TX DSP should recover from underflow.
* Possible options are "next_burst" or "next_packet".
- * In the "next_burst" mode, the DSP drops incoming packets until a new burst is started.
- * In the "next_packet" mode, the DSP starts transmitting again at the next packet.
+ * In the "next_burst" mode, the DSP drops incoming packets until a new burst is
+ * started. In the "next_packet" mode, the DSP starts transmitting again at the next
+ * packet.
*
* - spp: (samples per packet) controls the size of RX packets.
* When not specified, the packets are always maximum frame size.
@@ -150,9 +149,9 @@ struct UHD_API stream_args_t{
* of `A:0 B:0`. This means the device has two channels available.
*
* Setting `stream_args.channels = (0, 1)` therefore configures MIMO streaming
- * from both channels. By switching the channel indexes, `stream_args.channels = (1, 0)`,
- * the channels are switched and the first channel of the USRP is mapped to
- * the second channel in the application.
+ * from both channels. By switching the channel indexes, `stream_args.channels = (1,
+ * 0)`, the channels are switched and the first channel of the USRP is mapped to the
+ * second channel in the application.
*
* If only a single channel is used for streaming, `stream_args.channels = (1,)` would
* only select a single channel (in this case, the second one). When streaming
@@ -167,7 +166,8 @@ struct UHD_API stream_args_t{
* It represents the layer between the samples on the host
* and samples inside the device's receive DSP processing.
*/
-class UHD_API rx_streamer : boost::noncopyable{
+class UHD_API rx_streamer : boost::noncopyable
+{
public:
typedef boost::shared_ptr<rx_streamer> sptr;
@@ -180,7 +180,7 @@ public:
virtual size_t get_max_num_samps(void) const = 0;
//! Typedef for a pointer to a single, or a collection of recv buffers
- typedef ref_vector<void *> buffs_type;
+ typedef ref_vector<void*> buffs_type;
/*!
* Receive buffers containing samples described by the metadata.
@@ -216,13 +216,11 @@ public:
* \param one_packet return after the first packet is received
* \return the number of samples received or 0 on error
*/
- virtual size_t recv(
- const buffs_type &buffs,
+ virtual size_t recv(const buffs_type& buffs,
const size_t nsamps_per_buff,
- rx_metadata_t &metadata,
- const double timeout = 0.1,
- const bool one_packet = false
- ) = 0;
+ rx_metadata_t& metadata,
+ const double timeout = 0.1,
+ const bool one_packet = false) = 0;
/*!
* Issue a stream command to the usrp device.
@@ -235,7 +233,7 @@ public:
*
* \param stream_cmd the stream command to issue
*/
- virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0;
+ virtual void issue_stream_cmd(const stream_cmd_t& stream_cmd) = 0;
};
/*!
@@ -243,7 +241,8 @@ public:
* It represents the layer between the samples on the host
* and samples inside the device's transmit DSP processing.
*/
-class UHD_API tx_streamer : boost::noncopyable{
+class UHD_API tx_streamer : boost::noncopyable
+{
public:
typedef boost::shared_ptr<tx_streamer> sptr;
@@ -256,7 +255,7 @@ public:
virtual size_t get_max_num_samps(void) const = 0;
//! Typedef for a pointer to a single, or a collection of send buffers
- typedef ref_vector<const void *> buffs_type;
+ typedef ref_vector<const void*> buffs_type;
/*!
* Send buffers containing samples described by the metadata.
@@ -279,12 +278,10 @@ public:
* \param timeout the timeout in seconds to wait on a packet
* \return the number of samples sent
*/
- virtual size_t send(
- const buffs_type &buffs,
+ virtual size_t send(const buffs_type& buffs,
const size_t nsamps_per_buff,
- const tx_metadata_t &metadata,
- const double timeout = 0.1
- ) = 0;
+ const tx_metadata_t& metadata,
+ const double timeout = 0.1) = 0;
/*!
* Receive and asynchronous message from this TX stream.
@@ -293,10 +290,9 @@ public:
* \return true when the async_metadata is valid, false for timeout
*/
virtual bool recv_async_msg(
- async_metadata_t &async_metadata, double timeout = 0.1
- ) = 0;
+ async_metadata_t& async_metadata, double timeout = 0.1) = 0;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_STREAM_HPP */
diff --git a/host/include/uhd/transport/bounded_buffer.hpp b/host/include/uhd/transport/bounded_buffer.hpp
index 76966ed2d..354cff5e2 100644
--- a/host/include/uhd/transport/bounded_buffer.hpp
+++ b/host/include/uhd/transport/bounded_buffer.hpp
@@ -10,102 +10,109 @@
#include <uhd/transport/bounded_buffer.ipp> //detail
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
+/*!
+ * Implement a templated bounded buffer:
+ * Used for passing elements between threads in a producer-consumer model.
+ * The bounded buffer implemented waits and timed waits with condition variables.
+ * The pop operation blocks on the bounded_buffer to become non empty.
+ * The push operation blocks on the bounded_buffer to become non full.
+ */
+template <typename elem_type> class bounded_buffer
+{
+public:
/*!
- * Implement a templated bounded buffer:
- * Used for passing elements between threads in a producer-consumer model.
- * The bounded buffer implemented waits and timed waits with condition variables.
- * The pop operation blocks on the bounded_buffer to become non empty.
- * The push operation blocks on the bounded_buffer to become non full.
+ * Create a new bounded buffer object.
+ * \param capacity the bounded_buffer capacity
*/
- template <typename elem_type> class bounded_buffer{
- public:
+ bounded_buffer(size_t capacity) : _detail(capacity)
+ {
+ /* NOP */
+ }
- /*!
- * Create a new bounded buffer object.
- * \param capacity the bounded_buffer capacity
- */
- bounded_buffer(size_t capacity):
- _detail(capacity)
- {
- /* NOP */
- }
-
- /*!
- * Push a new element into the bounded buffer immediately.
- * The element will not be pushed when the buffer is full.
- * \param elem the element reference pop to
- * \return false when the buffer is full
- */
- UHD_INLINE bool push_with_haste(const elem_type &elem){
- return _detail.push_with_haste(elem);
- }
+ /*!
+ * Push a new element into the bounded buffer immediately.
+ * The element will not be pushed when the buffer is full.
+ * \param elem the element reference pop to
+ * \return false when the buffer is full
+ */
+ UHD_INLINE bool push_with_haste(const elem_type& elem)
+ {
+ return _detail.push_with_haste(elem);
+ }
- /*!
- * Push a new element into the bounded buffer.
- * If the buffer is full prior to the push,
- * make room by popping the oldest element.
- * \param elem the new element to push
- * \return true if the element fit without popping for space
- */
- UHD_INLINE bool push_with_pop_on_full(const elem_type &elem){
- return _detail.push_with_pop_on_full(elem);
- }
+ /*!
+ * Push a new element into the bounded buffer.
+ * If the buffer is full prior to the push,
+ * make room by popping the oldest element.
+ * \param elem the new element to push
+ * \return true if the element fit without popping for space
+ */
+ UHD_INLINE bool push_with_pop_on_full(const elem_type& elem)
+ {
+ return _detail.push_with_pop_on_full(elem);
+ }
- /*!
- * Push a new element into the bounded_buffer.
- * Wait until the bounded_buffer becomes non-full.
- * \param elem the new element to push
- */
- UHD_INLINE void push_with_wait(const elem_type &elem){
- return _detail.push_with_wait(elem);
- }
+ /*!
+ * Push a new element into the bounded_buffer.
+ * Wait until the bounded_buffer becomes non-full.
+ * \param elem the new element to push
+ */
+ UHD_INLINE void push_with_wait(const elem_type& elem)
+ {
+ return _detail.push_with_wait(elem);
+ }
- /*!
- * Push a new element into the bounded_buffer.
- * Wait until the bounded_buffer becomes non-full or timeout.
- * \param elem the new element to push
- * \param timeout the timeout in seconds
- * \return false when the operation times out
- */
- UHD_INLINE bool push_with_timed_wait(const elem_type &elem, double timeout){
- return _detail.push_with_timed_wait(elem, timeout);
- }
+ /*!
+ * Push a new element into the bounded_buffer.
+ * Wait until the bounded_buffer becomes non-full or timeout.
+ * \param elem the new element to push
+ * \param timeout the timeout in seconds
+ * \return false when the operation times out
+ */
+ UHD_INLINE bool push_with_timed_wait(const elem_type& elem, double timeout)
+ {
+ return _detail.push_with_timed_wait(elem, timeout);
+ }
- /*!
- * Pop an element from the bounded buffer immediately.
- * The element will not be popped when the buffer is empty.
- * \param elem the element reference pop to
- * \return false when the buffer is empty
- */
- UHD_INLINE bool pop_with_haste(elem_type &elem){
- return _detail.pop_with_haste(elem);
- }
+ /*!
+ * Pop an element from the bounded buffer immediately.
+ * The element will not be popped when the buffer is empty.
+ * \param elem the element reference pop to
+ * \return false when the buffer is empty
+ */
+ UHD_INLINE bool pop_with_haste(elem_type& elem)
+ {
+ return _detail.pop_with_haste(elem);
+ }
- /*!
- * Pop an element from the bounded_buffer.
- * Wait until the bounded_buffer becomes non-empty.
- * \param elem the element reference pop to
- */
- UHD_INLINE void pop_with_wait(elem_type &elem){
- return _detail.pop_with_wait(elem);
- }
+ /*!
+ * Pop an element from the bounded_buffer.
+ * Wait until the bounded_buffer becomes non-empty.
+ * \param elem the element reference pop to
+ */
+ UHD_INLINE void pop_with_wait(elem_type& elem)
+ {
+ return _detail.pop_with_wait(elem);
+ }
- /*!
- * Pop an element from the bounded_buffer.
- * Wait until the bounded_buffer becomes non-empty or timeout.
- * \param elem the element reference pop to
- * \param timeout the timeout in seconds
- * \return false when the operation times out
- */
- UHD_INLINE bool pop_with_timed_wait(elem_type &elem, double timeout){
- return _detail.pop_with_timed_wait(elem, timeout);
- }
+ /*!
+ * Pop an element from the bounded_buffer.
+ * Wait until the bounded_buffer becomes non-empty or timeout.
+ * \param elem the element reference pop to
+ * \param timeout the timeout in seconds
+ * \return false when the operation times out
+ */
+ UHD_INLINE bool pop_with_timed_wait(elem_type& elem, double timeout)
+ {
+ return _detail.pop_with_timed_wait(elem, timeout);
+ }
- private: bounded_buffer_detail<elem_type> _detail;
- };
+private:
+ bounded_buffer_detail<elem_type> _detail;
+};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_HPP */
diff --git a/host/include/uhd/transport/buffer_pool.hpp b/host/include/uhd/transport/buffer_pool.hpp
index 0ad835c1b..769c78180 100644
--- a/host/include/uhd/transport/buffer_pool.hpp
+++ b/host/include/uhd/transport/buffer_pool.hpp
@@ -9,43 +9,41 @@
#define INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP
#include <uhd/config.hpp>
-#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
+
+namespace uhd { namespace transport {
+
+/*!
+ * A buffer pool manages memory for a homogeneous set of buffers.
+ * Each buffer is the pool start at a 16-byte alignment boundary.
+ */
+class UHD_API buffer_pool : boost::noncopyable
+{
+public:
+ typedef boost::shared_ptr<buffer_pool> sptr;
+ typedef void* ptr_type;
-namespace uhd{ namespace transport{
+ virtual ~buffer_pool(void) = 0;
/*!
- * A buffer pool manages memory for a homogeneous set of buffers.
- * Each buffer is the pool start at a 16-byte alignment boundary.
+ * Make a new buffer pool.
+ * \param num_buffs the number of buffers to allocate
+ * \param buff_size the size of each buffer in bytes
+ * \param alignment the alignment boundary in bytes
+ * \return a new buffer pool buff_size X num_buffs
*/
- class UHD_API buffer_pool : boost::noncopyable{
- public:
- typedef boost::shared_ptr<buffer_pool> sptr;
- typedef void * ptr_type;
-
- virtual ~buffer_pool(void) = 0;
-
- /*!
- * Make a new buffer pool.
- * \param num_buffs the number of buffers to allocate
- * \param buff_size the size of each buffer in bytes
- * \param alignment the alignment boundary in bytes
- * \return a new buffer pool buff_size X num_buffs
- */
- static sptr make(
- const size_t num_buffs,
- const size_t buff_size,
- const size_t alignment = 16
- );
-
- //! Get a pointer to the buffer start at the specified index
- virtual ptr_type at(const size_t index) const = 0;
-
- //! Get the number of buffers in this pool
- virtual size_t size(void) const = 0;
- };
-
-}} //namespace
+ static sptr make(
+ const size_t num_buffs, const size_t buff_size, const size_t alignment = 16);
+
+ //! Get a pointer to the buffer start at the specified index
+ virtual ptr_type at(const size_t index) const = 0;
+
+ //! Get the number of buffers in this pool
+ virtual size_t size(void) const = 0;
+};
+
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP */
diff --git a/host/include/uhd/transport/chdr.hpp b/host/include/uhd/transport/chdr.hpp
index 64260fbfc..f4b5c91f1 100644
--- a/host/include/uhd/transport/chdr.hpp
+++ b/host/include/uhd/transport/chdr.hpp
@@ -10,7 +10,7 @@
#include <uhd/transport/vrt_if_packet.hpp>
-namespace uhd{ namespace transport{ namespace vrt{
+namespace uhd { namespace transport { namespace vrt {
/*! \brief CHDR related function
*
@@ -34,70 +34,59 @@ namespace uhd{ namespace transport{ namespace vrt{
*
* In the unpacker, these values will be set accordingly.
*/
-namespace chdr{
+namespace chdr {
- //! The maximum number of 64-bit words in a CHDR header
- static const size_t max_if_hdr_words64 = 2; // CHDR + tsf (fractional timestamp)
+//! The maximum number of 64-bit words in a CHDR header
+static const size_t max_if_hdr_words64 = 2; // CHDR + tsf (fractional timestamp)
- /*!
- * Pack a CHDR header from metadata (big endian format).
- *
- * See \ref vrt_pack_contract, but `link_type` is assumed to be
- * `LINK_TYPE_CHDR`.
- *
- * \param packet_buff memory to write the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_pack_be(
- uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
+/*!
+ * Pack a CHDR header from metadata (big endian format).
+ *
+ * See \ref vrt_pack_contract, but `link_type` is assumed to be
+ * `LINK_TYPE_CHDR`.
+ *
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_pack_be(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
- /*!
- * Unpack a CHDR header to metadata (big endian format).
- *
- * See \ref vrt_unpack_contract, but `link_type` is assumed to be
- * `LINK_TYPE_CHDR`.
- *
- * \param packet_buff memory to read the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_unpack_be(
- const uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
+/*!
+ * Unpack a CHDR header to metadata (big endian format).
+ *
+ * See \ref vrt_unpack_contract, but `link_type` is assumed to be
+ * `LINK_TYPE_CHDR`.
+ *
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_unpack_be(
+ const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
- /*!
- * Pack a CHDR header from metadata (little endian format).
- *
- * See \ref vrt_pack_contract, but `link_type` is assumed to be
- * `LINK_TYPE_CHDR`.
- *
- * \param packet_buff memory to write the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_pack_le(
- uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
+/*!
+ * Pack a CHDR header from metadata (little endian format).
+ *
+ * See \ref vrt_pack_contract, but `link_type` is assumed to be
+ * `LINK_TYPE_CHDR`.
+ *
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_pack_le(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
- /*!
- * Unpack a CHDR header to metadata (little endian format).
- *
- * See \ref vrt_unpack_contract, but `link_type` is assumed to be
- * `LINK_TYPE_CHDR`.
- *
- * \param packet_buff memory to read the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_unpack_le(
- const uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
+/*!
+ * Unpack a CHDR header to metadata (little endian format).
+ *
+ * See \ref vrt_unpack_contract, but `link_type` is assumed to be
+ * `LINK_TYPE_CHDR`.
+ *
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_unpack_le(
+ const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
-} //namespace chdr
+} // namespace chdr
-}}} //namespace uhd::transport::vrt
+}}} // namespace uhd::transport::vrt
#endif /* INCLUDED_UHD_TRANSPORT_CHDR_HPP */
-
diff --git a/host/include/uhd/transport/if_addrs.hpp b/host/include/uhd/transport/if_addrs.hpp
index 0458fe4f7..b97c6156e 100644
--- a/host/include/uhd/transport/if_addrs.hpp
+++ b/host/include/uhd/transport/if_addrs.hpp
@@ -12,25 +12,26 @@
#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;
- };
-
- /*!
- * 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
+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;
+};
+
+/*!
+ * 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 uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP */
diff --git a/host/include/uhd/transport/muxed_zero_copy_if.hpp b/host/include/uhd/transport/muxed_zero_copy_if.hpp
index 0cf293a18..f69e6f288 100644
--- a/host/include/uhd/transport/muxed_zero_copy_if.hpp
+++ b/host/include/uhd/transport/muxed_zero_copy_if.hpp
@@ -8,11 +8,11 @@
#ifndef INCLUDED_LIBUHD_TRANSPORT_MUXED_ZERO_COPY_IF_HPP
#define INCLUDED_LIBUHD_TRANSPORT_MUXED_ZERO_COPY_IF_HPP
-#include <uhd/transport/zero_copy.hpp>
#include <uhd/config.hpp>
+#include <uhd/transport/zero_copy.hpp>
+#include <stdint.h>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
-#include <stdint.h>
namespace uhd { namespace transport {
@@ -25,7 +25,8 @@ namespace uhd { namespace transport {
* appropriate virtual streams with the given classifier
* function. A worker therad is spawned to handle the demuxing.
*/
-class muxed_zero_copy_if : private boost::noncopyable {
+class muxed_zero_copy_if : private boost::noncopyable
+{
public:
typedef boost::shared_ptr<muxed_zero_copy_if> sptr;
@@ -54,9 +55,11 @@ public:
virtual size_t get_num_dropped_frames() const = 0;
//! Make a new demuxer from a transport and parameters
- static sptr make(zero_copy_if::sptr base_xport, stream_classifier_fn classify_fn, size_t max_streams);
+ static sptr make(zero_copy_if::sptr base_xport,
+ stream_classifier_fn classify_fn,
+ size_t max_streams);
};
-}} //namespace uhd::transport
+}} // namespace uhd::transport
#endif /* INCLUDED_LIBUHD_TRANSPORT_MUXED_ZERO_COPY_IF_HPP */
diff --git a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
index bf309ad28..536210c31 100644
--- a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
+++ b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
@@ -8,52 +8,54 @@
#ifndef INCLUDED_RPC_CLIENT_HPP
#define INCLUDED_RPC_CLIENT_HPP
+#include "rpc_common.hpp"
+#include <uhd/utils/log.hpp>
#include <boost/asio.hpp>
#include <boost/smart_ptr.hpp>
-#include <boost/thread/thread.hpp>
#include <boost/thread/condition_variable.hpp>
-#include "rpc_common.hpp"
-#include <uhd/utils/log.hpp>
+#include <boost/thread/thread.hpp>
namespace uhd { namespace usrprio_rpc {
class rpc_client : private boost::noncopyable
{
public:
- static const uint32_t CURRENT_VERSION = 1;
+ static const uint32_t CURRENT_VERSION = 1;
static const uint32_t OLDEST_COMPATIBLE_VERSION = 1;
- rpc_client(
- const std::string& server,
+ rpc_client(const std::string& server,
const std::string& port,
uint32_t process_id,
uint32_t host_id);
~rpc_client();
- const boost::system::error_code& call(
- func_id_t func_id,
+ const boost::system::error_code& call(func_id_t func_id,
const func_args_writer_t& in_args,
- func_args_reader_t &out_args,
+ func_args_reader_t& out_args,
boost::posix_time::milliseconds timeout);
- inline const boost::system::error_code& status() const {
+ inline const boost::system::error_code& status() const
+ {
return _exec_err;
}
/* [Possible boost::system::error_code values]
* boost::asio::error::connection_aborted: Network connection failure
* boost::asio::error::eof: Network connection closed cleanly
- * boost::asio::error::connection_refused: Software handshake failure (version mismatch, etc)
- * boost::asio::error::timed_out: RPC call timed out
+ * boost::asio::error::connection_refused: Software handshake failure (version
+ * mismatch, etc) boost::asio::error::timed_out: RPC call timed out
* boost::asio::error::operation_aborted: RPC call aborted but connection alive
*/
private:
- void _handle_response_hdr(const boost::system::error_code& err, size_t transferred, size_t expected);
- void _handle_response_data(const boost::system::error_code& err, size_t transferred, size_t expected);
+ void _handle_response_hdr(
+ const boost::system::error_code& err, size_t transferred, size_t expected);
+ void _handle_response_data(
+ const boost::system::error_code& err, size_t transferred, size_t expected);
void _wait_for_next_response_header();
- inline void _stop_io_service() {
+ inline void _stop_io_service()
+ {
if (_io_service_thread.get()) {
UHD_LOGGER_INFO("NIRIO") << "rpc_client stopping...";
_io_service.stop();
@@ -63,22 +65,22 @@ private:
}
}
- //Services
- boost::asio::io_service _io_service;
- boost::scoped_ptr<boost::thread> _io_service_thread;
- boost::asio::ip::tcp::socket _socket;
- //Handshake info
- hshake_args_t _hshake_args_client;
- hshake_args_t _hshake_args_server;
- //In-out function args
- func_xport_buf_t _request;
- func_xport_buf_t _response;
- //Synchronization
- boost::mutex _mutex;
- boost::condition_variable _exec_gate;
- boost::system::error_code _exec_err;
+ // Services
+ boost::asio::io_service _io_service;
+ boost::scoped_ptr<boost::thread> _io_service_thread;
+ boost::asio::ip::tcp::socket _socket;
+ // Handshake info
+ hshake_args_t _hshake_args_client;
+ hshake_args_t _hshake_args_server;
+ // In-out function args
+ func_xport_buf_t _request;
+ func_xport_buf_t _response;
+ // Synchronization
+ boost::mutex _mutex;
+ boost::condition_variable _exec_gate;
+ boost::system::error_code _exec_err;
};
-}}
+}} // namespace uhd::usrprio_rpc
#endif /* INCLUDED_RPC_CLIENT_HPP */
diff --git a/host/include/uhd/transport/nirio/rpc/rpc_common.hpp b/host/include/uhd/transport/nirio/rpc/rpc_common.hpp
index c1261f634..2384c0f61 100644
--- a/host/include/uhd/transport/nirio/rpc/rpc_common.hpp
+++ b/host/include/uhd/transport/nirio/rpc/rpc_common.hpp
@@ -10,139 +10,150 @@
#define USE_BINARY_ARCHIVE 0
-#include <string>
#include <iostream>
#include <sstream>
+#include <string>
#include <vector>
#if (USE_BINARY_ARCHIVE)
- #include <boost/archive/binary_oarchive.hpp>
- #include <boost/archive/binary_iarchive.hpp>
+# include <boost/archive/binary_iarchive.hpp>
+# include <boost/archive/binary_oarchive.hpp>
#else
- #include <boost/archive/text_oarchive.hpp>
- #include <boost/archive/text_iarchive.hpp>
+# include <boost/archive/text_iarchive.hpp>
+# include <boost/archive/text_oarchive.hpp>
#endif
#include <stdint.h>
namespace uhd { namespace usrprio_rpc {
//[Over-the-wire] IDs
-typedef int32_t func_id_t;
+typedef int32_t func_id_t;
typedef uint64_t client_id_t;
#define build_client_id(host_id, process_id) \
((static_cast<uint64_t>(host_id) << 32) | static_cast<uint64_t>(process_id))
-#define get_process_id_from_client_id(client_id) \
- (static_cast<int32_t>(client_id))
-#define get_host_id_from_client_id(client_id) \
- (static_cast<uint32_t>(client_id >> 32))
+#define get_process_id_from_client_id(client_id) (static_cast<int32_t>(client_id))
+#define get_host_id_from_client_id(client_id) (static_cast<uint32_t>(client_id >> 32))
//[Over-the-wire] Handshake format
-struct hshake_args_t {
+struct hshake_args_t
+{
uint32_t version;
uint32_t oldest_comp_version;
- int32_t boost_archive_version;
- client_id_t client_id;
+ int32_t boost_archive_version;
+ client_id_t client_id;
};
//[Over-the-wire] Header for RPC request and response
-class func_args_header_t {
+class func_args_header_t
+{
public:
- func_id_t func_id;
- client_id_t client_id;
+ func_id_t func_id;
+ client_id_t client_id;
uint32_t func_args_size;
- static bool match_function(const func_args_header_t& a, const func_args_header_t& b) {
+ static bool match_function(const func_args_header_t& a, const func_args_header_t& b)
+ {
return ((a.func_id == b.func_id) && (a.client_id == b.client_id));
}
};
//[Internal] Storage for RPC header and arguments
-class func_xport_buf_t {
+class func_xport_buf_t
+{
public:
- func_args_header_t header;
- std::vector<char> data;
+ func_args_header_t header;
+ std::vector<char> data;
};
//[Internal] Serializer for RPC input parameters
-class func_args_writer_t {
+class func_args_writer_t
+{
public:
func_args_writer_t() : _stream(), _archive(_stream, boost::archive::no_header) {}
- template<typename data_t>
- void push(const data_t& d) {
+ template <typename data_t> void push(const data_t& d)
+ {
_archive << d;
}
- template<typename data_t>
- func_args_writer_t& operator<< (const data_t& data) {
+ template <typename data_t> func_args_writer_t& operator<<(const data_t& data)
+ {
push(data);
return *this;
}
- void store(std::vector<char>& data) const {
+ void store(std::vector<char>& data) const
+ {
const std::string& str = _stream.str();
data.resize(str.length());
data.assign((char*)str.c_str(), ((char*)str.c_str()) + str.length());
}
private:
- std::ostringstream _stream;
+ std::ostringstream _stream;
#if (USE_BINARY_ARCHIVE)
boost::archive::binary_oarchive _archive;
#else
- boost::archive::text_oarchive _archive;
+ boost::archive::text_oarchive _archive;
#endif
};
//[Internal] Deserializer for RPC output parameters
-class func_args_reader_t {
+class func_args_reader_t
+{
public:
func_args_reader_t() : _stream(), _archive() {}
- template<typename data_t>
- void pull(data_t& d) const {
- if (_archive) (*_archive) >> d;
+ template <typename data_t> void pull(data_t& d) const
+ {
+ if (_archive)
+ (*_archive) >> d;
}
- template<typename data_t>
- const func_args_reader_t& operator>> (data_t& data) const {
+ template <typename data_t> const func_args_reader_t& operator>>(data_t& data) const
+ {
pull(data);
return *this;
}
- void load(const std::vector<char>& data) {
+ void load(const std::vector<char>& data)
+ {
_stream.str(std::string(data.begin(), data.end()));
#if (USE_BINARY_ARCHIVE)
- _archive.reset(new boost::archive::binary_iarchive(_stream, boost::archive::no_header));
+ _archive.reset(
+ new boost::archive::binary_iarchive(_stream, boost::archive::no_header));
#else
- _archive.reset(new boost::archive::text_iarchive(_stream, boost::archive::no_header));
+ _archive.reset(
+ new boost::archive::text_iarchive(_stream, boost::archive::no_header));
#endif
}
private:
- std::istringstream _stream;
+ std::istringstream _stream;
#if (USE_BINARY_ARCHIVE)
- boost::scoped_ptr<boost::archive::binary_iarchive> _archive;
+ boost::scoped_ptr<boost::archive::binary_iarchive> _archive;
#else
- boost::scoped_ptr<boost::archive::text_iarchive> _archive;
+ boost::scoped_ptr<boost::archive::text_iarchive> _archive;
#endif
};
-class boost_serialization_archive_utils {
+class boost_serialization_archive_utils
+{
public:
- static int32_t get_version() {
- #if (USE_BINARY_ARCHIVE)
+ static int32_t get_version()
+ {
+#if (USE_BINARY_ARCHIVE)
typedef boost::archive::binary_oarchive archive_t;
- #else
- typedef boost::archive::text_oarchive archive_t;
- #endif
+#else
+ typedef boost::archive::text_oarchive archive_t;
+#endif
std::ostringstream stream;
archive_t dummy_archive(stream, boost::archive::no_header);
return static_cast<int32_t>(dummy_archive.get_library_version());
}
};
-}}
+}} // namespace uhd::usrprio_rpc
#undef USE_BINARY_ARCHIVE
diff --git a/host/include/uhd/transport/nirio/rpc/usrprio_rpc_client.hpp b/host/include/uhd/transport/nirio/rpc/usrprio_rpc_client.hpp
index b05cf0d5d..1d67d9286 100644
--- a/host/include/uhd/transport/nirio/rpc/usrprio_rpc_client.hpp
+++ b/host/include/uhd/transport/nirio/rpc/usrprio_rpc_client.hpp
@@ -8,51 +8,47 @@
#ifndef INCLUDED_USRPRIO_RPC_CLIENT_HPP
#define INCLUDED_USRPRIO_RPC_CLIENT_HPP
-#include <uhd/transport/nirio/rpc/rpc_common.hpp>
#include <uhd/transport/nirio/rpc/rpc_client.hpp>
+#include <uhd/transport/nirio/rpc/rpc_common.hpp>
#include <uhd/transport/nirio/rpc/usrprio_rpc_common.hpp>
#include <uhd/transport/nirio/status.h>
namespace uhd { namespace usrprio_rpc {
-class UHD_API usrprio_rpc_client {
+class UHD_API usrprio_rpc_client
+{
public:
- usrprio_rpc_client(
- std::string server,
- std::string port);
+ usrprio_rpc_client(std::string server, std::string port);
~usrprio_rpc_client();
- inline void set_rpc_timeout(boost::posix_time::milliseconds timeout_in_ms) {
+ inline void set_rpc_timeout(boost::posix_time::milliseconds timeout_in_ms)
+ {
_timeout = timeout_in_ms;
}
- inline nirio_status get_ctor_status() {
+ inline nirio_status get_ctor_status()
+ {
return _ctor_status;
}
- nirio_status niusrprio_enumerate(
- NIUSRPRIO_ENUMERATE_ARGS);
- nirio_status niusrprio_open_session(
- NIUSRPRIO_OPEN_SESSION_ARGS);
- nirio_status niusrprio_close_session(
- NIUSRPRIO_CLOSE_SESSION_ARGS);
- nirio_status niusrprio_reset_device(
- NIUSRPRIO_RESET_SESSION_ARGS);
+ nirio_status niusrprio_enumerate(NIUSRPRIO_ENUMERATE_ARGS);
+ nirio_status niusrprio_open_session(NIUSRPRIO_OPEN_SESSION_ARGS);
+ nirio_status niusrprio_close_session(NIUSRPRIO_CLOSE_SESSION_ARGS);
+ nirio_status niusrprio_reset_device(NIUSRPRIO_RESET_SESSION_ARGS);
nirio_status niusrprio_download_bitstream_to_fpga(
NIUSRPRIO_DOWNLOAD_BITSTREAM_TO_FPGA_ARGS);
- nirio_status niusrprio_get_interface_path(
- NIUSRPRIO_GET_INTERFACE_PATH_ARGS);
- nirio_status niusrprio_download_fpga_to_flash(
- NIUSRPRIO_DOWNLOAD_FPGA_TO_FLASH_ARGS);
+ nirio_status niusrprio_get_interface_path(NIUSRPRIO_GET_INTERFACE_PATH_ARGS);
+ nirio_status niusrprio_download_fpga_to_flash(NIUSRPRIO_DOWNLOAD_FPGA_TO_FLASH_ARGS);
private:
- static nirio_status _boost_error_to_nirio_status(const boost::system::error_code& err);
+ static nirio_status _boost_error_to_nirio_status(
+ const boost::system::error_code& err);
- rpc_client _rpc_client;
+ rpc_client _rpc_client;
boost::posix_time::milliseconds _timeout;
- nirio_status _ctor_status;
+ nirio_status _ctor_status;
};
-}}
+}} // namespace uhd::usrprio_rpc
#endif /* INCLUDED_USRPRIO_RPC_CLIENT_HPP */
diff --git a/host/include/uhd/transport/nirio/rpc/usrprio_rpc_common.hpp b/host/include/uhd/transport/nirio/rpc/usrprio_rpc_common.hpp
index 12cf5f385..71d8f7047 100644
--- a/host/include/uhd/transport/nirio/rpc/usrprio_rpc_common.hpp
+++ b/host/include/uhd/transport/nirio/rpc/usrprio_rpc_common.hpp
@@ -12,9 +12,9 @@
namespace uhd { namespace usrprio_rpc {
-//Function IDs
+// Function IDs
-static const func_id_t NIUSRPRIO_FUNC_BASE = 0x100;
+static const func_id_t NIUSRPRIO_FUNC_BASE = 0x100;
static const func_id_t NIUSRPRIO_ENUMERATE = NIUSRPRIO_FUNC_BASE + 0;
static const func_id_t NIUSRPRIO_OPEN_SESSION = NIUSRPRIO_FUNC_BASE + 1;
@@ -24,52 +24,44 @@ static const func_id_t NIUSRPRIO_DOWNLOAD_BITSTREAM_TO_FPGA = NIUSRPRIO_FUNC_BAS
static const func_id_t NIUSRPRIO_GET_INTERFACE_PATH = NIUSRPRIO_FUNC_BASE + 5;
static const func_id_t NIUSRPRIO_DOWNLOAD_FPGA_TO_FLASH = NIUSRPRIO_FUNC_BASE + 6;
-//Function Args
+// Function Args
-struct usrprio_device_info {
+struct usrprio_device_info
+{
uint32_t interface_num;
- std::string resource_name;
- std::string pcie_serial_num;
- std::string interface_path;
+ std::string resource_name;
+ std::string pcie_serial_num;
+ std::string interface_path;
- template <typename Archive>
- void serialize(Archive& ar, const unsigned int version)
+ template <typename Archive> void serialize(Archive& ar, const unsigned int version)
{
- if (version || !version) { //Suppress unused warning
- ar & interface_num;
- ar & resource_name;
- ar & pcie_serial_num;
- ar & interface_path;
+ if (version || !version) { // Suppress unused warning
+ ar& interface_num;
+ ar& resource_name;
+ ar& pcie_serial_num;
+ ar& interface_path;
}
}
};
typedef std::vector<usrprio_device_info> usrprio_device_info_vtr;
-#define NIUSRPRIO_ENUMERATE_ARGS \
- usrprio_device_info_vtr& device_info_vtr
+#define NIUSRPRIO_ENUMERATE_ARGS usrprio_device_info_vtr& device_info_vtr
-#define NIUSRPRIO_OPEN_SESSION_ARGS \
- const std::string& resource, \
- const std::string& path, \
- const std::string& signature, \
- const uint16_t& download_fpga
+#define NIUSRPRIO_OPEN_SESSION_ARGS \
+ const std::string &resource, const std::string &path, const std::string &signature, \
+ const uint16_t &download_fpga
-#define NIUSRPRIO_CLOSE_SESSION_ARGS \
- const std::string& resource
+#define NIUSRPRIO_CLOSE_SESSION_ARGS const std::string& resource
-#define NIUSRPRIO_RESET_SESSION_ARGS \
- const std::string& resource
+#define NIUSRPRIO_RESET_SESSION_ARGS const std::string& resource
-#define NIUSRPRIO_DOWNLOAD_BITSTREAM_TO_FPGA_ARGS \
- const std::string& resource
+#define NIUSRPRIO_DOWNLOAD_BITSTREAM_TO_FPGA_ARGS const std::string& resource
-#define NIUSRPRIO_GET_INTERFACE_PATH_ARGS \
- const std::string& resource, \
- std::string& interface_path
+#define NIUSRPRIO_GET_INTERFACE_PATH_ARGS \
+ const std::string &resource, std::string &interface_path
-#define NIUSRPRIO_DOWNLOAD_FPGA_TO_FLASH_ARGS \
- const std::string& resource, \
- const std::string& bitstream_path
-}}
+#define NIUSRPRIO_DOWNLOAD_FPGA_TO_FLASH_ARGS \
+ const std::string &resource, const std::string &bitstream_path
+}} // namespace uhd::usrprio_rpc
#endif /* INCLUDED_USRPRIO_RPC_COMMON_HPP */
diff --git a/host/include/uhd/transport/nirio_zero_copy.hpp b/host/include/uhd/transport/nirio_zero_copy.hpp
index bc055d636..b5e4dea38 100644
--- a/host/include/uhd/transport/nirio_zero_copy.hpp
+++ b/host/include/uhd/transport/nirio_zero_copy.hpp
@@ -8,27 +8,26 @@
#ifndef INCLUDED_UHD_TRANSPORT_NIRIO_ZERO_COPY_HPP
#define INCLUDED_UHD_TRANSPORT_NIRIO_ZERO_COPY_HPP
-#include <uhd/transport/nirio/niusrprio_session.h>
#include <uhd/config.hpp>
+#include <uhd/transport/nirio/niusrprio_session.h>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/device_addr.hpp>
-#include <boost/shared_ptr.hpp>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
-class UHD_API nirio_zero_copy : public virtual zero_copy_if{
+class UHD_API nirio_zero_copy : public virtual zero_copy_if
+{
public:
typedef boost::shared_ptr<nirio_zero_copy> sptr;
- static sptr make(
- uhd::niusrprio::niusrprio_session::sptr fpga_session,
+ static sptr make(uhd::niusrprio::niusrprio_session::sptr fpga_session,
const uint32_t instance,
- const zero_copy_xport_params &default_buff_args,
- const device_addr_t &hints = device_addr_t()
- );
+ const zero_copy_xport_params& default_buff_args,
+ const device_addr_t& hints = device_addr_t());
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_NIRIO_ZERO_COPY_HPP */
diff --git a/host/include/uhd/transport/tcp_zero_copy.hpp b/host/include/uhd/transport/tcp_zero_copy.hpp
index d250f675a..4db68cec8 100644
--- a/host/include/uhd/transport/tcp_zero_copy.hpp
+++ b/host/include/uhd/transport/tcp_zero_copy.hpp
@@ -13,7 +13,7 @@
#include <uhd/types/device_addr.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
/*!
* The zero copy TCP transport.
@@ -37,13 +37,11 @@ struct UHD_API tcp_zero_copy : public virtual zero_copy_if
* \param port a string representing the destination port
* \param hints optional parameters to pass to the underlying transport
*/
- static zero_copy_if::sptr make(
- const std::string &addr,
- const std::string &port,
- const device_addr_t &hints = device_addr_t()
- );
+ static zero_copy_if::sptr make(const std::string& addr,
+ const std::string& port,
+ const device_addr_t& hints = device_addr_t());
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_TCP_ZERO_COPY_HPP */
diff --git a/host/include/uhd/transport/udp_constants.hpp b/host/include/uhd/transport/udp_constants.hpp
index 5d3f5dea0..6fe26424f 100644
--- a/host/include/uhd/transport/udp_constants.hpp
+++ b/host/include/uhd/transport/udp_constants.hpp
@@ -10,7 +10,8 @@
// Constants related to UDP (over Ethernet)
-static const size_t IP_PROTOCOL_MIN_MTU_SIZE = 576; //bytes
-static const size_t IP_PROTOCOL_UDP_PLUS_IP_HEADER = 28; //bytes. Note that this is the minimum value!
+static const size_t IP_PROTOCOL_MIN_MTU_SIZE = 576; // bytes
+static const size_t IP_PROTOCOL_UDP_PLUS_IP_HEADER =
+ 28; // bytes. Note that this is the minimum value!
#endif /* INCLUDED_UHD_TRANSPORT_UDP_CONSTANTS_HPP */
diff --git a/host/include/uhd/transport/udp_simple.hpp b/host/include/uhd/transport/udp_simple.hpp
index 3683ed8e0..19164d80b 100644
--- a/host/include/uhd/transport/udp_simple.hpp
+++ b/host/include/uhd/transport/udp_simple.hpp
@@ -11,19 +11,21 @@
#include <uhd/config.hpp>
#include <uhd/types/serial.hpp>
#include <boost/asio/buffer.hpp>
-#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
-class UHD_API udp_simple : boost::noncopyable{
+class UHD_API udp_simple : boost::noncopyable
+{
public:
typedef boost::shared_ptr<udp_simple> sptr;
virtual ~udp_simple(void) = 0;
//! The maximum number of bytes per udp packet.
- static const size_t mtu = 1500 - 20 - 8; //default ipv4 mtu - ipv4 header - udp header
+ static const size_t mtu = 1500 - 20 - 8; // default ipv4 mtu - ipv4 header - udp
+ // header
/*!
* Make a new connected udp transport:
@@ -38,7 +40,7 @@ public:
* \param addr a string representing the destination address
* \param port a string representing the destination port
*/
- static sptr make_connected(const std::string &addr, const std::string &port);
+ static sptr make_connected(const std::string& addr, const std::string& port);
/*!
* Make a new broadcasting udp transport:
@@ -52,7 +54,7 @@ public:
* \param addr a string representing the destination address
* \param port a string representing the destination port
*/
- static sptr make_broadcast(const std::string &addr, const std::string &port);
+ static sptr make_broadcast(const std::string& addr, const std::string& port);
/*!
* Make a UART interface from a UDP transport.
@@ -67,7 +69,7 @@ public:
* \param buff single asio buffer
* \return the number of bytes sent
*/
- virtual size_t send(const boost::asio::const_buffer &buff) = 0;
+ virtual size_t send(const boost::asio::const_buffer& buff) = 0;
/*!
* Receive into the provided buffer.
@@ -76,7 +78,8 @@ public:
* \param timeout the timeout in seconds
* \return the number of bytes received or zero on timeout
*/
- virtual size_t recv(const boost::asio::mutable_buffer &buff, double timeout = 0.1) = 0;
+ virtual size_t recv(
+ const boost::asio::mutable_buffer& buff, double timeout = 0.1) = 0;
/*!
* Get the last IP address as seen by recv().
@@ -90,6 +93,6 @@ public:
virtual std::string get_send_addr(void) = 0;
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_UDP_SIMPLE_HPP */
diff --git a/host/include/uhd/transport/udp_zero_copy.hpp b/host/include/uhd/transport/udp_zero_copy.hpp
index ff55a58da..2fedad99a 100644
--- a/host/include/uhd/transport/udp_zero_copy.hpp
+++ b/host/include/uhd/transport/udp_zero_copy.hpp
@@ -13,7 +13,7 @@
#include <uhd/types/device_addr.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
/*!
* A zero copy udp transport provides an efficient way to handle data.
@@ -25,11 +25,13 @@ namespace uhd{ namespace transport{
* If no platform specific solution is available, make returns a boost asio
* implementation that wraps the functionality around a standard send/recv calls.
*/
-class UHD_API udp_zero_copy : public virtual zero_copy_if{
+class UHD_API udp_zero_copy : public virtual zero_copy_if
+{
public:
- struct buff_params {
- size_t recv_buff_size;
- size_t send_buff_size;
+ struct buff_params
+ {
+ size_t recv_buff_size;
+ size_t send_buff_size;
};
typedef boost::shared_ptr<udp_zero_copy> sptr;
@@ -50,13 +52,11 @@ public:
* \param[out] buff_params_out Returns the actual buffer sizes
* \param hints optional parameters to pass to the underlying transport
*/
- static sptr make(
- const std::string &addr,
- const std::string &port,
- const zero_copy_xport_params &default_buff_args,
+ static sptr make(const std::string& addr,
+ const std::string& port,
+ const zero_copy_xport_params& default_buff_args,
udp_zero_copy::buff_params& buff_params_out,
- const device_addr_t &hints = device_addr_t()
- );
+ const device_addr_t& hints = device_addr_t());
/*! Return the local port of the UDP connection
*
@@ -74,6 +74,6 @@ public:
virtual std::string get_local_addr(void) const = 0;
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_UDP_ZERO_COPY_HPP */
diff --git a/host/include/uhd/transport/usb_control.hpp b/host/include/uhd/transport/usb_control.hpp
index 53c35881a..3fc6d0394 100644
--- a/host/include/uhd/transport/usb_control.hpp
+++ b/host/include/uhd/transport/usb_control.hpp
@@ -12,7 +12,8 @@
namespace uhd { namespace transport {
-class UHD_API usb_control : boost::noncopyable {
+class UHD_API usb_control : boost::noncopyable
+{
public:
typedef boost::shared_ptr<usb_control> sptr;
@@ -47,14 +48,14 @@ public:
* \return number of bytes submitted or error code
*/
virtual int submit(uint8_t request_type,
- uint8_t request,
- uint16_t value,
- uint16_t index,
- unsigned char *buff,
- uint16_t length,
- uint32_t timeout = 0) = 0;
+ uint8_t request,
+ uint16_t value,
+ uint16_t index,
+ unsigned char* buff,
+ uint16_t length,
+ uint32_t timeout = 0) = 0;
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP */
diff --git a/host/include/uhd/transport/usb_device_handle.hpp b/host/include/uhd/transport/usb_device_handle.hpp
index 9b0806b30..3cd740771 100644
--- a/host/include/uhd/transport/usb_device_handle.hpp
+++ b/host/include/uhd/transport/usb_device_handle.hpp
@@ -9,9 +9,9 @@
#define INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP
#include <uhd/config.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
#include <vector>
namespace uhd { namespace transport {
@@ -28,7 +28,8 @@ namespace uhd { namespace transport {
* a true descriptor serial number string. This interface returns the
* actual string descriptor.
*/
-class UHD_API usb_device_handle : boost::noncopyable {
+class UHD_API usb_device_handle : boost::noncopyable
+{
public:
typedef boost::shared_ptr<usb_device_handle> sptr;
typedef std::pair<uint16_t, uint16_t> vid_pid_pair_t;
@@ -75,12 +76,14 @@ public:
* Return a vector of USB devices on this host
* \return a vector of USB device handles that match vid and pid
*/
- static std::vector<usb_device_handle::sptr> get_device_list(uint16_t vid, uint16_t pid);
- static std::vector<usb_device_handle::sptr> get_device_list(const std::vector<usb_device_handle::vid_pid_pair_t>& vid_pid_pair_list);
+ static std::vector<usb_device_handle::sptr> get_device_list(
+ uint16_t vid, uint16_t pid);
+ static std::vector<usb_device_handle::sptr> get_device_list(
+ const std::vector<usb_device_handle::vid_pid_pair_t>& vid_pid_pair_list);
-}; //namespace usb
+}; // namespace usb
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP */
diff --git a/host/include/uhd/transport/usb_zero_copy.hpp b/host/include/uhd/transport/usb_zero_copy.hpp
index 7ce85e54a..d78807768 100644
--- a/host/include/uhd/transport/usb_zero_copy.hpp
+++ b/host/include/uhd/transport/usb_zero_copy.hpp
@@ -24,7 +24,8 @@ namespace uhd { namespace transport {
* If no platform specific solution is available, make returns a boost asio
* implementation that wraps functionality around standard send/recv calls.
*/
-class UHD_API usb_zero_copy : public virtual zero_copy_if {
+class UHD_API usb_zero_copy : public virtual zero_copy_if
+{
public:
typedef boost::shared_ptr<usb_zero_copy> sptr;
@@ -45,16 +46,14 @@ public:
* \param hints optional parameters to pass to the underlying transport
* \return a new zero copy USB object
*/
- static sptr make(
- usb_device_handle::sptr handle,
+ static sptr make(usb_device_handle::sptr handle,
const int recv_interface,
const unsigned char recv_endpoint,
const int send_interface,
const unsigned char send_endpoint,
- const device_addr_t &hints = device_addr_t()
- );
+ const device_addr_t& hints = device_addr_t());
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP */
diff --git a/host/include/uhd/transport/vrt_if_packet.hpp b/host/include/uhd/transport/vrt_if_packet.hpp
index 07792f13f..f357b8ceb 100644
--- a/host/include/uhd/transport/vrt_if_packet.hpp
+++ b/host/include/uhd/transport/vrt_if_packet.hpp
@@ -12,191 +12,189 @@
#include <stdint.h>
#include <cstddef> //size_t
-namespace uhd{ namespace transport{
-
-namespace vrt{
-
- //! The maximum number of 32-bit words in the vrlp link layer
- static const size_t num_vrl_words32 = 3;
-
- //! The maximum number of 32-bit words in a vrt if packet header
- static const size_t max_if_hdr_words32 = 7; //hdr+sid+cid+tsi+tsf
-
- /*!
- * Definition for fields that can be packed into a vrt if header.
- * The size fields are used for input and output depending upon
- * the operation used (ie the pack or unpack function call).
- */
- struct UHD_API if_packet_info_t
- {
- if_packet_info_t(void);
-
- //link layer type - always set for pack and unpack
- enum link_type_t
- {
- LINK_TYPE_NONE = 0x0,
- LINK_TYPE_CHDR = 0x1,
- LINK_TYPE_VRLP = 0x2
- } link_type;
-
- //packet type
- enum packet_type_t
- {
- // VRT language:
- PACKET_TYPE_DATA = 0x0,
- PACKET_TYPE_IF_EXT = 0x1,
- PACKET_TYPE_CONTEXT = 0x2, //extension context: has_sid = true
-
- // CHDR language:
- //PACKET_TYPE_DATA = 0x0, // Data
- PACKET_TYPE_FC = 0x1, // Flow control
- PACKET_TYPE_ACK = 0x1, // Flow control (ack)
- PACKET_TYPE_CMD = 0x2, // Command
- PACKET_TYPE_RESP = 0x3, // Command response
- PACKET_TYPE_ERROR = 0x3 // Command response: Error (the EOB bit is raised in this case)
- } packet_type;
-
- //size fields
- size_t num_payload_words32; //required in pack, derived in unpack
- size_t num_payload_bytes; //required in pack, derived in unpack
- size_t num_header_words32; //derived in pack, derived in unpack
- size_t num_packet_words32; //derived in pack, required in unpack
-
- //header fields
- size_t packet_count;
- //! Asserted for start- or end-of-burst
- bool sob, eob;
- //! This is asserted for command responses that are errors (CHDR only)
- bool error;
- //! This is asserted for flow control packets are ACKS (CHDR only)
- bool fc_ack;
-
- //optional fields
- //! Stream ID (SID). See uhd::sid_t
- bool has_sid; uint32_t sid;
- //! Class ID.
- bool has_cid; uint64_t cid;
- //! Integer timestamp
- bool has_tsi; uint32_t tsi;
- //! Fractional timestamp
- bool has_tsf; uint64_t tsf;
- //! Trailer
- bool has_tlr; uint32_t tlr;
- };
-
- /*!
- * Pack a vrt header from metadata (big endian format).
- *
- * \section vrt_pack_contract Packing contract
- *
- * \subsection vrt_pack_contract_reqs Requirements:
- * - packet_buff points to a valid address space with enough space to write
- * the entire buffer, regardless of its length. At the very least, it must
- * be able to hold an entire header.
- * - `if_packet_info` has the following members set to correct values:
- * - `has_*` members all set accordingly
- * - For every true `has_*` member, the corresponding variable holds a valid
- * value (e.g. if `has_sid` is true, `sid` contains a valid SID)
- * - `num_payload_bytes` and `num_payload_words32` are both set to the correct values
- *
- * \subsection vrt_pack_contract_res Result:
- * - `packet_buff` now points to a valid header that can be sent over the transport
- * without further modification
- * - The following members on `if_packet_info` are set:
- * - `num_header_words32`
- * - `num_packet_words32`
- *
- * \param packet_buff memory to write the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_pack_be(
- uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
-
- /*!
- * Unpack a vrt header to metadata (big endian format).
- *
- * \section vrt_unpack_contract Unpacking contract
- *
- * \subsection vrt_unpack_contract_reqs Requirements
- * - `packet_buff` points to a readable address space with a
- * CHDR packet, starting at the header. `packet_buff[0]` *must* always
- * point to a valid first word of the header. This implies that num_packet_words32
- * must be at least 1.
- * - `if_packet_info` has the following members set to correct values:
- * - `num_packet_words32`. This means all values `packet_buff[0]`
- * through `packet_buff[if_packet_info.num_packet_words32-1]` are
- * readable words from this packet.
- * - `link_type`
- *
- * \subsection vrt_unpack_contract_res Result
- * - `if_packet_info` now has the following values set to correct values:
- * - `packet_type`
- * - `num_payload_bytes`
- * - `num_payload_words32`
- * - `num_header_words32`
- * - `has_*`
- * - `sob`, `eob`, `error`, `cid`, `sid` (if applicable)
- * - `tsf`, `tsi` (if applicable)
- *
- * \subsection Exceptions
- * - If the header is invalid, but the requirements are still met,
- * will throw a uhd::value_error.
- *
- * \param packet_buff memory to read the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_unpack_be(
- const uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
-
- /*!
- * Pack a vrt header from metadata (little endian format).
- *
- * See \ref vrt_pack_contract.
- *
- * \param packet_buff memory to write the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_pack_le(
- uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
-
- /*!
- * Unpack a vrt header to metadata (little endian format).
- *
- * See \ref vrt_unpack_contract.
- *
- * \param packet_buff memory to read the packed vrt header
- * \param if_packet_info the if packet info (read/write)
- */
- UHD_API void if_hdr_unpack_le(
- const uint32_t *packet_buff,
- if_packet_info_t &if_packet_info
- );
-
- UHD_INLINE if_packet_info_t::if_packet_info_t(void):
- link_type(LINK_TYPE_NONE),
- packet_type(PACKET_TYPE_DATA),
- num_payload_words32(0),
- num_payload_bytes(0),
- num_header_words32(0),
- num_packet_words32(0),
- packet_count(0),
- sob(false), eob(false),
- error(false), fc_ack(false),
- has_sid(false), sid(0),
- has_cid(false), cid(0),
- has_tsi(false), tsi(0),
- has_tsf(false), tsf(0),
- has_tlr(false), tlr(0)
- {}
-
-} //namespace vrt
-
-}} //namespace
+namespace uhd { namespace transport { namespace vrt {
+
+//! The maximum number of 32-bit words in the vrlp link layer
+static const size_t num_vrl_words32 = 3;
+
+//! The maximum number of 32-bit words in a vrt if packet header
+static const size_t max_if_hdr_words32 = 7; // hdr+sid+cid+tsi+tsf
+
+/*!
+ * Definition for fields that can be packed into a vrt if header.
+ * The size fields are used for input and output depending upon
+ * the operation used (ie the pack or unpack function call).
+ */
+struct UHD_API if_packet_info_t
+{
+ if_packet_info_t(void);
+
+ // link layer type - always set for pack and unpack
+ enum link_type_t {
+ LINK_TYPE_NONE = 0x0,
+ LINK_TYPE_CHDR = 0x1,
+ LINK_TYPE_VRLP = 0x2
+ } link_type;
+
+ // packet type
+ enum packet_type_t {
+ // VRT language:
+ PACKET_TYPE_DATA = 0x0,
+ PACKET_TYPE_IF_EXT = 0x1,
+ PACKET_TYPE_CONTEXT = 0x2, // extension context: has_sid = true
+
+ // CHDR language:
+ // PACKET_TYPE_DATA = 0x0, // Data
+ PACKET_TYPE_FC = 0x1, // Flow control
+ PACKET_TYPE_ACK = 0x1, // Flow control (ack)
+ PACKET_TYPE_CMD = 0x2, // Command
+ PACKET_TYPE_RESP = 0x3, // Command response
+ PACKET_TYPE_ERROR =
+ 0x3 // Command response: Error (the EOB bit is raised in this case)
+ } packet_type;
+
+ // size fields
+ size_t num_payload_words32; // required in pack, derived in unpack
+ size_t num_payload_bytes; // required in pack, derived in unpack
+ size_t num_header_words32; // derived in pack, derived in unpack
+ size_t num_packet_words32; // derived in pack, required in unpack
+
+ // header fields
+ size_t packet_count;
+ //! Asserted for start- or end-of-burst
+ bool sob, eob;
+ //! This is asserted for command responses that are errors (CHDR only)
+ bool error;
+ //! This is asserted for flow control packets are ACKS (CHDR only)
+ bool fc_ack;
+
+ // optional fields
+ //! Stream ID (SID). See uhd::sid_t
+ bool has_sid;
+ uint32_t sid;
+ //! Class ID.
+ bool has_cid;
+ uint64_t cid;
+ //! Integer timestamp
+ bool has_tsi;
+ uint32_t tsi;
+ //! Fractional timestamp
+ bool has_tsf;
+ uint64_t tsf;
+ //! Trailer
+ bool has_tlr;
+ uint32_t tlr;
+};
+
+/*!
+ * Pack a vrt header from metadata (big endian format).
+ *
+ * \section vrt_pack_contract Packing contract
+ *
+ * \subsection vrt_pack_contract_reqs Requirements:
+ * - packet_buff points to a valid address space with enough space to write
+ * the entire buffer, regardless of its length. At the very least, it must
+ * be able to hold an entire header.
+ * - `if_packet_info` has the following members set to correct values:
+ * - `has_*` members all set accordingly
+ * - For every true `has_*` member, the corresponding variable holds a valid
+ * value (e.g. if `has_sid` is true, `sid` contains a valid SID)
+ * - `num_payload_bytes` and `num_payload_words32` are both set to the correct values
+ *
+ * \subsection vrt_pack_contract_res Result:
+ * - `packet_buff` now points to a valid header that can be sent over the transport
+ * without further modification
+ * - The following members on `if_packet_info` are set:
+ * - `num_header_words32`
+ * - `num_packet_words32`
+ *
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_pack_be(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
+
+/*!
+ * Unpack a vrt header to metadata (big endian format).
+ *
+ * \section vrt_unpack_contract Unpacking contract
+ *
+ * \subsection vrt_unpack_contract_reqs Requirements
+ * - `packet_buff` points to a readable address space with a
+ * CHDR packet, starting at the header. `packet_buff[0]` *must* always
+ * point to a valid first word of the header. This implies that num_packet_words32
+ * must be at least 1.
+ * - `if_packet_info` has the following members set to correct values:
+ * - `num_packet_words32`. This means all values `packet_buff[0]`
+ * through `packet_buff[if_packet_info.num_packet_words32-1]` are
+ * readable words from this packet.
+ * - `link_type`
+ *
+ * \subsection vrt_unpack_contract_res Result
+ * - `if_packet_info` now has the following values set to correct values:
+ * - `packet_type`
+ * - `num_payload_bytes`
+ * - `num_payload_words32`
+ * - `num_header_words32`
+ * - `has_*`
+ * - `sob`, `eob`, `error`, `cid`, `sid` (if applicable)
+ * - `tsf`, `tsi` (if applicable)
+ *
+ * \subsection Exceptions
+ * - If the header is invalid, but the requirements are still met,
+ * will throw a uhd::value_error.
+ *
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_unpack_be(
+ const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
+
+/*!
+ * Pack a vrt header from metadata (little endian format).
+ *
+ * See \ref vrt_pack_contract.
+ *
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_pack_le(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
+
+/*!
+ * Unpack a vrt header to metadata (little endian format).
+ *
+ * See \ref vrt_unpack_contract.
+ *
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
+ */
+UHD_API void if_hdr_unpack_le(
+ const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
+
+UHD_INLINE if_packet_info_t::if_packet_info_t(void)
+ : link_type(LINK_TYPE_NONE)
+ , packet_type(PACKET_TYPE_DATA)
+ , num_payload_words32(0)
+ , num_payload_bytes(0)
+ , num_header_words32(0)
+ , num_packet_words32(0)
+ , packet_count(0)
+ , sob(false)
+ , eob(false)
+ , error(false)
+ , fc_ack(false)
+ , has_sid(false)
+ , sid(0)
+ , has_cid(false)
+ , cid(0)
+ , has_tsi(false)
+ , tsi(0)
+ , has_tsf(false)
+ , tsf(0)
+ , has_tlr(false)
+ , tlr(0)
+{
+}
+
+}}} // namespace uhd::transport::vrt
#endif /* INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP */
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index 4218ab2f9..05582f902 100644
--- a/host/include/uhd/transport/zero_copy.hpp
+++ b/host/include/uhd/transport/zero_copy.hpp
@@ -9,199 +9,212 @@
#define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP
#include <uhd/config.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/intrusive_ptr.hpp>
#include <boost/detail/atomic_count.hpp>
+#include <boost/intrusive_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
- //! Simple managed buffer with release interface
- class UHD_API managed_buffer{
- public:
- managed_buffer(void):_ref_count(0),_buffer(NULL),_length(0)
- {
+//! Simple managed buffer with release interface
+class UHD_API managed_buffer
+{
+public:
+ managed_buffer(void) : _ref_count(0), _buffer(NULL), _length(0)
+ {
#ifdef UHD_TXRX_DEBUG_PRINTS
- _mb_num = s_buffer_count;
- // From Boost website: atomic_count seems only to have precrement operator.
- ++s_buffer_count;
+ _mb_num = s_buffer_count;
+ // From Boost website: atomic_count seems only to have precrement operator.
+ ++s_buffer_count;
#endif
- }
-
- virtual ~managed_buffer(void) {}
-
- /*!
- * Signal to the transport that we are done with the buffer.
- * This should be called to release the buffer to the transport object.
- * After calling, the referenced memory should be considered invalid.
- */
- virtual void release(void) = 0;
-
- /*!
- * Use commit() to re-write the length (for use with send buffers).
- * \param num_bytes the number of bytes written into the buffer
- */
- UHD_INLINE void commit(size_t num_bytes){
- _length = num_bytes;
- }
-
- /*!
- * Get a pointer to the underlying buffer.
- * \return a pointer into memory
- */
- template <class T> UHD_INLINE T cast(void) const{
- return static_cast<T>(_buffer);
- }
-
- /*!
- * Get the size of the underlying buffer.
- * \return the number of bytes
- */
- UHD_INLINE size_t size(void) const{
- return _length;
- }
-
- //! Create smart pointer to a reusable managed buffer
- template <typename T> UHD_INLINE boost::intrusive_ptr<T> make(
- T *p, void *buffer, size_t length
- ){
- _buffer = buffer;
- _length = length;
- return boost::intrusive_ptr<T>(p);
- }
-
- boost::detail::atomic_count _ref_count;
- typedef boost::intrusive_ptr<managed_buffer> sptr;
-
- int ref_count(){
- return (int) _ref_count;
- }
+ }
+
+ virtual ~managed_buffer(void) {}
+
+ /*!
+ * Signal to the transport that we are done with the buffer.
+ * This should be called to release the buffer to the transport object.
+ * After calling, the referenced memory should be considered invalid.
+ */
+ virtual void release(void) = 0;
+
+ /*!
+ * Use commit() to re-write the length (for use with send buffers).
+ * \param num_bytes the number of bytes written into the buffer
+ */
+ UHD_INLINE void commit(size_t num_bytes)
+ {
+ _length = num_bytes;
+ }
+
+ /*!
+ * Get a pointer to the underlying buffer.
+ * \return a pointer into memory
+ */
+ template <class T> UHD_INLINE T cast(void) const
+ {
+ return static_cast<T>(_buffer);
+ }
+
+ /*!
+ * Get the size of the underlying buffer.
+ * \return the number of bytes
+ */
+ UHD_INLINE size_t size(void) const
+ {
+ return _length;
+ }
+
+ //! Create smart pointer to a reusable managed buffer
+ template <typename T>
+ UHD_INLINE boost::intrusive_ptr<T> make(T* p, void* buffer, size_t length)
+ {
+ _buffer = buffer;
+ _length = length;
+ return boost::intrusive_ptr<T>(p);
+ }
+
+ boost::detail::atomic_count _ref_count;
+ typedef boost::intrusive_ptr<managed_buffer> sptr;
+
+ int ref_count()
+ {
+ return (int)_ref_count;
+ }
#ifdef UHD_TXRX_DEBUG_PRINTS
- int num() const{
- return _mb_num;
- }
+ int num() const
+ {
+ return _mb_num;
+ }
#endif
- protected:
- void *_buffer;
- size_t _length;
+protected:
+ void* _buffer;
+ size_t _length;
#ifdef UHD_TXRX_DEBUG_PRINTS
- int _mb_num;
+ int _mb_num;
#endif
- private:
+private:
#ifdef UHD_TXRX_DEBUG_PRINTS
- static boost::detail::atomic_count s_buffer_count;
+ static boost::detail::atomic_count s_buffer_count;
#endif
- };
-
- UHD_INLINE void intrusive_ptr_add_ref(managed_buffer *p){
- ++(p->_ref_count);
+};
+
+UHD_INLINE void intrusive_ptr_add_ref(managed_buffer* p)
+{
+ ++(p->_ref_count);
+}
+
+UHD_INLINE void intrusive_ptr_release(managed_buffer* p)
+{
+ if (--(p->_ref_count) == 0)
+ p->release();
+}
+
+/*!
+ * A managed receive buffer:
+ * Contains a reference to transport-managed memory,
+ * and a method to release the memory after reading.
+ */
+class UHD_API managed_recv_buffer : public managed_buffer
+{
+public:
+ typedef boost::intrusive_ptr<managed_recv_buffer> sptr;
+};
+
+/*!
+ * A managed send buffer:
+ * Contains a reference to transport-managed memory,
+ * and a method to commit the memory after writing.
+ */
+class UHD_API managed_send_buffer : public managed_buffer
+{
+public:
+ typedef boost::intrusive_ptr<managed_send_buffer> sptr;
+};
+
+/*!
+ * Transport parameters
+ */
+struct zero_copy_xport_params
+{
+ zero_copy_xport_params()
+ : recv_frame_size(0)
+ , send_frame_size(0)
+ , num_recv_frames(0)
+ , num_send_frames(0)
+ , recv_buff_size(0)
+ , send_buff_size(0)
+ { /* NOP */
}
+ size_t recv_frame_size;
+ size_t send_frame_size;
+ size_t num_recv_frames;
+ size_t num_send_frames;
+ size_t recv_buff_size;
+ size_t send_buff_size;
+};
+
+/*!
+ * A zero-copy interface for transport objects.
+ * Provides a way to get send and receive buffers
+ * with memory managed by the transport object.
+ */
+class UHD_API zero_copy_if : boost::noncopyable
+{
+public:
+ typedef boost::shared_ptr<zero_copy_if> sptr;
- UHD_INLINE void intrusive_ptr_release(managed_buffer *p){
- if (--(p->_ref_count) == 0) p->release();
- }
+ /*!
+ * Clean up tasks before releasing the transport object.
+ */
+ virtual ~zero_copy_if(){};
+
+ /*!
+ * Get a new receive buffer from this transport object.
+ * \param timeout the timeout to get the buffer in seconds
+ * \return a managed buffer, or null sptr on timeout/error
+ */
+ virtual managed_recv_buffer::sptr get_recv_buff(double timeout = 0.1) = 0;
/*!
- * A managed receive buffer:
- * Contains a reference to transport-managed memory,
- * and a method to release the memory after reading.
+ * Get the number of receive frames:
+ * The number of simultaneous receive buffers in use.
+ * \return number of frames
*/
- class UHD_API managed_recv_buffer : public managed_buffer{
- public:
- typedef boost::intrusive_ptr<managed_recv_buffer> sptr;
- };
+ virtual size_t get_num_recv_frames(void) const = 0;
/*!
- * A managed send buffer:
- * Contains a reference to transport-managed memory,
- * and a method to commit the memory after writing.
+ * Get the size of a receive frame:
+ * The maximum capacity of a single receive buffer.
+ * \return frame size in bytes
*/
- class UHD_API managed_send_buffer : public managed_buffer{
- public:
- typedef boost::intrusive_ptr<managed_send_buffer> sptr;
- };
+ virtual size_t get_recv_frame_size(void) const = 0;
/*!
- * Transport parameters
+ * Get a new send buffer from this transport object.
+ * \param timeout the timeout to get the buffer in seconds
+ * \return a managed buffer, or null sptr on timeout/error
*/
- struct zero_copy_xport_params {
- zero_copy_xport_params() :
- recv_frame_size(0),
- send_frame_size(0),
- num_recv_frames(0),
- num_send_frames(0),
- recv_buff_size(0),
- send_buff_size(0)
- { /* NOP */ }
- size_t recv_frame_size;
- size_t send_frame_size;
- size_t num_recv_frames;
- size_t num_send_frames;
- size_t recv_buff_size;
- size_t send_buff_size;
- };
+ virtual managed_send_buffer::sptr get_send_buff(double timeout = 0.1) = 0;
/*!
- * A zero-copy interface for transport objects.
- * Provides a way to get send and receive buffers
- * with memory managed by the transport object.
+ * Get the number of send frames:
+ * The number of simultaneous send buffers in use.
+ * \return number of frames
*/
- class UHD_API zero_copy_if : boost::noncopyable{
- public:
- typedef boost::shared_ptr<zero_copy_if> sptr;
-
- /*!
- * Clean up tasks before releasing the transport object.
- */
- virtual ~zero_copy_if() {};
-
- /*!
- * Get a new receive buffer from this transport object.
- * \param timeout the timeout to get the buffer in seconds
- * \return a managed buffer, or null sptr on timeout/error
- */
- virtual managed_recv_buffer::sptr get_recv_buff(double timeout = 0.1) = 0;
-
- /*!
- * Get the number of receive frames:
- * The number of simultaneous receive buffers in use.
- * \return number of frames
- */
- virtual size_t get_num_recv_frames(void) const = 0;
-
- /*!
- * Get the size of a receive frame:
- * The maximum capacity of a single receive buffer.
- * \return frame size in bytes
- */
- virtual size_t get_recv_frame_size(void) const = 0;
-
- /*!
- * Get a new send buffer from this transport object.
- * \param timeout the timeout to get the buffer in seconds
- * \return a managed buffer, or null sptr on timeout/error
- */
- virtual managed_send_buffer::sptr get_send_buff(double timeout = 0.1) = 0;
-
- /*!
- * Get the number of send frames:
- * The number of simultaneous send buffers in use.
- * \return number of frames
- */
- virtual size_t get_num_send_frames(void) const = 0;
-
- /*!
- * Get the size of a send frame:
- * The maximum capacity of a single send buffer.
- * \return frame size in bytes
- */
- virtual size_t get_send_frame_size(void) const = 0;
-
- };
-
-}} //namespace
+ virtual size_t get_num_send_frames(void) const = 0;
+
+ /*!
+ * Get the size of a send frame:
+ * The maximum capacity of a single send buffer.
+ * \return frame size in bytes
+ */
+ virtual size_t get_send_frame_size(void) const = 0;
+};
+
+}} // namespace uhd::transport
#endif /* INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP */
diff --git a/host/include/uhd/transport/zero_copy_flow_ctrl.hpp b/host/include/uhd/transport/zero_copy_flow_ctrl.hpp
index bc99e9bbf..f98a0891c 100644
--- a/host/include/uhd/transport/zero_copy_flow_ctrl.hpp
+++ b/host/include/uhd/transport/zero_copy_flow_ctrl.hpp
@@ -13,7 +13,7 @@
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
/*!
* Flow control function.
@@ -25,7 +25,8 @@ typedef boost::function<bool(managed_buffer::sptr buff)> flow_ctrl_func;
/*!
* Adds flow control to any zero_copy_if transport.
*/
-class UHD_API zero_copy_flow_ctrl : public virtual zero_copy_if {
+class UHD_API zero_copy_flow_ctrl : public virtual zero_copy_if
+{
public:
typedef boost::shared_ptr<zero_copy_flow_ctrl> sptr;
@@ -33,16 +34,15 @@ public:
* Make flow controlled transport.
*
* \param transport a shared pointer to the transport interface
- * \param send_flow_ctrl optional send flow control function called before buffer is sent
- * \param recv_flow_ctrl optional receive flow control function called after buffer released
+ * \param send_flow_ctrl optional send flow control function called before buffer is
+ * sent \param recv_flow_ctrl optional receive flow control function called after
+ * buffer released
*/
- static sptr make(
- zero_copy_if::sptr transport,
+ static sptr make(zero_copy_if::sptr transport,
flow_ctrl_func send_flow_ctrl,
- flow_ctrl_func recv_flow_ctrl
- );
+ flow_ctrl_func recv_flow_ctrl);
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_ZERO_COPY_FLOW_CTRL_HPP */
diff --git a/host/include/uhd/transport/zero_copy_recv_offload.hpp b/host/include/uhd/transport/zero_copy_recv_offload.hpp
index 92aa28073..04878f72d 100644
--- a/host/include/uhd/transport/zero_copy_recv_offload.hpp
+++ b/host/include/uhd/transport/zero_copy_recv_offload.hpp
@@ -12,13 +12,14 @@
#include <uhd/transport/zero_copy.hpp>
#include <boost/shared_ptr.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
/*!
* A threaded transport offload that is meant to relieve the main thread of
* the responsibility of making receive calls.
*/
-class UHD_API zero_copy_recv_offload : public virtual zero_copy_if {
+class UHD_API zero_copy_recv_offload : public virtual zero_copy_if
+{
public:
typedef boost::shared_ptr<zero_copy_recv_offload> sptr;
@@ -31,10 +32,9 @@ public:
* \param transport a shared pointer to the transport interface
* \param timeout a general timeout for pushing and pulling on the bounded buffer
*/
- static sptr make(zero_copy_if::sptr transport,
- const double timeout);
+ static sptr make(zero_copy_if::sptr transport, const double timeout);
};
-}} //namespace
+}} // namespace uhd::transport
#endif /* INCLUDED_ZERO_COPY_OFFLOAD_HPP */
diff --git a/host/include/uhd/types/byte_vector.hpp b/host/include/uhd/types/byte_vector.hpp
index 9cf0be88c..64c0911e2 100644
--- a/host/include/uhd/types/byte_vector.hpp
+++ b/host/include/uhd/types/byte_vector.hpp
@@ -14,22 +14,23 @@
#include <string>
#include <vector>
-namespace uhd{
+namespace uhd {
- //! Byte vector used for I2C data passing and EEPROM parsing.
- typedef std::vector<uint8_t> byte_vector_t;
+//! Byte vector used for I2C data passing and EEPROM parsing.
+typedef std::vector<uint8_t> byte_vector_t;
- template<typename RangeSrc, typename RangeDst> UHD_INLINE
- void byte_copy(const RangeSrc &src, RangeDst &dst){
- std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
- }
+template <typename RangeSrc, typename RangeDst>
+UHD_INLINE void byte_copy(const RangeSrc& src, RangeDst& dst)
+{
+ std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
+}
- //! Create a string from a byte vector, terminate when invalid ASCII encountered
- UHD_API std::string bytes_to_string(const byte_vector_t &bytes);
+//! Create a string from a byte vector, terminate when invalid ASCII encountered
+UHD_API std::string bytes_to_string(const byte_vector_t& bytes);
- //! Create a byte vector from a string, end at null terminator or max length
- UHD_API byte_vector_t string_to_bytes(const std::string &str, size_t max_length);
+//! Create a byte vector from a string, end at null terminator or max length
+UHD_API byte_vector_t string_to_bytes(const std::string& str, size_t max_length);
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP */
diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp
index 92b7b7e44..30a754f54 100644
--- a/host/include/uhd/types/clock_config.hpp
+++ b/host/include/uhd/types/clock_config.hpp
@@ -10,47 +10,48 @@
#include <uhd/config.hpp>
-namespace uhd{
-
- /*!
- * The DEPRECATED Clock configuration settings:
- * The source for the 10MHz reference clock.
- * The source and polarity for the PPS clock.
- *
- * Deprecated in favor of set time/clock source calls.
- * Its still in this file for the sake of gr-uhd swig.
- *
- * Use the convenience functions external() and internal(),
- * unless you have a special purpose and cannot use them.
- */
- struct UHD_API clock_config_t{
- //------ simple usage --------//
-
- //! A convenience function to create an external clock configuration
- static clock_config_t external(void);
-
- //! A convenience function to create an internal clock configuration
- static clock_config_t internal(void);
-
- //------ advanced usage --------//
- enum ref_source_t {
- REF_AUTO = int('a'), //automatic (device specific)
- REF_INT = int('i'), //internal reference
- REF_SMA = int('s'), //external sma port
- REF_MIMO = int('m') //reference from mimo cable
- } ref_source;
- enum pps_source_t {
- PPS_INT = int('i'), //there is no internal
- PPS_SMA = int('s'), //external sma port
- PPS_MIMO = int('m') //time sync from mimo cable
- } pps_source;
- enum pps_polarity_t {
- PPS_NEG = int('n'), //negative edge
- PPS_POS = int('p') //positive edge
- } pps_polarity;
- clock_config_t(void);
- };
-
-} //namespace uhd
+namespace uhd {
+
+/*!
+ * The DEPRECATED Clock configuration settings:
+ * The source for the 10MHz reference clock.
+ * The source and polarity for the PPS clock.
+ *
+ * Deprecated in favor of set time/clock source calls.
+ * Its still in this file for the sake of gr-uhd swig.
+ *
+ * Use the convenience functions external() and internal(),
+ * unless you have a special purpose and cannot use them.
+ */
+struct UHD_API clock_config_t
+{
+ //------ simple usage --------//
+
+ //! A convenience function to create an external clock configuration
+ static clock_config_t external(void);
+
+ //! A convenience function to create an internal clock configuration
+ static clock_config_t internal(void);
+
+ //------ advanced usage --------//
+ enum ref_source_t {
+ REF_AUTO = int('a'), // automatic (device specific)
+ REF_INT = int('i'), // internal reference
+ REF_SMA = int('s'), // external sma port
+ REF_MIMO = int('m') // reference from mimo cable
+ } ref_source;
+ enum pps_source_t {
+ PPS_INT = int('i'), // there is no internal
+ PPS_SMA = int('s'), // external sma port
+ PPS_MIMO = int('m') // time sync from mimo cable
+ } pps_source;
+ enum pps_polarity_t {
+ PPS_NEG = int('n'), // negative edge
+ PPS_POS = int('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/component_file.hpp b/host/include/uhd/types/component_file.hpp
index 07c009257..905fc067f 100644
--- a/host/include/uhd/types/component_file.hpp
+++ b/host/include/uhd/types/component_file.hpp
@@ -11,26 +11,27 @@
#include <string>
#include <vector>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
- /*! Defines a file that can be sent using update_component
- *
- * \param metadata dictionary of strings that define the metadata
- * associated with the file.
- *
- * Keys must include "id" and "filename", and may include an "md5" hash,
- * as well as other, device- or component-specific keys.
- *
- * \param data the binary data file
- *
- * Can be the contents of the FPGA image file, for example.
- */
- struct component_file_t {
- uhd::dict<std::string, std::string> metadata;
- std::vector<uint8_t> data;
- };
+/*! Defines a file that can be sent using update_component
+ *
+ * \param metadata dictionary of strings that define the metadata
+ * associated with the file.
+ *
+ * Keys must include "id" and "filename", and may include an "md5" hash,
+ * as well as other, device- or component-specific keys.
+ *
+ * \param data the binary data file
+ *
+ * Can be the contents of the FPGA image file, for example.
+ */
+struct component_file_t
+{
+ uhd::dict<std::string, std::string> metadata;
+ std::vector<uint8_t> data;
+};
- typedef std::vector<component_file_t> component_files_t;
+typedef std::vector<component_file_t> component_files_t;
}} // namespace uhd::usrp
diff --git a/host/include/uhd/types/device_addr.hpp b/host/include/uhd/types/device_addr.hpp
index b9d3659c0..93a5d345f 100644
--- a/host/include/uhd/types/device_addr.hpp
+++ b/host/include/uhd/types/device_addr.hpp
@@ -11,85 +11,87 @@
#include <uhd/config.hpp>
#include <uhd/types/dict.hpp>
#include <boost/lexical_cast.hpp>
+#include <map>
#include <stdexcept>
-#include <vector>
#include <string>
-#include <map>
+#include <vector>
-namespace uhd{
+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.
+ *
+ * An arguments string, is a way to represent a device address
+ * using a single string with delimiter characters.
+ * - Ex: addr=192.168.10.2
+ * - Ex: addr=192.168.10.2, recv_buff_size=1e6
+ */
+class UHD_API device_addr_t : public dict<std::string, std::string>
+{
+public:
/*!
- * 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.
- *
- * An arguments string, is a way to represent a device address
- * using a single string with delimiter characters.
- * - Ex: addr=192.168.10.2
- * - Ex: addr=192.168.10.2, recv_buff_size=1e6
+ * Create a device address from an args string.
+ * \param args the arguments string
*/
- class UHD_API device_addr_t : public dict<std::string, std::string>{
- public:
- /*!
- * Create a device address from an args string.
- * \param args the arguments string
- */
- device_addr_t(const std::string &args = "");
+ device_addr_t(const std::string& args = "");
- /*!
- * Create a device address from a std::map
- * \param info the device info map
- */
- device_addr_t(const std::map<std::string, std::string> &info);
+ /*!
+ * Create a device address from a std::map
+ * \param info the device info map
+ */
+ device_addr_t(const std::map<std::string, std::string>& info);
- /*!
- * Convert a device address into a pretty print string.
- * \return a printable string representing the device address
- */
- std::string to_pp_string(void) const;
+ /*!
+ * Convert a device address into a pretty print string.
+ * \return a printable string representing the device address
+ */
+ std::string to_pp_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_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_string(void) const;
- /*!
- * Lexically cast a parameter to the specified type,
- * or use the default value if the key is not found.
- * \param key the key as one of the address parameters
- * \param def the value to use when key is not present
- * \return the casted value as type T or the default
- * \throw error when the parameter cannot be casted
- */
- template <typename T> T cast(const std::string &key, const T &def) const{
- if (not this->has_key(key)) return def;
- try{
- return boost::lexical_cast<T>((*this)[key]);
- }
- catch(const boost::bad_lexical_cast &){
- throw std::runtime_error("cannot cast " + key + " = " + (*this)[key]);
- }
+ /*!
+ * Lexically cast a parameter to the specified type,
+ * or use the default value if the key is not found.
+ * \param key the key as one of the address parameters
+ * \param def the value to use when key is not present
+ * \return the casted value as type T or the default
+ * \throw error when the parameter cannot be casted
+ */
+ template <typename T> T cast(const std::string& key, const T& def) const
+ {
+ if (not this->has_key(key))
+ return def;
+ try {
+ return boost::lexical_cast<T>((*this)[key]);
+ } catch (const boost::bad_lexical_cast&) {
+ throw std::runtime_error("cannot cast " + key + " = " + (*this)[key]);
}
- };
+ }
+};
- //! A typedef for a vector of device addresses
- typedef std::vector<device_addr_t> device_addrs_t;
+//! A typedef for a vector of device addresses
+typedef std::vector<device_addr_t> device_addrs_t;
- //! Separate an indexed device address into a vector of device addresses
- 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
+UHD_API device_addrs_t separate_device_addr(const device_addr_t& dev_addr);
- //! Combine a vector of device addresses into an indexed device address
- 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
+UHD_API device_addr_t combine_device_addrs(const device_addrs_t& dev_addrs);
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_DEVICE_ADDR_HPP */
diff --git a/host/include/uhd/types/dict.hpp b/host/include/uhd/types/dict.hpp
index 51594e17b..8b7a63c69 100644
--- a/host/include/uhd/types/dict.hpp
+++ b/host/include/uhd/types/dict.hpp
@@ -9,141 +9,141 @@
#define INCLUDED_UHD_TYPES_DICT_HPP
#include <uhd/config.hpp>
-#include <vector>
#include <list>
+#include <vector>
+
+namespace uhd {
+
+/*!
+ * A templated dictionary class with a python-like interface.
+ */
+template <typename Key, typename Val> class dict
+{
+public:
+ /*!
+ * Create a new empty dictionary.
+ */
+ dict(void);
+
+ /*!
+ * Input iterator constructor:
+ * Makes boost::assign::map_list_of work.
+ * \param first the begin iterator
+ * \param last the end iterator
+ */
+ template <typename InputIterator> dict(InputIterator first, InputIterator last);
+
+ /*!
+ * Get the number of elements in this dict.
+ * \return the number of elements
+ */
+ std::size_t size(void) const;
+
+ /*!
+ * Get a list of the keys in this dict.
+ * Key order depends on insertion precedence.
+ * \return vector of keys
+ */
+ std::vector<Key> keys(void) const;
+
+ /*!
+ * Get a list of the values in this dict.
+ * Value order depends on insertion precedence.
+ * \return vector of values
+ */
+ std::vector<Val> vals(void) const;
+
+ /*!
+ * Does the dictionary contain this key?
+ * \param key the key to look for
+ * \return true if found
+ */
+ bool has_key(const Key& key) const;
+
+ /*!
+ * Get a value in the dict or default.
+ * \param key the key to look for
+ * \param other use if key not found
+ * \return the value or default
+ */
+ const Val& get(const Key& key, const Val& other) const;
+
+ /*!
+ * Get a value in the dict or throw.
+ * \param key the key to look for
+ * \return the value or default
+ */
+ const Val& get(const Key& key) const;
+
+ /*!
+ * Set a value in the dict at the key.
+ * \param key the key to set at
+ * \param val the value to set
+ */
+ void set(const Key& key, const Val& val);
+
+ /*!
+ * Get a value for the given key if it exists.
+ * If the key is not found throw an error.
+ * \param key the key to look for
+ * \return the value at the key
+ * \throw an exception when not found
+ */
+ const Val& operator[](const Key& key) const;
-namespace uhd{
+ /*!
+ * Set a value for the given key, however, in reality
+ * it really returns a reference which can be assigned to.
+ * \param key the key to set to
+ * \return a reference to the value
+ */
+ Val& operator[](const Key& key);
+
+ /*!
+ * Equals operator for the dict type
+ * \param other the dict being compared to this
+ * \return whether or not the two dict's are equal
+ */
+ bool operator==(const dict<Key, Val>& other) const;
/*!
- * A templated dictionary class with a python-like interface.
+ * Not equal operator for the dict type
+ * \param other the dict being compared to this
+ * \return whether or not the two dict's are not equal
*/
- template <typename Key, typename Val> class dict{
- public:
- /*!
- * Create a new empty dictionary.
- */
- dict(void);
-
- /*!
- * Input iterator constructor:
- * Makes boost::assign::map_list_of work.
- * \param first the begin iterator
- * \param last the end iterator
- */
- template <typename InputIterator>
- dict(InputIterator first, InputIterator last);
-
- /*!
- * Get the number of elements in this dict.
- * \return the number of elements
- */
- std::size_t size(void) const;
-
- /*!
- * Get a list of the keys in this dict.
- * Key order depends on insertion precedence.
- * \return vector of keys
- */
- std::vector<Key> keys(void) const;
-
- /*!
- * Get a list of the values in this dict.
- * Value order depends on insertion precedence.
- * \return vector of values
- */
- std::vector<Val> vals(void) const;
-
- /*!
- * Does the dictionary contain this key?
- * \param key the key to look for
- * \return true if found
- */
- bool has_key(const Key &key) const;
-
- /*!
- * Get a value in the dict or default.
- * \param key the key to look for
- * \param other use if key not found
- * \return the value or default
- */
- const Val &get(const Key &key, const Val &other) const;
-
- /*!
- * Get a value in the dict or throw.
- * \param key the key to look for
- * \return the value or default
- */
- const Val &get(const Key &key) const;
-
- /*!
- * Set a value in the dict at the key.
- * \param key the key to set at
- * \param val the value to set
- */
- void set(const Key &key, const Val &val);
-
- /*!
- * Get a value for the given key if it exists.
- * If the key is not found throw an error.
- * \param key the key to look for
- * \return the value at the key
- * \throw an exception when not found
- */
- const Val &operator[](const Key &key) const;
-
- /*!
- * Set a value for the given key, however, in reality
- * it really returns a reference which can be assigned to.
- * \param key the key to set to
- * \return a reference to the value
- */
- Val &operator[](const Key &key);
-
- /*!
- * Equals operator for the dict type
- * \param other the dict being compared to this
- * \return whether or not the two dict's are equal
- */
- bool operator==(const dict<Key, Val> &other) const;
-
- /*!
- * Not equal operator for the dict type
- * \param other the dict being compared to this
- * \return whether or not the two dict's are not equal
- */
- bool operator!=(const dict<Key, Val> &other) const;
-
- /*!
- * Pop an item out of the dictionary.
- * \param key the item key
- * \return the value of the item
- * \throw an exception when not found
- */
- Val pop(const Key &key);
-
- /*! Update this dictionary with values from another.
- *
- * Basically, this copies all the key/value pairs from \p new_dict
- * into this dict. When the key is already present in the current
- * dict, it either overwrites the current value (if \p fail_on_conflict
- * is false) or it throws (if \p fail_on_conflict is true *and* the
- * values differ).
- *
- * With the exception of \p fail_on_conflict, this behaves analogously
- * to Python's dict.update() method.
- *
- * \param new_dict The arguments to copy.
- * \param fail_on_conflict If true, throws.
- * \throws uhd::value_error
- */
- void update(const dict<Key, Val> &new_dict, bool fail_on_conflict=true);
-
- private:
- typedef std::pair<Key, Val> pair_t;
- std::list<pair_t> _map; //private container
- };
-
-} //namespace uhd
+ bool operator!=(const dict<Key, Val>& other) const;
+
+ /*!
+ * Pop an item out of the dictionary.
+ * \param key the item key
+ * \return the value of the item
+ * \throw an exception when not found
+ */
+ Val pop(const Key& key);
+
+ /*! Update this dictionary with values from another.
+ *
+ * Basically, this copies all the key/value pairs from \p new_dict
+ * into this dict. When the key is already present in the current
+ * dict, it either overwrites the current value (if \p fail_on_conflict
+ * is false) or it throws (if \p fail_on_conflict is true *and* the
+ * values differ).
+ *
+ * With the exception of \p fail_on_conflict, this behaves analogously
+ * to Python's dict.update() method.
+ *
+ * \param new_dict The arguments to copy.
+ * \param fail_on_conflict If true, throws.
+ * \throws uhd::value_error
+ */
+ void update(const dict<Key, Val>& new_dict, bool fail_on_conflict = true);
+
+private:
+ typedef std::pair<Key, Val> pair_t;
+ std::list<pair_t> _map; // private container
+};
+
+} // namespace uhd
#include <uhd/types/dict.ipp>
diff --git a/host/include/uhd/types/direction.hpp b/host/include/uhd/types/direction.hpp
index 79d942bd6..73ef0c07f 100644
--- a/host/include/uhd/types/direction.hpp
+++ b/host/include/uhd/types/direction.hpp
@@ -10,15 +10,15 @@
namespace uhd {
- enum direction_t {
- //! Receive
- RX_DIRECTION,
- //! Transmit
- TX_DIRECTION,
- //! Duplex
- DX_DIRECTION
- };
+enum direction_t {
+ //! Receive
+ RX_DIRECTION,
+ //! Transmit
+ TX_DIRECTION,
+ //! Duplex
+ DX_DIRECTION
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_DIRECTION_HPP */
diff --git a/host/include/uhd/types/eeprom.hpp b/host/include/uhd/types/eeprom.hpp
index a61fbf211..d2b29fe6b 100644
--- a/host/include/uhd/types/eeprom.hpp
+++ b/host/include/uhd/types/eeprom.hpp
@@ -13,7 +13,7 @@
namespace uhd {
- typedef std::map<std::string, std::vector<uint8_t>> eeprom_map_t;
+typedef std::map<std::string, std::vector<uint8_t> > eeprom_map_t;
} /* namespace uhd */
diff --git a/host/include/uhd/types/endianness.hpp b/host/include/uhd/types/endianness.hpp
index 74b8f43e9..a14bfcd23 100644
--- a/host/include/uhd/types/endianness.hpp
+++ b/host/include/uhd/types/endianness.hpp
@@ -10,13 +10,10 @@
#include <uhd/config.hpp>
-namespace uhd{
+namespace uhd {
- enum endianness_t {
- ENDIANNESS_BIG,
- ENDIANNESS_LITTLE
- };
+enum endianness_t { ENDIANNESS_BIG, ENDIANNESS_LITTLE };
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_ENDIANNESS_HPP */
diff --git a/host/include/uhd/types/filters.hpp b/host/include/uhd/types/filters.hpp
index 9879774cc..ff72dd5e3 100644
--- a/host/include/uhd/types/filters.hpp
+++ b/host/include/uhd/types/filters.hpp
@@ -10,267 +10,249 @@
#include <uhd/config.hpp>
#include <uhd/utils/log.hpp>
-
#include <stdint.h>
-#include <boost/shared_ptr.hpp>
#include <boost/scoped_array.hpp>
-#include <string>
-#include <vector>
+#include <boost/shared_ptr.hpp>
#include <iostream>
#include <ostream>
#include <sstream>
+#include <string>
+#include <vector>
-namespace uhd{
-
- class UHD_API filter_info_base
- {
- public:
- typedef boost::shared_ptr<filter_info_base> sptr;
- enum filter_type
- {
- ANALOG_LOW_PASS,
- ANALOG_BAND_PASS,
- DIGITAL_I16,
- DIGITAL_FIR_I16
- };
-
- filter_info_base(
- filter_type type,
- bool bypass,
- size_t position_index
- ):
- _type(type), _bypass(bypass),
- _position_index(position_index)
- {
- //NOP
- }
-
- UHD_INLINE virtual bool is_bypassed()
- {
- return _bypass;
- }
-
- UHD_INLINE filter_type get_type()
- {
- return _type;
- }
-
- virtual ~filter_info_base()
- {
- //NOP
- }
-
- virtual std::string to_pp_string();
-
- protected:
- filter_type _type;
- bool _bypass;
- size_t _position_index;
-
- };
+namespace uhd {
- UHD_API std::ostream& operator<<(std::ostream& os, filter_info_base& f);
+class UHD_API filter_info_base
+{
+public:
+ typedef boost::shared_ptr<filter_info_base> sptr;
+ enum filter_type { ANALOG_LOW_PASS, ANALOG_BAND_PASS, DIGITAL_I16, DIGITAL_FIR_I16 };
- class UHD_API analog_filter_base : public filter_info_base
+ filter_info_base(filter_type type, bool bypass, size_t position_index)
+ : _type(type), _bypass(bypass), _position_index(position_index)
{
- std::string _analog_type;
- public:
- typedef boost::shared_ptr<analog_filter_base> sptr;
- analog_filter_base(
- filter_type type,
- bool bypass,
- size_t position_index,
- const std::string& analog_type
- ):
- filter_info_base(type, bypass, position_index),
- _analog_type(analog_type)
- {
- //NOP
- }
+ // NOP
+ }
- UHD_INLINE const std::string& get_analog_type()
- {
- return _analog_type;
- }
-
- virtual std::string to_pp_string();
- };
+ UHD_INLINE virtual bool is_bypassed()
+ {
+ return _bypass;
+ }
- class UHD_API analog_filter_lp : public analog_filter_base
+ UHD_INLINE filter_type get_type()
{
- double _cutoff;
- double _rolloff;
-
- public:
- typedef boost::shared_ptr<analog_filter_lp> sptr;
- analog_filter_lp(
- filter_type type,
- bool bypass,
- size_t position_index,
- const std::string& analog_type,
- double cutoff,
- double rolloff
- ):
- analog_filter_base(type, bypass, position_index, analog_type),
- _cutoff(cutoff),
- _rolloff(rolloff)
- {
- //NOP
- }
+ return _type;
+ }
- UHD_INLINE double get_cutoff()
- {
- return _cutoff;
- }
+ virtual ~filter_info_base()
+ {
+ // NOP
+ }
+
+ virtual std::string to_pp_string();
+
+protected:
+ filter_type _type;
+ bool _bypass;
+ size_t _position_index;
+};
+
+UHD_API std::ostream& operator<<(std::ostream& os, filter_info_base& f);
+
+class UHD_API analog_filter_base : public filter_info_base
+{
+ std::string _analog_type;
+
+public:
+ typedef boost::shared_ptr<analog_filter_base> sptr;
+ analog_filter_base(filter_type type,
+ bool bypass,
+ size_t position_index,
+ const std::string& analog_type)
+ : filter_info_base(type, bypass, position_index), _analog_type(analog_type)
+ {
+ // NOP
+ }
- UHD_INLINE double get_rolloff()
- {
- return _rolloff;
- }
+ UHD_INLINE const std::string& get_analog_type()
+ {
+ return _analog_type;
+ }
+
+ virtual std::string to_pp_string();
+};
+
+class UHD_API analog_filter_lp : public analog_filter_base
+{
+ double _cutoff;
+ double _rolloff;
+
+public:
+ typedef boost::shared_ptr<analog_filter_lp> sptr;
+ analog_filter_lp(filter_type type,
+ bool bypass,
+ size_t position_index,
+ const std::string& analog_type,
+ double cutoff,
+ double rolloff)
+ : analog_filter_base(type, bypass, position_index, analog_type)
+ , _cutoff(cutoff)
+ , _rolloff(rolloff)
+ {
+ // NOP
+ }
- UHD_INLINE void set_cutoff(const double cutoff)
- {
- _cutoff = cutoff;
- }
+ UHD_INLINE double get_cutoff()
+ {
+ return _cutoff;
+ }
- virtual std::string to_pp_string();
- };
+ UHD_INLINE double get_rolloff()
+ {
+ return _rolloff;
+ }
- template<typename tap_t>
- class UHD_API digital_filter_base : public filter_info_base
+ UHD_INLINE void set_cutoff(const double cutoff)
{
- protected:
- double _rate;
- uint32_t _interpolation;
- uint32_t _decimation;
- tap_t _tap_full_scale;
- uint32_t _max_num_taps;
- std::vector<tap_t> _taps;
-
- public:
- typedef boost::shared_ptr<digital_filter_base> sptr;
- digital_filter_base(
- filter_type type,
- bool bypass,
- size_t position_index,
- double rate,
- size_t interpolation,
- size_t decimation,
- double tap_full_scale,
- size_t max_num_taps,
- const std::vector<tap_t>& taps
- ):
- filter_info_base(type, bypass, position_index),
- _rate(rate),
- _interpolation(interpolation),
- _decimation(decimation),
- _tap_full_scale(tap_full_scale),
- _max_num_taps(max_num_taps),
- _taps(taps)
- {
- //NOP
- }
+ _cutoff = cutoff;
+ }
+
+ virtual std::string to_pp_string();
+};
+
+template <typename tap_t> class UHD_API digital_filter_base : public filter_info_base
+{
+protected:
+ double _rate;
+ uint32_t _interpolation;
+ uint32_t _decimation;
+ tap_t _tap_full_scale;
+ uint32_t _max_num_taps;
+ std::vector<tap_t> _taps;
+
+public:
+ typedef boost::shared_ptr<digital_filter_base> sptr;
+ digital_filter_base(filter_type type,
+ bool bypass,
+ size_t position_index,
+ double rate,
+ size_t interpolation,
+ size_t decimation,
+ double tap_full_scale,
+ size_t max_num_taps,
+ const std::vector<tap_t>& taps)
+ : filter_info_base(type, bypass, position_index)
+ , _rate(rate)
+ , _interpolation(interpolation)
+ , _decimation(decimation)
+ , _tap_full_scale(tap_full_scale)
+ , _max_num_taps(max_num_taps)
+ , _taps(taps)
+ {
+ // NOP
+ }
- UHD_INLINE double get_output_rate()
- {
- return (_bypass ? _rate : (_rate / _decimation * _interpolation));
- }
+ UHD_INLINE double get_output_rate()
+ {
+ return (_bypass ? _rate : (_rate / _decimation * _interpolation));
+ }
- UHD_INLINE double get_input_rate()
- {
- return _rate;
- }
+ UHD_INLINE double get_input_rate()
+ {
+ return _rate;
+ }
- UHD_INLINE double get_interpolation()
- {
- return _interpolation;
- }
+ UHD_INLINE double get_interpolation()
+ {
+ return _interpolation;
+ }
- UHD_INLINE double get_decimation()
- {
- return _decimation;
- }
+ UHD_INLINE double get_decimation()
+ {
+ return _decimation;
+ }
- UHD_INLINE double get_tap_full_scale()
- {
- return _tap_full_scale;
- }
+ UHD_INLINE double get_tap_full_scale()
+ {
+ return _tap_full_scale;
+ }
- UHD_INLINE std::vector<tap_t>& get_taps()
- {
- return _taps;
- }
+ UHD_INLINE std::vector<tap_t>& get_taps()
+ {
+ return _taps;
+ }
- virtual std::string to_pp_string()
- {
- std::ostringstream os;
- os<<filter_info_base::to_pp_string()<<
- "\t[digital_filter_base]"<<std::endl<<
- "\tinput rate: "<<_rate<<std::endl<<
- "\tinterpolation: "<<_interpolation<<std::endl<<
- "\tdecimation: "<<_decimation<<std::endl<<
- "\tfull-scale: "<<_tap_full_scale<<std::endl<<
- "\tmax num taps: "<<_max_num_taps<<std::endl<<
- "\ttaps: "<<std::endl;
-
- os<<"\t\t";
- for(size_t i = 0; i < _taps.size(); i++)
- {
- os<<"(tap "<<i<<": "<<_taps[i]<<")";
- if( ((i%10) == 0) && (i != 0))
- {
- os<<std::endl<<"\t\t";
- }
+ virtual std::string to_pp_string()
+ {
+ std::ostringstream os;
+ os << filter_info_base::to_pp_string() << "\t[digital_filter_base]" << std::endl
+ << "\tinput rate: " << _rate << std::endl
+ << "\tinterpolation: " << _interpolation << std::endl
+ << "\tdecimation: " << _decimation << std::endl
+ << "\tfull-scale: " << _tap_full_scale << std::endl
+ << "\tmax num taps: " << _max_num_taps << std::endl
+ << "\ttaps: " << std::endl;
+
+ os << "\t\t";
+ for (size_t i = 0; i < _taps.size(); i++) {
+ os << "(tap " << i << ": " << _taps[i] << ")";
+ if (((i % 10) == 0) && (i != 0)) {
+ os << std::endl << "\t\t";
}
- os<<std::endl;
- return std::string(os.str());
}
-
- };
-
- template<typename tap_t>
- class UHD_API digital_filter_fir : public digital_filter_base<tap_t>
+ os << std::endl;
+ return std::string(os.str());
+ }
+};
+
+template <typename tap_t>
+class UHD_API digital_filter_fir : public digital_filter_base<tap_t>
+{
+public:
+ typedef boost::shared_ptr<digital_filter_fir<tap_t> > sptr;
+
+ digital_filter_fir(filter_info_base::filter_type type,
+ bool bypass,
+ size_t position_index,
+ double rate,
+ size_t interpolation,
+ size_t decimation,
+ size_t tap_bit_width,
+ size_t max_num_taps,
+ const std::vector<tap_t>& taps)
+ : digital_filter_base<tap_t>(type,
+ bypass,
+ position_index,
+ rate,
+ interpolation,
+ decimation,
+ tap_bit_width,
+ max_num_taps,
+ taps)
{
- public:
- typedef boost::shared_ptr<digital_filter_fir<tap_t> > sptr;
-
- digital_filter_fir(
- filter_info_base::filter_type type,
- bool bypass, size_t position_index,
- double rate,
- size_t interpolation,
- size_t decimation,
- size_t tap_bit_width,
- size_t max_num_taps,
- const std::vector<tap_t>& taps
- ):
- digital_filter_base<tap_t>(type, bypass, position_index, rate, interpolation, decimation, tap_bit_width, max_num_taps, taps)
- {
- //NOP
- }
+ // NOP
+ }
- void set_taps(const std::vector<tap_t>& taps)
- {
- std::size_t num_taps = taps.size();
- if(num_taps < this->_max_num_taps){
- UHD_LOGGER_WARNING("FILTERS") << "digital_filter_fir::set_taps not enough coefficients. Appending zeros";
- std::vector<tap_t> coeffs;
- for (size_t i = 0; i < this->_max_num_taps; i++)
- {
- if(i < num_taps)
- {
- coeffs.push_back(taps[i]);
- } else {
- coeffs.push_back(0);
- }
+ void set_taps(const std::vector<tap_t>& taps)
+ {
+ std::size_t num_taps = taps.size();
+ if (num_taps < this->_max_num_taps) {
+ UHD_LOGGER_WARNING("FILTERS") << "digital_filter_fir::set_taps not enough "
+ "coefficients. Appending zeros";
+ std::vector<tap_t> coeffs;
+ for (size_t i = 0; i < this->_max_num_taps; i++) {
+ if (i < num_taps) {
+ coeffs.push_back(taps[i]);
+ } else {
+ coeffs.push_back(0);
}
- this->_taps = coeffs;
- } else {
- this->_taps = taps;
}
+ this->_taps = coeffs;
+ } else {
+ this->_taps = taps;
}
- };
+ }
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_FILTERS_HPP */
diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp
index 3effe5cec..01e10142c 100644
--- a/host/include/uhd/types/io_type.hpp
+++ b/host/include/uhd/types/io_type.hpp
@@ -10,60 +10,59 @@
#include <uhd/config.hpp>
-namespace uhd{
+namespace uhd {
+/*!
+ * The DEPRECATED Input/Output configuration struct:
+ * Used to specify the IO type with device send/recv.
+ *
+ * Deprecated in favor of streamer interface.
+ * Its still in this file for the sake of gr-uhd swig.
+ */
+class UHD_API io_type_t
+{
+public:
/*!
- * The DEPRECATED Input/Output configuration struct:
- * Used to specify the IO type with device send/recv.
- *
- * Deprecated in favor of streamer interface.
- * Its still in this file for the sake of gr-uhd swig.
+ * Built in IO types known to the system.
*/
- class UHD_API io_type_t{
- public:
-
- /*!
- * Built in IO types known to the system.
- */
- enum tid_t{
- //! Custom type (technically unsupported by implementation)
- CUSTOM_TYPE = int('?'),
- //! Complex floating point (64-bit floats) range [-1.0, +1.0]
- COMPLEX_FLOAT64 = int('d'),
- //! Complex floating point (32-bit floats) range [-1.0, +1.0]
- COMPLEX_FLOAT32 = int('f'),
- //! Complex signed integer (16-bit integers) range [-32768, +32767]
- COMPLEX_INT16 = int('s'),
- //! Complex signed integer (8-bit integers) range [-128, 127]
- COMPLEX_INT8 = int('b')
- };
-
- /*!
- * The size of this io type in bytes.
- */
- const size_t size;
+ enum tid_t {
+ //! Custom type (technically unsupported by implementation)
+ CUSTOM_TYPE = int('?'),
+ //! Complex floating point (64-bit floats) range [-1.0, +1.0]
+ COMPLEX_FLOAT64 = int('d'),
+ //! Complex floating point (32-bit floats) range [-1.0, +1.0]
+ COMPLEX_FLOAT32 = int('f'),
+ //! Complex signed integer (16-bit integers) range [-32768, +32767]
+ COMPLEX_INT16 = int('s'),
+ //! Complex signed integer (8-bit integers) range [-128, 127]
+ COMPLEX_INT8 = int('b')
+ };
- /*!
- * The type id of this io type.
- * Good for using with switch statements.
- */
- const tid_t tid;
+ /*!
+ * The size of this io type in bytes.
+ */
+ const size_t size;
- /*!
- * 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);
+ /*!
+ * The type id of this io type.
+ * Good for using with switch statements.
+ */
+ const 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);
+ /*!
+ * 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
+} // 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
index ff119c5de..316c5890c 100644
--- a/host/include/uhd/types/mac_addr.hpp
+++ b/host/include/uhd/types/mac_addr.hpp
@@ -12,45 +12,46 @@
#include <uhd/types/serial.hpp>
#include <string>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * Wrapper for an ethernet mac address.
+ * Provides conversion between string and binary formats.
+ */
+class UHD_API mac_addr_t
+{
+public:
+ /*!
+ * Create a mac address a byte array.
+ * \param bytes a vector of bytes
+ * \return a new mac address
+ */
+ static mac_addr_t from_bytes(const byte_vector_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);
/*!
- * Wrapper for an ethernet mac address.
- * Provides conversion between string and binary formats.
- */
- class UHD_API mac_addr_t{
- public:
- /*!
- * Create a mac address a byte array.
- * \param bytes a vector of bytes
- * \return a new mac address
- */
- static mac_addr_t from_bytes(const byte_vector_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 vector of bytes
- */
- byte_vector_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 byte_vector_t &bytes); //private constructor
- const byte_vector_t _bytes; //internal representation
- };
-
-} //namespace uhd
+ * Get the byte representation of the mac address.
+ * \return a vector of bytes
+ */
+ byte_vector_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 byte_vector_t& bytes); // private constructor
+ const byte_vector_t _bytes; // 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
index b46eb0a89..a29cae93c 100644
--- a/host/include/uhd/types/metadata.hpp
+++ b/host/include/uhd/types/metadata.hpp
@@ -13,186 +13,190 @@
#include <stdint.h>
#include <string>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * RX metadata structure for describing sent IF data.
+ * Includes time specification, fragmentation flags, burst flags, and error codes.
+ * The receive routines will convert IF data headers into metadata.
+ */
+struct UHD_API rx_metadata_t
+{
+ //! Default constructor.
+ rx_metadata_t()
+ {
+ reset();
+ }
+
+ //! Reset values.
+ void reset()
+ {
+ has_time_spec = false;
+ time_spec = time_spec_t(0.0);
+ more_fragments = false;
+ fragment_offset = 0;
+ start_of_burst = false;
+ end_of_burst = false;
+ error_code = ERROR_CODE_NONE;
+ out_of_sequence = false;
+ }
+
+ //! Has time specification?
+ bool has_time_spec;
+
+ //! Time of the first sample.
+ time_spec_t time_spec;
/*!
- * RX metadata structure for describing sent IF data.
- * Includes time specification, fragmentation flags, burst flags, and error codes.
- * The receive routines will convert IF data headers into metadata.
+ * Fragmentation flag:
+ * Similar to IPv4 fragmentation:
+ * http://en.wikipedia.org/wiki/IPv4#Fragmentation_and_reassembly More fragments is
+ * true when the input buffer has insufficient size to fit an entire received packet.
+ * More fragments will be false for the last fragment.
*/
- struct UHD_API rx_metadata_t{
-
- //! Default constructor.
- rx_metadata_t()
- {
- reset();
- }
-
- //! Reset values.
- void reset()
- {
- has_time_spec = false;
- time_spec = time_spec_t(0.0);
- more_fragments = false;
- fragment_offset = 0;
- start_of_burst = false;
- end_of_burst = false;
- error_code = ERROR_CODE_NONE;
- out_of_sequence = false;
- }
-
- //! Has time specification?
- bool has_time_spec;
-
- //! Time of the first sample.
- time_spec_t time_spec;
+ bool more_fragments;
- /*!
- * Fragmentation flag:
- * Similar to IPv4 fragmentation: http://en.wikipedia.org/wiki/IPv4#Fragmentation_and_reassembly
- * More fragments is true when the input buffer has insufficient size to fit
- * an entire received packet. More fragments will be false for the last fragment.
- */
- bool more_fragments;
-
- /*!
- * Fragmentation offset:
- * The fragment offset is the sample number at the start of the receive buffer.
- * For non-fragmented receives, the fragment offset should always be zero.
- */
- size_t fragment_offset;
+ /*!
+ * Fragmentation offset:
+ * The fragment offset is the sample number at the start of the receive buffer.
+ * For non-fragmented receives, the fragment offset should always be zero.
+ */
+ size_t fragment_offset;
- //! Start of burst will be true for the first packet in the chain.
- bool start_of_burst;
+ //! Start of burst will be true for the first packet in the chain.
+ bool start_of_burst;
- //! End of burst will be true for the last packet in the chain.
- bool end_of_burst;
-
- /*!
- * The error condition on a receive call.
- *
- * Note: When an overrun occurs in continuous streaming mode,
- * the device will continue to send samples to the host.
- * For other streaming modes, streaming will discontinue
- * until the user issues a new stream command.
- *
- * The metadata fields have meaning for the following error codes:
- * - none
- * - late command
- * - broken chain
- * - overflow
- */
- enum error_code_t {
- //! No error associated with this metadata.
- ERROR_CODE_NONE = 0x0,
- //! No packet received, implementation timed-out.
- ERROR_CODE_TIMEOUT = 0x1,
- //! A stream command was issued in the past.
- ERROR_CODE_LATE_COMMAND = 0x2,
- //! Expected another stream command.
- ERROR_CODE_BROKEN_CHAIN = 0x4,
- /*!
- * An internal receive buffer has filled or a sequence error has been detected.
- * So, why is this overloaded? Simple: legacy support. It would have been much cleaner
- * to create a separate error code for a sequence error, but that would have broken
- * legacy applications. So, the out_of_sequence flag was added to differentiate between
- * the two error cases. In either case, data is missing between this time_spec and the
- * and the time_spec of the next successful receive.
- */
- ERROR_CODE_OVERFLOW = 0x8,
- //! Multi-channel alignment failed.
- ERROR_CODE_ALIGNMENT = 0xc,
- //! The packet could not be parsed.
- ERROR_CODE_BAD_PACKET = 0xf
- } error_code;
-
- //! Out of sequence. The transport has either dropped a packet or received data out of order.
- bool out_of_sequence;
+ //! End of burst will be true for the last packet in the chain.
+ bool end_of_burst;
+ /*!
+ * The error condition on a receive call.
+ *
+ * Note: When an overrun occurs in continuous streaming mode,
+ * the device will continue to send samples to the host.
+ * For other streaming modes, streaming will discontinue
+ * until the user issues a new stream command.
+ *
+ * The metadata fields have meaning for the following error codes:
+ * - none
+ * - late command
+ * - broken chain
+ * - overflow
+ */
+ enum error_code_t {
+ //! No error associated with this metadata.
+ ERROR_CODE_NONE = 0x0,
+ //! No packet received, implementation timed-out.
+ ERROR_CODE_TIMEOUT = 0x1,
+ //! A stream command was issued in the past.
+ ERROR_CODE_LATE_COMMAND = 0x2,
+ //! Expected another stream command.
+ ERROR_CODE_BROKEN_CHAIN = 0x4,
/*!
- * Convert a rx_metadata_t into a pretty print string.
- *
- * \param compact Set to false for a more verbose output.
- * \return a printable string representing the metadata.
+ * An internal receive buffer has filled or a sequence error has been detected.
+ * So, why is this overloaded? Simple: legacy support. It would have been much
+ * cleaner to create a separate error code for a sequence error, but that would
+ * have broken legacy applications. So, the out_of_sequence flag was added to
+ * differentiate between the two error cases. In either case, data is missing
+ * between this time_spec and the and the time_spec of the next successful
+ * receive.
*/
- std::string to_pp_string(bool compact=true) const;
+ ERROR_CODE_OVERFLOW = 0x8,
+ //! Multi-channel alignment failed.
+ ERROR_CODE_ALIGNMENT = 0xc,
+ //! The packet could not be parsed.
+ ERROR_CODE_BAD_PACKET = 0xf
+ } error_code;
- /*!
- * Similar to C's strerror() function, creates a std::string describing the error code.
- * \return a printable string representing the error.
- */
- std::string strerror(void) const;
- };
+ //! Out of sequence. The transport has either dropped a packet or received data out
+ //! of order.
+ bool out_of_sequence;
/*!
- * TX metadata structure for describing received IF data.
- * Includes time specification, and start and stop burst flags.
- * The send routines will convert the metadata to IF data headers.
+ * Convert a rx_metadata_t into a pretty print string.
+ *
+ * \param compact Set to false for a more verbose output.
+ * \return a printable string representing the metadata.
*/
- struct UHD_API tx_metadata_t{
- /*!
- * Has time specification?
- * - Set false to send immediately.
- * - Set true to send at the time specified by time spec.
- */
- bool has_time_spec;
+ std::string to_pp_string(bool compact = true) const;
- //! When to send the first sample.
- time_spec_t time_spec;
+ /*!
+ * Similar to C's strerror() function, creates a std::string describing the error
+ * code. \return a printable string representing the error.
+ */
+ std::string strerror(void) const;
+};
+
+/*!
+ * TX metadata structure for describing received IF data.
+ * Includes time specification, and start and stop burst flags.
+ * The send routines will convert the metadata to IF data headers.
+ */
+struct UHD_API tx_metadata_t
+{
+ /*!
+ * Has time specification?
+ * - Set false to send immediately.
+ * - Set true to send at the time specified by time spec.
+ */
+ bool has_time_spec;
- //! Set start of burst to true for the first packet in the chain.
- bool start_of_burst;
+ //! When to send the first sample.
+ time_spec_t time_spec;
- //! Set end of burst to true for the last packet in the chain.
- bool end_of_burst;
+ //! Set start of burst to true for the first packet in the chain.
+ bool start_of_burst;
- /*!
- * The default constructor:
- * Sets the fields to default values (flags set to false).
- */
- tx_metadata_t(void);
- };
+ //! Set end of burst to true for the last packet in the chain.
+ bool end_of_burst;
/*!
- * Async metadata structure for describing transmit related events.
+ * The default constructor:
+ * Sets the fields to default values (flags set to false).
*/
- struct UHD_API async_metadata_t{
- //! The channel number in a mimo configuration
- size_t channel;
+ tx_metadata_t(void);
+};
- //! Has time specification?
- bool has_time_spec;
+/*!
+ * Async metadata structure for describing transmit related events.
+ */
+struct UHD_API async_metadata_t
+{
+ //! The channel number in a mimo configuration
+ size_t channel;
- //! When the async event occurred.
- time_spec_t time_spec;
+ //! Has time specification?
+ bool has_time_spec;
- /*!
- * The type of event for a receive async message call.
- */
- enum event_code_t {
- //! A burst was successfully transmitted.
- EVENT_CODE_BURST_ACK = 0x1,
- //! An internal send buffer has emptied.
- EVENT_CODE_UNDERFLOW = 0x2,
- //! Packet loss between host and device.
- EVENT_CODE_SEQ_ERROR = 0x4,
- //! Packet had time that was late.
- EVENT_CODE_TIME_ERROR = 0x8,
- //! Underflow occurred inside a packet.
- EVENT_CODE_UNDERFLOW_IN_PACKET = 0x10,
- //! Packet loss within a burst.
- EVENT_CODE_SEQ_ERROR_IN_BURST = 0x20,
- //! Some kind of custom user payload
- EVENT_CODE_USER_PAYLOAD = 0x40
- } event_code;
+ //! When the async event occurred.
+ time_spec_t time_spec;
- /*!
- * A special payload populated by custom FPGA fabric.
- */
- uint32_t user_payload[4];
+ /*!
+ * The type of event for a receive async message call.
+ */
+ enum event_code_t {
+ //! A burst was successfully transmitted.
+ EVENT_CODE_BURST_ACK = 0x1,
+ //! An internal send buffer has emptied.
+ EVENT_CODE_UNDERFLOW = 0x2,
+ //! Packet loss between host and device.
+ EVENT_CODE_SEQ_ERROR = 0x4,
+ //! Packet had time that was late.
+ EVENT_CODE_TIME_ERROR = 0x8,
+ //! Underflow occurred inside a packet.
+ EVENT_CODE_UNDERFLOW_IN_PACKET = 0x10,
+ //! Packet loss within a burst.
+ EVENT_CODE_SEQ_ERROR_IN_BURST = 0x20,
+ //! Some kind of custom user payload
+ EVENT_CODE_USER_PAYLOAD = 0x40
+ } event_code;
- };
+ /*!
+ * A special payload populated by custom FPGA fabric.
+ */
+ uint32_t user_payload[4];
+};
-} //namespace uhd
+} // 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
index 6dc634fc8..ff761cc55 100644
--- a/host/include/uhd/types/otw_type.hpp
+++ b/host/include/uhd/types/otw_type.hpp
@@ -1,2 +1,2 @@
-//The OTW type API has been deprecated in favor of the streamer interface
+// The OTW type API has been deprecated in favor of the streamer interface
#include <uhd/deprecated.hpp>
diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp
index 862b5ba8a..982fdae98 100644
--- a/host/include/uhd/types/ranges.hpp
+++ b/host/include/uhd/types/ranges.hpp
@@ -12,104 +12,106 @@
#include <string>
#include <vector>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * A range object describes a set of discrete values of the form:
+ * y = start + step*n, where n is an integer between 0 and (stop - start)/step
+ */
+class UHD_API range_t
+{
+public:
+ /*!
+ * Create a range from a single value.
+ * The step size will be taken as zero.
+ * \param value the only possible value in this range
+ */
+ range_t(double value = 0);
/*!
- * A range object describes a set of discrete values of the form:
- * y = start + step*n, where n is an integer between 0 and (stop - start)/step
+ * Create a range from a full set of values.
+ * A step size of zero implies infinite precision.
+ * \param start the minimum value for this range
+ * \param stop the maximum value for this range
+ * \param step the step size for this range
*/
- class UHD_API range_t{
- public:
+ range_t(double start, double stop, double step = 0);
- /*!
- * Create a range from a single value.
- * The step size will be taken as zero.
- * \param value the only possible value in this range
- */
- range_t(double value = 0);
+ //! Get the start value for this range.
+ double start(void) const;
- /*!
- * Create a range from a full set of values.
- * A step size of zero implies infinite precision.
- * \param start the minimum value for this range
- * \param stop the maximum value for this range
- * \param step the step size for this range
- */
- range_t(double start, double stop, double step = 0);
+ //! Get the stop value for this range.
+ double stop(void) const;
- //! Get the start value for this range.
- double start(void) const;
+ //! Get the step value for this range.
+ double step(void) const;
- //! Get the stop value for this range.
- double stop(void) const;
+ //! Convert this range to a printable string
+ const std::string to_pp_string(void) const;
- //! Get the step value for this range.
- double step(void) const;
+ //! Equality operator
+ bool operator==(const range_t& other) const;
- //! Convert this range to a printable string
- const std::string to_pp_string(void) const;
+ //! Inequality operator
+ bool operator!=(const range_t& other) const;
- //! Equality operator
- bool operator==(const range_t &other) const;
+private:
+ double _start, _stop, _step;
+};
- //! Inequality operator
- bool operator!=(const range_t &other) const;
+/*!
+ * A meta-range object holds a list of individual ranges.
+ */
+struct UHD_API meta_range_t : std::vector<range_t>
+{
+ //! A default constructor for an empty meta-range
+ meta_range_t(void);
- private: double _start, _stop, _step;
- };
+ /*!
+ * Input iterator constructor:
+ * Makes boost::assign::list_of work.
+ * \param first the begin iterator
+ * \param last the end iterator
+ */
+ template <typename InputIterator>
+ meta_range_t(InputIterator first, InputIterator last)
+ : std::vector<range_t>(first, last)
+ { /* NOP */
+ }
/*!
- * A meta-range object holds a list of individual ranges.
+ * A convenience constructor for a single range.
+ * A step size of zero implies infinite precision.
+ * \param start the minimum value for this range
+ * \param stop the maximum value for this range
+ * \param step the step size for this range
*/
- struct UHD_API meta_range_t : std::vector<range_t>{
-
- //! A default constructor for an empty meta-range
- meta_range_t(void);
-
- /*!
- * Input iterator constructor:
- * Makes boost::assign::list_of work.
- * \param first the begin iterator
- * \param last the end iterator
- */
- template <typename InputIterator>
- meta_range_t(InputIterator first, InputIterator last):
- std::vector<range_t>(first, last){ /* NOP */ }
-
- /*!
- * A convenience constructor for a single range.
- * A step size of zero implies infinite precision.
- * \param start the minimum value for this range
- * \param stop the maximum value for this range
- * \param step the step size for this range
- */
- meta_range_t(double start, double stop, double step = 0);
-
- //! Get the overall start value for this meta-range.
- double start(void) const;
-
- //! Get the overall stop value for this meta-range.
- double stop(void) const;
-
- //! Get the overall step value for this meta-range.
- double step(void) const;
-
- /*!
- * Clip the target value to a possible range value.
- * \param value the value to clip to this range
- * \param clip_step if true, clip to steps as well
- * \return a value that is in one of the ranges
- */
- double clip(double value, bool clip_step = false) const;
-
- //! Convert this meta-range to a printable string
- const std::string to_pp_string(void) const;
-
- };
-
- typedef meta_range_t gain_range_t;
- typedef meta_range_t freq_range_t;
-
-} //namespace uhd
+ meta_range_t(double start, double stop, double step = 0);
+
+ //! Get the overall start value for this meta-range.
+ double start(void) const;
+
+ //! Get the overall stop value for this meta-range.
+ double stop(void) const;
+
+ //! Get the overall step value for this meta-range.
+ double step(void) const;
+
+ /*!
+ * Clip the target value to a possible range value.
+ * \param value the value to clip to this range
+ * \param clip_step if true, clip to steps as well
+ * \return a value that is in one of the ranges
+ */
+ double clip(double value, bool clip_step = false) const;
+
+ //! Convert this meta-range to a printable string
+ const std::string to_pp_string(void) const;
+};
+
+typedef meta_range_t gain_range_t;
+typedef meta_range_t freq_range_t;
+
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_RANGES_HPP */
diff --git a/host/include/uhd/types/ref_vector.hpp b/host/include/uhd/types/ref_vector.hpp
index 6cbc5edd9..2a1fc0aad 100644
--- a/host/include/uhd/types/ref_vector.hpp
+++ b/host/include/uhd/types/ref_vector.hpp
@@ -11,22 +11,23 @@
#include <uhd/config.hpp>
#include <cstddef>
-namespace uhd{
+namespace uhd {
/*!
* Reference vector:
* - Provides a std::vector-like interface for an array.
* - Statically sized, and does not manage the memory.
*/
-template <typename T> class UHD_API ref_vector{
+template <typename T> class UHD_API ref_vector
+{
public:
/*!
* Create a reference vector of size 1 from a pointer.
* Therefore: rv[0] == ptr and rv.size() == 1
* \param ptr a pointer to a chunk of memory
*/
- template <typename Ptr> ref_vector(Ptr *ptr):
- _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
+ template <typename Ptr>
+ ref_vector(Ptr* ptr) : _ptr(T(ptr)), _mem(_mem_t(&_ptr)), _size(1)
{
/* NOP */
}
@@ -36,8 +37,9 @@ public:
* Therefore: rv[n] == vec[n] and rv.size() == vec.size()
* \param vec a const reference to an std::vector
*/
- template <typename Vector> ref_vector(const Vector &vec):
- _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
+ template <typename Vector>
+ ref_vector(const Vector& vec)
+ : _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size())
{
/* NOP */
}
@@ -48,29 +50,30 @@ public:
* \param mem a pointer to an array of pointers
* \param len the length of the array of pointers
*/
- ref_vector(const T *mem, size_t len):
- _ptr(T()), _mem(_mem_t(mem)), _size(len)
+ ref_vector(const T* mem, size_t len) : _ptr(T()), _mem(_mem_t(mem)), _size(len)
{
/* NOP */
}
//! Index operator gets the value of rv[index]
- const T &operator[](size_t index) const{
+ const T& operator[](size_t index) const
+ {
return _mem[index];
}
//! The number of elements in this container
- size_t size(void) const{
+ size_t size(void) const
+ {
return _size;
}
private:
- const T _ptr;
- typedef T* _mem_t;
+ const T _ptr;
+ typedef T* _mem_t;
const _mem_t _mem;
const size_t _size;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_REF_VECTOR_HPP */
diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp
index 4f1b64534..5423f2423 100644
--- a/host/include/uhd/types/sensors.hpp
+++ b/host/include/uhd/types/sensors.hpp
@@ -12,142 +12,127 @@
#include <map>
#include <string>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * A sensor value stores a sensor reading as a string with unit and data type.
+ * The sensor value class can be used in the following way:
+ *
+ * sensor_value_t ref_lock_sensor("Reference", my_lock, "unlocked", "locked");
+ * std::cout << ref_lock_sensor.to_pp_string() << std::endl;
+ * //prints Reference: locked
+ *
+ * sensor_value_t temp_sensor("Temperature", my_temp, "C");
+ * std::cout << temp_sensor.to_pp_string() << std::endl;
+ * //prints Temperature: 38.5 C
+ */
+struct UHD_API sensor_value_t
+{
+ typedef std::map<std::string, std::string> sensor_map_t;
/*!
- * A sensor value stores a sensor reading as a string with unit and data type.
- * The sensor value class can be used in the following way:
+ * Create a sensor value from a boolean.
+ * \param name the name of the sensor
+ * \param value the value true or false
+ * \param utrue the unit string when value is true
+ * \param ufalse the unit string when value is false
+ */
+ sensor_value_t(const std::string& name,
+ bool value,
+ const std::string& utrue,
+ const std::string& ufalse);
+
+ /*!
+ * Create a sensor value from an integer.
+ * \param name the name of the sensor
+ * \param value the signed integer value
+ * \param unit the associated unit type
+ * \param formatter the formatter string
+ */
+ sensor_value_t(const std::string& name,
+ signed value,
+ const std::string& unit,
+ const std::string& formatter = "%d");
+
+ /*!
+ * Create a sensor value from a real number.
+ * \param name the name of the sensor
+ * \param value the real number value
+ * \param unit the associated unit type
+ * \param formatter the formatter string
+ */
+ sensor_value_t(const std::string& name,
+ double value,
+ const std::string& unit,
+ const std::string& formatter = "%f");
+
+ /*!
+ * Create a sensor value from a string.
+ * \param name the name of the sensor
+ * \param value the real number value
+ * \param unit the associated unit type
+ */
+ sensor_value_t(
+ const std::string& name, const std::string& value, const std::string& unit);
+
+ /*!
+ * Create a sensor value from a map.
*
- * sensor_value_t ref_lock_sensor("Reference", my_lock, "unlocked", "locked");
- * std::cout << ref_lock_sensor.to_pp_string() << std::endl;
- * //prints Reference: locked
+ * The map must have the following keys: name, type, value, and unit.
*
- * sensor_value_t temp_sensor("Temperature", my_temp, "C");
- * std::cout << temp_sensor.to_pp_string() << std::endl;
- * //prints Temperature: 38.5 C
+ * type must one of the following strings: BOOLEAN, INTEGER, REALNUM,
+ * or STRING (see data_type_t).
*/
- struct UHD_API sensor_value_t{
- typedef std::map<std::string, std::string> sensor_map_t;
-
- /*!
- * Create a sensor value from a boolean.
- * \param name the name of the sensor
- * \param value the value true or false
- * \param utrue the unit string when value is true
- * \param ufalse the unit string when value is false
- */
- sensor_value_t(
- const std::string &name,
- bool value,
- const std::string &utrue,
- const std::string &ufalse
- );
-
- /*!
- * Create a sensor value from an integer.
- * \param name the name of the sensor
- * \param value the signed integer value
- * \param unit the associated unit type
- * \param formatter the formatter string
- */
- sensor_value_t(
- const std::string &name,
- signed value,
- const std::string &unit,
- const std::string &formatter = "%d"
- );
-
- /*!
- * Create a sensor value from a real number.
- * \param name the name of the sensor
- * \param value the real number value
- * \param unit the associated unit type
- * \param formatter the formatter string
- */
- sensor_value_t(
- const std::string &name,
- double value,
- const std::string &unit,
- const std::string &formatter = "%f"
- );
-
- /*!
- * Create a sensor value from a string.
- * \param name the name of the sensor
- * \param value the real number value
- * \param unit the associated unit type
- */
- sensor_value_t(
- const std::string &name,
- const std::string &value,
- const std::string &unit
- );
-
- /*!
- * Create a sensor value from a map.
- *
- * The map must have the following keys: name, type, value, and unit.
- *
- * type must one of the following strings: BOOLEAN, INTEGER, REALNUM,
- * or STRING (see data_type_t).
- */
- sensor_value_t(
- const std::map<std::string, std::string> &sensor_dict
- );
-
- /*!
- * Create a sensor value from another sensor value.
- * \param source the source sensor value to copy
- */
- sensor_value_t(const sensor_value_t& source);
-
- //! convert the sensor value to a boolean
- bool to_bool(void) const;
-
- //! convert the sensor value to an integer
- signed to_int(void) const;
-
- //! convert the sensor value to real number
- double to_real(void) const;
-
- //! convert the sensor value to sensor_map_t
- sensor_map_t to_map(void) const;
-
- //! The name of the sensor value
- std::string name;
-
- /*!
- * The sensor value as a string.
- * For integer and real number types, this will be the output of the formatter.
- * For boolean types, the value will be the string literal "true" or "false".
- */
- std::string value;
-
- /*!
- * The sensor value's unit type.
- * For boolean types, this will be the one of the two units
- * depending upon the value of the boolean true or false.
- */
- std::string unit;
-
- //! Enumeration of possible data types in a sensor
- enum data_type_t {
- BOOLEAN = 'b',
- INTEGER = 'i',
- REALNUM = 'r',
- STRING = 's'
- };
-
- //! The data type of the value
- data_type_t type;
-
- //! Convert this sensor value into a printable string
- std::string to_pp_string(void) const;
-
- //! Assignment operator for sensor value
- sensor_value_t& operator=(const sensor_value_t& value);
- };
-
-} //namespace uhd
+ sensor_value_t(const std::map<std::string, std::string>& sensor_dict);
+
+ /*!
+ * Create a sensor value from another sensor value.
+ * \param source the source sensor value to copy
+ */
+ sensor_value_t(const sensor_value_t& source);
+
+ //! convert the sensor value to a boolean
+ bool to_bool(void) const;
+
+ //! convert the sensor value to an integer
+ signed to_int(void) const;
+
+ //! convert the sensor value to real number
+ double to_real(void) const;
+
+ //! convert the sensor value to sensor_map_t
+ sensor_map_t to_map(void) const;
+
+ //! The name of the sensor value
+ std::string name;
+
+ /*!
+ * The sensor value as a string.
+ * For integer and real number types, this will be the output of the formatter.
+ * For boolean types, the value will be the string literal "true" or "false".
+ */
+ std::string value;
+
+ /*!
+ * The sensor value's unit type.
+ * For boolean types, this will be the one of the two units
+ * depending upon the value of the boolean true or false.
+ */
+ std::string unit;
+
+ //! Enumeration of possible data types in a sensor
+ enum data_type_t { BOOLEAN = 'b', INTEGER = 'i', REALNUM = 'r', STRING = 's' };
+
+ //! The data type of the value
+ data_type_t type;
+
+ //! Convert this sensor value into a printable string
+ std::string to_pp_string(void) const;
+
+ //! Assignment operator for sensor value
+ sensor_value_t& operator=(const sensor_value_t& value);
+};
+
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_SENSORS_HPP */
diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp
index 5ede2d4f5..b68c68870 100644
--- a/host/include/uhd/types/serial.hpp
+++ b/host/include/uhd/types/serial.hpp
@@ -9,198 +9,176 @@
#define INCLUDED_UHD_TYPES_SERIAL_HPP
#include <uhd/config.hpp>
-#include <boost/shared_ptr.hpp>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
#include <vector>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * Byte vector typedef for passing data in and out of I2C interfaces.
+ */
+typedef std::vector<uint8_t> byte_vector_t;
+
+/*!
+ * The i2c interface class:
+ * Provides i2c and eeprom functionality.
+ * A subclass should only have to implement the i2c routines.
+ * An eeprom implementation comes for free with the interface.
+ *
+ * The eeprom routines are implemented on top of i2c.
+ * The built in eeprom implementation only does single
+ * byte reads and byte writes over the i2c interface,
+ * so it should be portable across multiple eeproms.
+ * Override the eeprom routines if this is not acceptable.
+ */
+class UHD_API i2c_iface
+{
+public:
+ typedef boost::shared_ptr<i2c_iface> sptr;
+
+ virtual ~i2c_iface(void);
+
+ //! Create an i2c_iface than can talk to 16 bit addressable EEPROMS
+ i2c_iface::sptr eeprom16(void);
+
+ /*!
+ * Write bytes over the i2c.
+ * \param addr the address
+ * \param buf the vector of bytes
+ */
+ virtual void write_i2c(uint16_t addr, const byte_vector_t& buf) = 0;
+
+ /*!
+ * Read bytes over the i2c.
+ * \param addr the address
+ * \param num_bytes number of bytes to read
+ * \return a vector of bytes
+ */
+ virtual byte_vector_t read_i2c(uint16_t addr, size_t num_bytes) = 0;
+
+ /*!
+ * Write bytes to an eeprom.
+ * \param addr the address
+ * \param offset byte offset
+ * \param buf the vector of bytes
+ */
+ virtual void write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t& buf);
+
+ /*!
+ * Read bytes from an eeprom.
+ * \param addr the address
+ * \param offset byte offset
+ * \param num_bytes number of bytes to read
+ * \return a vector of bytes
+ */
+ virtual byte_vector_t read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes);
+};
+
+/*!
+ * The SPI configuration struct:
+ * Used to configure a SPI transaction interface.
+ */
+struct UHD_API spi_config_t
+{
+ /*!
+ * The edge type specifies when data is valid
+ * relative to the edge of the serial clock.
+ */
+ enum edge_t { EDGE_RISE = 'r', EDGE_FALL = 'f' };
+
+ //! on what edge is the mosi data valid?
+ edge_t mosi_edge;
+
+ //! on what edge is the miso data valid?
+ edge_t miso_edge;
+
+ //! Set the clock speed for this transaction
+ bool use_custom_divider;
+
+ //! Optionally set the SPI clock divider for this transaction
+ size_t divider;
+
+ /*!
+ * Create a new spi config.
+ * \param edge the default edge for mosi and miso
+ */
+ spi_config_t(edge_t edge = EDGE_RISE);
+};
+
+/*!
+ * The SPI interface class.
+ * Provides routines to transact SPI and do other useful things which haven't been defined
+ * yet.
+ */
+class UHD_API spi_iface
+{
+public:
+ typedef boost::shared_ptr<spi_iface> sptr;
+
+ virtual ~spi_iface(void);
/*!
- * Byte vector typedef for passing data in and out of I2C interfaces.
+ * Perform a spi transaction.
+ * \param which_slave the slave device number
+ * \param config spi config args
+ * \param data the bits to write
+ * \param num_bits how many bits in data
+ * \param readback true to readback a value
+ * \return spi data if readback set
*/
- typedef std::vector<uint8_t> byte_vector_t;
+ virtual uint32_t transact_spi(int which_slave,
+ const spi_config_t& config,
+ uint32_t data,
+ size_t num_bits,
+ bool readback) = 0;
/*!
- * The i2c interface class:
- * Provides i2c and eeprom functionality.
- * A subclass should only have to implement the i2c routines.
- * An eeprom implementation comes for free with the interface.
- *
- * The eeprom routines are implemented on top of i2c.
- * The built in eeprom implementation only does single
- * byte reads and byte writes over the i2c interface,
- * so it should be portable across multiple eeproms.
- * Override the eeprom routines if this is not acceptable.
+ * Read from the SPI bus.
+ * \param which_slave the slave device number
+ * \param config spi config args
+ * \param data the bits to write out (be sure to set write bit)
+ * \param num_bits how many bits in data
+ * \return spi data
*/
- class UHD_API i2c_iface{
- public:
- typedef boost::shared_ptr<i2c_iface> sptr;
-
- virtual ~i2c_iface(void);
-
- //! Create an i2c_iface than can talk to 16 bit addressable EEPROMS
- i2c_iface::sptr eeprom16(void);
-
- /*!
- * Write bytes over the i2c.
- * \param addr the address
- * \param buf the vector of bytes
- */
- virtual void write_i2c(
- uint16_t addr,
- const byte_vector_t &buf
- ) = 0;
-
- /*!
- * Read bytes over the i2c.
- * \param addr the address
- * \param num_bytes number of bytes to read
- * \return a vector of bytes
- */
- virtual byte_vector_t read_i2c(
- uint16_t addr,
- size_t num_bytes
- ) = 0;
-
- /*!
- * Write bytes to an eeprom.
- * \param addr the address
- * \param offset byte offset
- * \param buf the vector of bytes
- */
- virtual void write_eeprom(
- uint16_t addr,
- uint16_t offset,
- const byte_vector_t &buf
- );
-
- /*!
- * Read bytes from an eeprom.
- * \param addr the address
- * \param offset byte offset
- * \param num_bytes number of bytes to read
- * \return a vector of bytes
- */
- virtual byte_vector_t read_eeprom(
- uint16_t addr,
- uint16_t offset,
- size_t num_bytes
- );
- };
+ virtual uint32_t read_spi(
+ int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
/*!
- * The SPI configuration struct:
- * Used to configure a SPI transaction interface.
+ * Write to the SPI bus.
+ * \param which_slave the slave device number
+ * \param config spi config args
+ * \param data the bits to write
+ * \param num_bits how many bits in data
*/
- struct UHD_API spi_config_t{
- /*!
- * The edge type specifies when data is valid
- * relative to the edge of the serial clock.
- */
- enum edge_t{
- EDGE_RISE = 'r',
- EDGE_FALL = 'f'
- };
-
- //! on what edge is the mosi data valid?
- edge_t mosi_edge;
-
- //! on what edge is the miso data valid?
- edge_t miso_edge;
-
- //! Set the clock speed for this transaction
- bool use_custom_divider;
-
- //! Optionally set the SPI clock divider for this transaction
- size_t divider;
-
- /*!
- * Create a new spi config.
- * \param edge the default edge for mosi and miso
- */
- spi_config_t(edge_t edge = EDGE_RISE);
- };
+ virtual void write_spi(
+ int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
+};
+
+/*!
+ * UART interface to write and read strings.
+ */
+class UHD_API uart_iface
+{
+public:
+ typedef boost::shared_ptr<uart_iface> sptr;
+
+ virtual ~uart_iface(void);
/*!
- * The SPI interface class.
- * Provides routines to transact SPI and do other useful things which haven't been defined yet.
+ * Write to a serial port.
+ * \param buf the data to write
*/
- class UHD_API spi_iface{
- public:
- typedef boost::shared_ptr<spi_iface> sptr;
-
- virtual ~spi_iface(void);
-
- /*!
- * Perform a spi transaction.
- * \param which_slave the slave device number
- * \param config spi config args
- * \param data the bits to write
- * \param num_bits how many bits in data
- * \param readback true to readback a value
- * \return spi data if readback set
- */
- virtual uint32_t transact_spi(
- int which_slave,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits,
- bool readback
- ) = 0;
-
- /*!
- * Read from the SPI bus.
- * \param which_slave the slave device number
- * \param config spi config args
- * \param data the bits to write out (be sure to set write bit)
- * \param num_bits how many bits in data
- * \return spi data
- */
- virtual uint32_t read_spi(
- int which_slave,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
- );
-
- /*!
- * Write to the SPI bus.
- * \param which_slave the slave device number
- * \param config spi config args
- * \param data the bits to write
- * \param num_bits how many bits in data
- */
- virtual void write_spi(
- int which_slave,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
- );
- };
+ virtual void write_uart(const std::string& buf) = 0;
/*!
- * UART interface to write and read strings.
+ * Read a line from a serial port.
+ * \param timeout the timeout in seconds
+ * \return the line or empty string upon timeout
*/
- class UHD_API uart_iface{
- public:
- typedef boost::shared_ptr<uart_iface> sptr;
-
- virtual ~uart_iface(void);
-
- /*!
- * Write to a serial port.
- * \param buf the data to write
- */
- virtual void write_uart(const std::string &buf) = 0;
-
- /*!
- * Read a line from a serial port.
- * \param timeout the timeout in seconds
- * \return the line or empty string upon timeout
- */
- virtual std::string read_uart(double timeout) = 0;
- };
-
-} //namespace uhd
+ virtual std::string read_uart(double timeout) = 0;
+};
+
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
diff --git a/host/include/uhd/types/sid.hpp b/host/include/uhd/types/sid.hpp
index bb92646d0..fe3ac1ac7 100644
--- a/host/include/uhd/types/sid.hpp
+++ b/host/include/uhd/types/sid.hpp
@@ -9,229 +9,261 @@
#define INCLUDED_UHD_TYPES_SID_HPP
#include <uhd/config.hpp>
-#include <iostream>
#include <stdint.h>
+#include <iostream>
namespace uhd {
- /*!
- * \brief Represents a stream ID (SID).
- *
- * A stream ID (SID) is an identifier for data.
- * It is a 32-Bit value which consists of 16 Bits
- * for the source address and 16 Bits for the destination
- * address.
- * Every address is split into two parts: The _address_, which
- * identifies the device used, and the _endpoint_, which identifies
- * a specific object inside the given device (e.g., a block).
- * *Note:* In the case where there are several crossbars on a single
- * device, each crossbar gets its own address.
- * Both address and endpoint are 8 bits in length. If a 16-bit address
- * is required, we use the combination of the 8-bit address and the 8-bit
- * endpoint.
- *
- * <pre>
- * +-------------+--------------+-------------+--------------+
- * | SRC address | SRC endpoint | DST address | DST endpoint |
- * +-------------+--------------+-------------+--------------+
- * </pre>
- *
- * \section sid_str_repr String Representation (pretty printing)
- *
- * The string representation of a SID is of the form
- *
- * 2.3>0.6
- *
- * The '>' symbol shows the direction, so in this case,
- * data is flowing from address 2.3 to 0.6.
- *
- * As a convention, ':' is used instead of '.' when giving the
- * SID in hexadecimal numbers, and two characters are used for each
- * address part. As an example, the following two SIDs are identical:
- *
- * 2.3>0.16 (decimal)
- * 02:03>00:10 (hexadecimal)
- *
- * The format is:
- * SRC_ADDRESS.SRC_ENDPOINT>DST_ADDRESS.DST_ENDPOINT
- *
- *
- * \section sid_block_ports Block Ports
- *
- * In the special case where a block on a crossbar is addressed, the
- * endpoint is further split up into two parts of four bits each: The
- * first four bits specify the port number on the crossbar, whereas the
- * lower four bits represent the *block port*. As an example, consider
- * the following SID, given in hexadecimal:
- *
- * 00:10>02:A1
- *
- * In this example, assume data is flowing from the host computer to an
- * X300. The crossbar address is 02. The endpoint is A1, which means we
- * are accessing a block on crossbar port A (the tenth port), and are addressing
- * block port 1.
- *
- */
- class UHD_API sid_t
- {
- public:
- //! Create an unset SID
- sid_t();
- //! Create a sid_t object from a 32-Bit SID value
- sid_t(uint32_t sid);
- //! Create a sid_t object from its four components
- sid_t(uint8_t src_addr, uint8_t src_ep, uint8_t dst_addr, uint8_t dst_ep);
- //! Convert a string representation of a SID into its numerical representation
- sid_t(const std::string &);
-
- //! Return a decimal string representation of the SID.
- std::string to_pp_string() const;
- //! Return a hexadecimal string representation of the SID.
- std::string to_pp_string_hex() const;
-
- //! Returns true if this actually holds a valid SID
- bool is_set() const { return _set; };
-
- // Getters
- //
- //! Alias for get_sid()
- inline uint32_t get() const { return get_sid(); };
- //! Returns a 32-Bit representation of the SID if set, or zero otherwise.
- inline uint32_t get_sid() const { return _set ? _sid : 0; };
- //! Return the 16-bit source address of this SID
- inline uint32_t get_src() const {
- return (_sid >> 16) & 0xFFFF;
- }
- //! Return the 16-bit destination address of this SID
- inline uint32_t get_dst() const {
- return _sid & 0xFFFF;
- }
- //! Return 8-bit address of the source
- inline uint32_t get_src_addr() const {
- return (get_src() >> 8) & 0xFF;
- }
- //! Return endpoint of the source
- inline uint32_t get_src_endpoint() const {
- return get_src() & 0xFF;
- }
- //! Return crossbar port of the source
- inline uint32_t get_src_xbarport() const {
- return (get_src_endpoint() >> 4) & 0xF;
- }
- //! Return block port of the source
- inline uint32_t get_src_blockport() const {
- return (get_src_endpoint()) & 0xF;
- }
- //! Return 8-bit address of the destination
- inline uint32_t get_dst_addr() const {
- return (get_dst() >> 8) & 0xFF;
- }
- //! Return endpoint of the destination
- inline uint32_t get_dst_endpoint() const {
- return get_dst() & 0xFF;
- }
- //! Return crossbar port of the source
- inline uint32_t get_dst_xbarport() const {
- return (get_dst_endpoint() >> 4) & 0xF;
- }
- //! Return block port of the source
- inline uint32_t get_dst_blockport() const {
- return (get_dst_endpoint()) & 0xF;
- }
-
- // Setters
-
- //! Alias for set_sid()
- void set(uint32_t new_sid) { set_sid(new_sid); };
- //! Convert a string representation of a SID into a numerical one
- // Throws uhd::value_error if the string is not a valid SID
- // representation.
- void set_from_str(const std::string &);
- void set_sid(uint32_t new_sid);
- //! Set the source address of this SID
- // (the first 16 Bits)
- void set_src(uint32_t new_addr);
- //! Set the destination address of this SID
- // (the last 16 Bits)
- void set_dst(uint32_t new_addr);
- void set_src_addr(uint32_t new_addr);
- void set_src_endpoint(uint32_t new_addr);
- void set_dst_addr(uint32_t new_addr);
- void set_dst_endpoint(uint32_t new_addr);
- void set_dst_xbarport(uint32_t new_xbarport);
- void set_dst_blockport(uint32_t new_blockport);
-
- // Manipulators
-
- //! Swaps dst and src address and returns the new SID.
- sid_t reversed() const;
-
- //! Swaps dst and src in-place. This modifies the current SID.
- void reverse();
-
- // Overloaded operators
-
- sid_t operator = (const uint32_t new_sid) {
- set_sid(new_sid);
- return *this;
- }
-
- sid_t operator = (sid_t &sid) {
- set_sid(sid.get_sid());
- return *this;
- }
-
- sid_t operator = (const sid_t &sid) {
- set_sid(sid.get_sid());
- return *this;
- }
-
- sid_t operator = (const std::string &sid_str) {
- set_from_str(sid_str);
- return *this;
- }
-
- bool operator == (const sid_t &sid) const {
- return (not _set and not sid.is_set()) or (_sid == sid.get_sid());
- }
-
- bool operator == (uint32_t sid) const {
- return _set and _sid == sid;
- }
-
- bool operator == (const std::string &sid_str) const {
- sid_t rhs(sid_str);
- return *this == rhs;
- }
-
- // overloaded type casts are tricky, but for now we'll need them
- // for backward compatibility. consider them deprecated.
-
- //! If the SID is not set, always returns zero.
- // Use is_set() to check if the return value is valid.
- operator uint32_t() const {
- return get();
- }
-
- operator bool() const {
- return _set;
- }
-
- private:
- uint32_t _sid;
- bool _set;
+/*!
+ * \brief Represents a stream ID (SID).
+ *
+ * A stream ID (SID) is an identifier for data.
+ * It is a 32-Bit value which consists of 16 Bits
+ * for the source address and 16 Bits for the destination
+ * address.
+ * Every address is split into two parts: The _address_, which
+ * identifies the device used, and the _endpoint_, which identifies
+ * a specific object inside the given device (e.g., a block).
+ * *Note:* In the case where there are several crossbars on a single
+ * device, each crossbar gets its own address.
+ * Both address and endpoint are 8 bits in length. If a 16-bit address
+ * is required, we use the combination of the 8-bit address and the 8-bit
+ * endpoint.
+ *
+ * <pre>
+ * +-------------+--------------+-------------+--------------+
+ * | SRC address | SRC endpoint | DST address | DST endpoint |
+ * +-------------+--------------+-------------+--------------+
+ * </pre>
+ *
+ * \section sid_str_repr String Representation (pretty printing)
+ *
+ * The string representation of a SID is of the form
+ *
+ * 2.3>0.6
+ *
+ * The '>' symbol shows the direction, so in this case,
+ * data is flowing from address 2.3 to 0.6.
+ *
+ * As a convention, ':' is used instead of '.' when giving the
+ * SID in hexadecimal numbers, and two characters are used for each
+ * address part. As an example, the following two SIDs are identical:
+ *
+ * 2.3>0.16 (decimal)
+ * 02:03>00:10 (hexadecimal)
+ *
+ * The format is:
+ * SRC_ADDRESS.SRC_ENDPOINT>DST_ADDRESS.DST_ENDPOINT
+ *
+ *
+ * \section sid_block_ports Block Ports
+ *
+ * In the special case where a block on a crossbar is addressed, the
+ * endpoint is further split up into two parts of four bits each: The
+ * first four bits specify the port number on the crossbar, whereas the
+ * lower four bits represent the *block port*. As an example, consider
+ * the following SID, given in hexadecimal:
+ *
+ * 00:10>02:A1
+ *
+ * In this example, assume data is flowing from the host computer to an
+ * X300. The crossbar address is 02. The endpoint is A1, which means we
+ * are accessing a block on crossbar port A (the tenth port), and are addressing
+ * block port 1.
+ *
+ */
+class UHD_API sid_t
+{
+public:
+ //! Create an unset SID
+ sid_t();
+ //! Create a sid_t object from a 32-Bit SID value
+ sid_t(uint32_t sid);
+ //! Create a sid_t object from its four components
+ sid_t(uint8_t src_addr, uint8_t src_ep, uint8_t dst_addr, uint8_t dst_ep);
+ //! Convert a string representation of a SID into its numerical representation
+ sid_t(const std::string&);
+
+ //! Return a decimal string representation of the SID.
+ std::string to_pp_string() const;
+ //! Return a hexadecimal string representation of the SID.
+ std::string to_pp_string_hex() const;
+
+ //! Returns true if this actually holds a valid SID
+ bool is_set() const
+ {
+ return _set;
+ };
+
+ // Getters
+ //
+ //! Alias for get_sid()
+ inline uint32_t get() const
+ {
+ return get_sid();
+ };
+ //! Returns a 32-Bit representation of the SID if set, or zero otherwise.
+ inline uint32_t get_sid() const
+ {
+ return _set ? _sid : 0;
+ };
+ //! Return the 16-bit source address of this SID
+ inline uint32_t get_src() const
+ {
+ return (_sid >> 16) & 0xFFFF;
+ }
+ //! Return the 16-bit destination address of this SID
+ inline uint32_t get_dst() const
+ {
+ return _sid & 0xFFFF;
+ }
+ //! Return 8-bit address of the source
+ inline uint32_t get_src_addr() const
+ {
+ return (get_src() >> 8) & 0xFF;
+ }
+ //! Return endpoint of the source
+ inline uint32_t get_src_endpoint() const
+ {
+ return get_src() & 0xFF;
+ }
+ //! Return crossbar port of the source
+ inline uint32_t get_src_xbarport() const
+ {
+ return (get_src_endpoint() >> 4) & 0xF;
+ }
+ //! Return block port of the source
+ inline uint32_t get_src_blockport() const
+ {
+ return (get_src_endpoint()) & 0xF;
+ }
+ //! Return 8-bit address of the destination
+ inline uint32_t get_dst_addr() const
+ {
+ return (get_dst() >> 8) & 0xFF;
+ }
+ //! Return endpoint of the destination
+ inline uint32_t get_dst_endpoint() const
+ {
+ return get_dst() & 0xFF;
+ }
+ //! Return crossbar port of the source
+ inline uint32_t get_dst_xbarport() const
+ {
+ return (get_dst_endpoint() >> 4) & 0xF;
+ }
+ //! Return block port of the source
+ inline uint32_t get_dst_blockport() const
+ {
+ return (get_dst_endpoint()) & 0xF;
+ }
+
+ // Setters
+
+ //! Alias for set_sid()
+ void set(uint32_t new_sid)
+ {
+ set_sid(new_sid);
};
+ //! Convert a string representation of a SID into a numerical one
+ // Throws uhd::value_error if the string is not a valid SID
+ // representation.
+ void set_from_str(const std::string&);
+ void set_sid(uint32_t new_sid);
+ //! Set the source address of this SID
+ // (the first 16 Bits)
+ void set_src(uint32_t new_addr);
+ //! Set the destination address of this SID
+ // (the last 16 Bits)
+ void set_dst(uint32_t new_addr);
+ void set_src_addr(uint32_t new_addr);
+ void set_src_endpoint(uint32_t new_addr);
+ void set_dst_addr(uint32_t new_addr);
+ void set_dst_endpoint(uint32_t new_addr);
+ void set_dst_xbarport(uint32_t new_xbarport);
+ void set_dst_blockport(uint32_t new_blockport);
+
+ // Manipulators
+
+ //! Swaps dst and src address and returns the new SID.
+ sid_t reversed() const;
+
+ //! Swaps dst and src in-place. This modifies the current SID.
+ void reverse();
+
+ // Overloaded operators
+
+ sid_t operator=(const uint32_t new_sid)
+ {
+ set_sid(new_sid);
+ return *this;
+ }
+
+ sid_t operator=(sid_t& sid)
+ {
+ set_sid(sid.get_sid());
+ return *this;
+ }
+
+ sid_t operator=(const sid_t& sid)
+ {
+ set_sid(sid.get_sid());
+ return *this;
+ }
+
+ sid_t operator=(const std::string& sid_str)
+ {
+ set_from_str(sid_str);
+ return *this;
+ }
+
+ bool operator==(const sid_t& sid) const
+ {
+ return (not _set and not sid.is_set()) or (_sid == sid.get_sid());
+ }
+
+ bool operator==(uint32_t sid) const
+ {
+ return _set and _sid == sid;
+ }
+
+ bool operator==(const std::string& sid_str) const
+ {
+ sid_t rhs(sid_str);
+ return *this == rhs;
+ }
+
+ // overloaded type casts are tricky, but for now we'll need them
+ // for backward compatibility. consider them deprecated.
+
+ //! If the SID is not set, always returns zero.
+ // Use is_set() to check if the return value is valid.
+ operator uint32_t() const
+ {
+ return get();
+ }
+
+ operator bool() const
+ {
+ return _set;
+ }
+
+private:
+ uint32_t _sid;
+ bool _set;
+};
- //! Stream output operator. Honors std::ios::hex.
- inline std::ostream& operator<< (std::ostream& out, const sid_t &sid) {
- std::ios_base::fmtflags ff = out.flags();
- if (ff & std::ios::hex) {
- out << sid.to_pp_string_hex();
- } else {
- out << sid.to_pp_string();
- }
- return out;
+//! Stream output operator. Honors std::ios::hex.
+inline std::ostream& operator<<(std::ostream& out, const sid_t& sid)
+{
+ std::ios_base::fmtflags ff = out.flags();
+ if (ff & std::ios::hex) {
+ out << sid.to_pp_string_hex();
+ } else {
+ out << sid.to_pp_string();
}
+ return out;
+}
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_SID_HPP */
diff --git a/host/include/uhd/types/stream_cmd.hpp b/host/include/uhd/types/stream_cmd.hpp
index 5628e8d92..9cd1e581f 100644
--- a/host/include/uhd/types/stream_cmd.hpp
+++ b/host/include/uhd/types/stream_cmd.hpp
@@ -11,43 +11,43 @@
#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 mode parameter controls how streaming is issued to the device:
- * - "Start continuous" tells the device to stream samples indefinitely.
- * - "Stop continuous" tells the device to end continuous streaming.
- * - "Num samps and done" tells the device to stream num samps and
- * to not expect a future stream command for contiguous samples.
- * - "Num samps and more" tells the device to stream num samps and
- * to expect a future stream command for contiguous samples.
- *
- * 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.
- */
- struct UHD_API stream_cmd_t{
-
- enum stream_mode_t {
- STREAM_MODE_START_CONTINUOUS = int('a'),
- STREAM_MODE_STOP_CONTINUOUS = int('o'),
- STREAM_MODE_NUM_SAMPS_AND_DONE = int('d'),
- STREAM_MODE_NUM_SAMPS_AND_MORE = int('m')
- } stream_mode;
- size_t num_samps;
-
- bool stream_now;
- time_spec_t time_spec;
-
- stream_cmd_t(const stream_mode_t &stream_mode);
- };
+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 mode parameter controls how streaming is issued to the device:
+ * - "Start continuous" tells the device to stream samples indefinitely.
+ * - "Stop continuous" tells the device to end continuous streaming.
+ * - "Num samps and done" tells the device to stream num samps and
+ * to not expect a future stream command for contiguous samples.
+ * - "Num samps and more" tells the device to stream num samps and
+ * to expect a future stream command for contiguous samples.
+ *
+ * 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.
+ */
+struct UHD_API stream_cmd_t
+{
+ enum stream_mode_t {
+ STREAM_MODE_START_CONTINUOUS = int('a'),
+ STREAM_MODE_STOP_CONTINUOUS = int('o'),
+ STREAM_MODE_NUM_SAMPS_AND_DONE = int('d'),
+ STREAM_MODE_NUM_SAMPS_AND_MORE = int('m')
+ } stream_mode;
+ size_t num_samps;
+
+ bool stream_now;
+ time_spec_t time_spec;
+
+ stream_cmd_t(const stream_mode_t& stream_mode);
+};
} /* namespace uhd */
diff --git a/host/include/uhd/types/time_spec.hpp b/host/include/uhd/types/time_spec.hpp
index c8d5443a0..89655807e 100644
--- a/host/include/uhd/types/time_spec.hpp
+++ b/host/include/uhd/types/time_spec.hpp
@@ -9,122 +9,123 @@
#define INCLUDED_UHD_TYPES_TIME_SPEC_HPP
#include <uhd/config.hpp>
-#include <boost/operators.hpp>
#include <stdint.h>
+#include <boost/operators.hpp>
-namespace uhd{
+namespace uhd {
+
+/*!
+ * A time_spec_t holds a seconds and a fractional seconds time value.
+ * Depending upon usage, the time_spec_t can represent absolute times,
+ * relative times, or time differences (between absolute times).
+ *
+ * The time_spec_t provides clock-domain independent time storage,
+ * but can convert fractional seconds to/from clock-domain specific units.
+ *
+ * The fractional seconds are stored as double precision floating point.
+ * This gives the fractional seconds enough precision to unambiguously
+ * specify a clock-tick/sample-count up to rates of several petahertz.
+ */
+class UHD_API time_spec_t : boost::additive<time_spec_t>,
+ boost::additive<time_spec_t, double>,
+ boost::totally_ordered<time_spec_t>
+{
+public:
+ /*!
+ * Create a time_spec_t from a real-valued seconds count.
+ * \param secs the real-valued seconds count (default = 0)
+ */
+ time_spec_t(double secs = 0);
+
+ /*!
+ * Create a time_spec_t from whole and fractional seconds.
+ * \param full_secs the whole/integer seconds count
+ * \param frac_secs the fractional seconds count (default = 0)
+ */
+ time_spec_t(int64_t full_secs, double frac_secs = 0);
+
+ /*!
+ * Create a time_spec_t from whole seconds and fractional ticks.
+ * Translation from clock-domain specific units.
+ * \param full_secs the whole/integer seconds count
+ * \param tick_count the fractional seconds tick count
+ * \param tick_rate the number of ticks per second
+ */
+ time_spec_t(int64_t full_secs, long tick_count, double tick_rate);
+
+ /*!
+ * Create a time_spec_t from a 64-bit tick count.
+ * Translation from clock-domain specific units.
+ * \param ticks an integer count of ticks
+ * \param tick_rate the number of ticks per second
+ */
+ static time_spec_t from_ticks(long long ticks, double tick_rate);
+
+ /*!
+ * Convert the fractional seconds to clock ticks.
+ * Translation into clock-domain specific units.
+ * \param tick_rate the number of ticks per second
+ * \return the fractional seconds tick count
+ */
+ long get_tick_count(double tick_rate) const;
+
+ /*!
+ * Convert the time spec into a 64-bit tick count.
+ * Translation into clock-domain specific units.
+ * \param tick_rate the number of ticks per second
+ * \return an integer number of ticks
+ */
+ long long to_ticks(const double tick_rate) const;
+
+ /*!
+ * Get the time as a real-valued seconds count.
+ * Note: If this time_spec_t represents an absolute time,
+ * the precision of the fractional seconds may be lost.
+ * \return the real-valued seconds
+ */
+ double get_real_secs(void) const;
+
+ /*!
+ * Get the whole/integer part of the time in seconds.
+ * \return the whole/integer seconds
+ */
+ int64_t get_full_secs(void) const;
/*!
- * A time_spec_t holds a seconds and a fractional seconds time value.
- * Depending upon usage, the time_spec_t can represent absolute times,
- * relative times, or time differences (between absolute times).
- *
- * The time_spec_t provides clock-domain independent time storage,
- * but can convert fractional seconds to/from clock-domain specific units.
- *
- * The fractional seconds are stored as double precision floating point.
- * This gives the fractional seconds enough precision to unambiguously
- * specify a clock-tick/sample-count up to rates of several petahertz.
+ * Get the fractional part of the time in seconds.
+ * \return the fractional seconds
*/
- class UHD_API time_spec_t :
- boost::additive<time_spec_t>,
- boost::additive<time_spec_t, double>,
- boost::totally_ordered<time_spec_t>{
- public:
-
- /*!
- * Create a time_spec_t from a real-valued seconds count.
- * \param secs the real-valued seconds count (default = 0)
- */
- time_spec_t(double secs = 0);
-
- /*!
- * Create a time_spec_t from whole and fractional seconds.
- * \param full_secs the whole/integer seconds count
- * \param frac_secs the fractional seconds count (default = 0)
- */
- time_spec_t(int64_t full_secs, double frac_secs = 0);
-
- /*!
- * Create a time_spec_t from whole seconds and fractional ticks.
- * Translation from clock-domain specific units.
- * \param full_secs the whole/integer seconds count
- * \param tick_count the fractional seconds tick count
- * \param tick_rate the number of ticks per second
- */
- time_spec_t(int64_t full_secs, long tick_count, double tick_rate);
-
- /*!
- * Create a time_spec_t from a 64-bit tick count.
- * Translation from clock-domain specific units.
- * \param ticks an integer count of ticks
- * \param tick_rate the number of ticks per second
- */
- static time_spec_t from_ticks(long long ticks, double tick_rate);
-
- /*!
- * Convert the fractional seconds to clock ticks.
- * Translation into clock-domain specific units.
- * \param tick_rate the number of ticks per second
- * \return the fractional seconds tick count
- */
- long get_tick_count(double tick_rate) const;
-
- /*!
- * Convert the time spec into a 64-bit tick count.
- * Translation into clock-domain specific units.
- * \param tick_rate the number of ticks per second
- * \return an integer number of ticks
- */
- long long to_ticks(const double tick_rate) const;
-
- /*!
- * Get the time as a real-valued seconds count.
- * Note: If this time_spec_t represents an absolute time,
- * the precision of the fractional seconds may be lost.
- * \return the real-valued seconds
- */
- double get_real_secs(void) const;
-
- /*!
- * Get the whole/integer part of the time in seconds.
- * \return the whole/integer seconds
- */
- int64_t get_full_secs(void) const;
-
- /*!
- * Get the fractional part of the time in seconds.
- * \return the fractional seconds
- */
- double get_frac_secs(void) const;
-
- //! Implement addable interface
- time_spec_t &operator+=(const time_spec_t &);
- time_spec_t &operator+=(double &);
- //! Implement subtractable interface
- time_spec_t &operator-=(const time_spec_t &);
- time_spec_t &operator-=(double &);
-
- //private time storage details
- private:
- int64_t _full_secs;
- double _frac_secs;
- };
-
- //! Implement equality_comparable interface
- UHD_API bool operator==(const time_spec_t &, const time_spec_t &);
-
- //! Implement less_than_comparable interface
- UHD_API bool operator<(const time_spec_t &, const time_spec_t &);
-
- UHD_INLINE int64_t time_spec_t::get_full_secs(void) const{
- return this->_full_secs;
- }
-
- UHD_INLINE double time_spec_t::get_frac_secs(void) const{
- return this->_frac_secs;
- }
-
-} //namespace uhd
+ double get_frac_secs(void) const;
+
+ //! Implement addable interface
+ time_spec_t& operator+=(const time_spec_t&);
+ time_spec_t& operator+=(double&);
+ //! Implement subtractable interface
+ time_spec_t& operator-=(const time_spec_t&);
+ time_spec_t& operator-=(double&);
+
+ // private time storage details
+private:
+ int64_t _full_secs;
+ double _frac_secs;
+};
+
+//! Implement equality_comparable interface
+UHD_API bool operator==(const time_spec_t&, const time_spec_t&);
+
+//! Implement less_than_comparable interface
+UHD_API bool operator<(const time_spec_t&, const time_spec_t&);
+
+UHD_INLINE int64_t time_spec_t::get_full_secs(void) const
+{
+ return this->_full_secs;
+}
+
+UHD_INLINE double time_spec_t::get_frac_secs(void) const
+{
+ return this->_frac_secs;
+}
+
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_TIME_SPEC_HPP */
diff --git a/host/include/uhd/types/tune_request.hpp b/host/include/uhd/types/tune_request.hpp
index ec7e70619..c85ca95a1 100644
--- a/host/include/uhd/types/tune_request.hpp
+++ b/host/include/uhd/types/tune_request.hpp
@@ -11,99 +11,99 @@
#include <uhd/config.hpp>
#include <uhd/types/device_addr.hpp>
-namespace uhd{
+namespace uhd {
+/*!
+ * A tune request instructs the implementation how to tune the RF chain.
+ * The policies can be used to select automatic tuning or
+ * fined control over the daughterboard IF and DSP tuning.
+ * Not all combinations of policies are applicable.
+ * Convenience constructors are supplied for most use cases.
+ *
+ * See also \ref general_tuning
+ */
+struct UHD_API tune_request_t
+{
/*!
- * A tune request instructs the implementation how to tune the RF chain.
- * The policies can be used to select automatic tuning or
- * fined control over the daughterboard IF and DSP tuning.
- * Not all combinations of policies are applicable.
- * Convenience constructors are supplied for most use cases.
- *
- * See also \ref general_tuning
+ * Make a new tune request for a particular center frequency.
+ * Use an automatic policy for the RF and DSP frequency
+ * to tune the chain as close as possible to the target frequency.
+ * \param target_freq the target frequency in Hz
*/
- struct UHD_API tune_request_t{
- /*!
- * Make a new tune request for a particular center frequency.
- * Use an automatic policy for the RF and DSP frequency
- * to tune the chain as close as possible to the target frequency.
- * \param target_freq the target frequency in Hz
- */
- tune_request_t(double target_freq = 0);
-
- /*!
- * Make a new tune request for a particular center frequency.
- * Use a manual policy for the RF frequency,
- * and an automatic policy for the DSP frequency,
- * to tune the chain as close as possible to the target frequency.
- * \param target_freq the target frequency in Hz
- * \param lo_off the LO offset frequency in Hz
- */
- tune_request_t(double target_freq, double lo_off);
+ tune_request_t(double target_freq = 0);
- //! Policy options for tunable elements in the RF chain.
- enum policy_t {
- //! Do not set this argument, use current setting.
- POLICY_NONE = int('N'),
- //! Automatically determine the argument's value.
- POLICY_AUTO = int('A'),
- //! Use the argument's value for the setting.
- POLICY_MANUAL = int('M')
- };
+ /*!
+ * Make a new tune request for a particular center frequency.
+ * Use a manual policy for the RF frequency,
+ * and an automatic policy for the DSP frequency,
+ * to tune the chain as close as possible to the target frequency.
+ * \param target_freq the target frequency in Hz
+ * \param lo_off the LO offset frequency in Hz
+ */
+ tune_request_t(double target_freq, double lo_off);
- /*!
- * The target frequency of the overall chain in Hz.
- * Set this even if all policies are set to manual.
- */
- double target_freq;
+ //! Policy options for tunable elements in the RF chain.
+ enum policy_t {
+ //! Do not set this argument, use current setting.
+ POLICY_NONE = int('N'),
+ //! Automatically determine the argument's value.
+ POLICY_AUTO = int('A'),
+ //! Use the argument's value for the setting.
+ POLICY_MANUAL = int('M')
+ };
- /*!
- * The policy for the RF frequency.
- * Automatic behavior: the target frequency + default LO offset.
- */
- policy_t rf_freq_policy;
+ /*!
+ * The target frequency of the overall chain in Hz.
+ * Set this even if all policies are set to manual.
+ */
+ double target_freq;
- /*!
- * The RF frequency in Hz.
- * Set when the policy is set to manual.
- */
- double rf_freq;
+ /*!
+ * The policy for the RF frequency.
+ * Automatic behavior: the target frequency + default LO offset.
+ */
+ policy_t rf_freq_policy;
- /*!
- * The policy for the DSP frequency.
- * Automatic behavior: the difference between the target and IF.
- */
- policy_t dsp_freq_policy;
+ /*!
+ * The RF frequency in Hz.
+ * Set when the policy is set to manual.
+ */
+ double rf_freq;
- /*!
- * The DSP frequency in Hz.
- * Set when the policy is set to manual.
- *
- * Note that the meaning of the DSP frequency's sign differs between
- * TX and RX operations. The target frequency is the result of
- * `target_freq = rf_freq + sign * dsp_freq`. For TX, `sign` is
- * negative, and for RX, `sign` is positive.
- * Example: If both RF and DSP tuning policies are set to manual, and
- * `rf_freq` is set to 1 GHz, and `dsp_freq` is set to 10 MHz, the
- * actual target frequency is 990 MHz for a TX tune request, and
- * 1010 MHz for an RX tune request.
- */
- double dsp_freq;
+ /*!
+ * The policy for the DSP frequency.
+ * Automatic behavior: the difference between the target and IF.
+ */
+ policy_t dsp_freq_policy;
- /*!
- * The args parameter is used to pass arbitrary key/value pairs.
- * Possible keys used by args (depends on implementation):
- *
- * - mode_n: Allows the user to tell the daughterboard tune code
- * to choose between an integer N divider or fractional N divider.
- * Default is fractional N on boards that support fractional N tuning.
- * Fractional N provides greater tuning accuracy at the expense of spurs.
- * Possible options for this key: "integer" or "fractional".
- */
- device_addr_t args;
+ /*!
+ * The DSP frequency in Hz.
+ * Set when the policy is set to manual.
+ *
+ * Note that the meaning of the DSP frequency's sign differs between
+ * TX and RX operations. The target frequency is the result of
+ * `target_freq = rf_freq + sign * dsp_freq`. For TX, `sign` is
+ * negative, and for RX, `sign` is positive.
+ * Example: If both RF and DSP tuning policies are set to manual, and
+ * `rf_freq` is set to 1 GHz, and `dsp_freq` is set to 10 MHz, the
+ * actual target frequency is 990 MHz for a TX tune request, and
+ * 1010 MHz for an RX tune request.
+ */
+ double dsp_freq;
- };
+ /*!
+ * The args parameter is used to pass arbitrary key/value pairs.
+ * Possible keys used by args (depends on implementation):
+ *
+ * - mode_n: Allows the user to tell the daughterboard tune code
+ * to choose between an integer N divider or fractional N divider.
+ * Default is fractional N on boards that support fractional N tuning.
+ * Fractional N provides greater tuning accuracy at the expense of spurs.
+ * Possible options for this key: "integer" or "fractional".
+ */
+ device_addr_t args;
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_TUNE_REQUEST_HPP */
diff --git a/host/include/uhd/types/tune_result.hpp b/host/include/uhd/types/tune_result.hpp
index 50b4e9536..2860b50c6 100644
--- a/host/include/uhd/types/tune_result.hpp
+++ b/host/include/uhd/types/tune_result.hpp
@@ -11,68 +11,69 @@
#include <uhd/config.hpp>
#include <string>
-namespace uhd{
+namespace uhd {
- /*!
- * The tune result struct holds the RF and DSP tuned frequencies.
- */
- struct UHD_API tune_result_t{
- /*! The target RF frequency, clipped to be within system range
- *
- * If the requested frequency is within the range of the system, then
- * this variable will equal the requested frequency. If the requested
- * frequency is outside of the tunable range, however, this variable
- * will hold the value that it was 'clipped' to in order to keep tuning
- * in-bounds. */
- double clipped_rf_freq;
+/*!
+ * The tune result struct holds the RF and DSP tuned frequencies.
+ */
+struct UHD_API tune_result_t
+{
+ /*! The target RF frequency, clipped to be within system range
+ *
+ * If the requested frequency is within the range of the system, then
+ * this variable will equal the requested frequency. If the requested
+ * frequency is outside of the tunable range, however, this variable
+ * will hold the value that it was 'clipped' to in order to keep tuning
+ * in-bounds. */
+ double clipped_rf_freq;
- /*! Target RF Freq, including RF FE offset
- *
- * AUTO Tuning Policy:
- * This variable holds the requested center frequency, plus any LO
- * offset required by the radio front-end. Note that this is *not* the
- * LO offset requested by the user (if one exists), but rather one
- * required by the hardware (if required).
- *
- * MANUAL Tuning Policy:
- * This variable equals the RF frequency in the tune request. */
- double target_rf_freq;
+ /*! Target RF Freq, including RF FE offset
+ *
+ * AUTO Tuning Policy:
+ * This variable holds the requested center frequency, plus any LO
+ * offset required by the radio front-end. Note that this is *not* the
+ * LO offset requested by the user (if one exists), but rather one
+ * required by the hardware (if required).
+ *
+ * MANUAL Tuning Policy:
+ * This variable equals the RF frequency in the tune request. */
+ double target_rf_freq;
- /*! The frequency to which the RF LO actually tuned
- *
- * If this does not equal the `target_rf_freq`, then it is because the
- * target was outside of the range of the LO, or the LO was not able to
- * hit it exactly due to tuning accuracy. */
- double actual_rf_freq;
+ /*! The frequency to which the RF LO actually tuned
+ *
+ * If this does not equal the `target_rf_freq`, then it is because the
+ * target was outside of the range of the LO, or the LO was not able to
+ * hit it exactly due to tuning accuracy. */
+ double actual_rf_freq;
- /*! The frequency the CORDIC must adjust the RF
- *
- * AUTO Tuning Policy:
- * It is fairly common for the RF LO to not be able to exactly hit the
- * requested frequency. This variable holds the required adjustment the
- * CORDIC must make to the signal to bring it to the requested center
- * frequency.
- *
- * MANUAL Tuning Policy
- * This variable equals the DSP frequency in the tune request, clipped
- * to be within range of the DSP if it was outside. */
- double target_dsp_freq;
+ /*! The frequency the CORDIC must adjust the RF
+ *
+ * AUTO Tuning Policy:
+ * It is fairly common for the RF LO to not be able to exactly hit the
+ * requested frequency. This variable holds the required adjustment the
+ * CORDIC must make to the signal to bring it to the requested center
+ * frequency.
+ *
+ * MANUAL Tuning Policy
+ * This variable equals the DSP frequency in the tune request, clipped
+ * to be within range of the DSP if it was outside. */
+ double target_dsp_freq;
- /*! The frequency to which the CORDIC in the DSP actually tuned
- *
- * If we failed to hit the target DSP frequency, it is either because
- * the requested resolution wasn't possible or something went wrong in
- * the DSP. In most cases, it should equal the `target_dsp_freq` above.
- */
- double actual_dsp_freq;
+ /*! The frequency to which the CORDIC in the DSP actually tuned
+ *
+ * If we failed to hit the target DSP frequency, it is either because
+ * the requested resolution wasn't possible or something went wrong in
+ * the DSP. In most cases, it should equal the `target_dsp_freq` above.
+ */
+ double actual_dsp_freq;
- /*!
- * Create a pretty print string for this tune result struct.
- * \return the printable string
- */
- std::string to_pp_string(void) const;
- };
+ /*!
+ * Create a pretty print string for this tune result struct.
+ * \return the printable string
+ */
+ std::string to_pp_string(void) const;
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_TUNE_RESULT_HPP */
diff --git a/host/include/uhd/types/wb_iface.hpp b/host/include/uhd/types/wb_iface.hpp
index 53c381c86..495762118 100644
--- a/host/include/uhd/types/wb_iface.hpp
+++ b/host/include/uhd/types/wb_iface.hpp
@@ -13,8 +13,7 @@
#include <stdint.h>
#include <boost/shared_ptr.hpp>
-namespace uhd
-{
+namespace uhd {
class UHD_API wb_iface
{
@@ -85,6 +84,6 @@ public:
virtual void set_time(const time_spec_t& t) = 0;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_TYPES_WB_IFACE_HPP */
diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp
index 9d885dfc0..8f9873399 100644
--- a/host/include/uhd/usrp/dboard_base.hpp
+++ b/host/include/uhd/usrp/dboard_base.hpp
@@ -9,20 +9,21 @@
#include <uhd/config.hpp>
#include <uhd/property_tree.hpp>
-#include <uhd/utils/pimpl.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
+#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/dboard_id.hpp>
#include <uhd/usrp/dboard_iface.hpp>
-#include <uhd/usrp/dboard_eeprom.hpp>
+#include <uhd/utils/pimpl.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
/*!
* A daughter board dboard_base class for all dboards.
* Only other dboard dboard_base classes should inherit this.
*/
-class UHD_API dboard_base : boost::noncopyable{
+class UHD_API dboard_base : boost::noncopyable
+{
public:
typedef boost::shared_ptr<dboard_base> sptr;
/*!
@@ -30,13 +31,13 @@ public:
* Derived classes should pass the args into the base class,
* but should not deal with the internals of the args.
*/
- typedef void * ctor_args_t;
+ typedef void* ctor_args_t;
- //structors
+ // structors
dboard_base(ctor_args_t);
virtual ~dboard_base() {}
- //post-construction initializer
+ // post-construction initializer
virtual void initialize() {}
protected:
@@ -57,7 +58,8 @@ private:
* A xcvr daughter board implements rx and tx methods
* Sub classes for xcvr boards should inherit this.
*/
-class UHD_API xcvr_dboard_base : public dboard_base{
+class UHD_API xcvr_dboard_base : public dboard_base
+{
public:
/*!
* Create a new xcvr dboard object, override in subclasses.
@@ -70,7 +72,8 @@ public:
* A rx daughter board only implements rx methods.
* Sub classes for rx-only boards should inherit this.
*/
-class UHD_API rx_dboard_base : public dboard_base{
+class UHD_API rx_dboard_base : public dboard_base
+{
public:
/*!
* Create a new rx dboard object, override in subclasses.
@@ -83,7 +86,8 @@ public:
* A tx daughter board only implements tx methods.
* Sub classes for rx-only boards should inherit this.
*/
-class UHD_API tx_dboard_base : public dboard_base{
+class UHD_API tx_dboard_base : public dboard_base
+{
public:
/*!
* Create a new rx dboard object, override in subclasses.
@@ -92,6 +96,6 @@ public:
virtual ~tx_dboard_base() {}
};
-}} //namespace
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_DBOARD_BASE_HPP */
diff --git a/host/include/uhd/usrp/dboard_eeprom.hpp b/host/include/uhd/usrp/dboard_eeprom.hpp
index 407d3f886..09d220bb3 100644
--- a/host/include/uhd/usrp/dboard_eeprom.hpp
+++ b/host/include/uhd/usrp/dboard_eeprom.hpp
@@ -9,14 +9,14 @@
#define INCLUDED_UHD_USRP_DBOARD_EEPROM_HPP
#include <uhd/config.hpp>
-#include <uhd/usrp/dboard_id.hpp>
#include <uhd/types/serial.hpp>
+#include <uhd/usrp/dboard_id.hpp>
#include <string>
-namespace uhd{ namespace usrp{
-
-struct UHD_API dboard_eeprom_t{
+namespace uhd { namespace usrp {
+struct UHD_API dboard_eeprom_t
+{
//! The ID for the daughterboard type
dboard_id_t id;
@@ -36,17 +36,16 @@ struct UHD_API dboard_eeprom_t{
* \param iface the serial interface with i2c
* \param addr the i2c address for the eeprom
*/
- void load(i2c_iface &iface, uint8_t addr);
+ void load(i2c_iface& iface, uint8_t addr);
/*!
* Store the object to bytes in the eeprom.
* \param iface the serial interface with i2c
* \param addr the i2c address for the eeprom
*/
- void store(i2c_iface &iface, uint8_t addr) const;
-
+ void store(i2c_iface& iface, uint8_t addr) const;
};
-}} //namespace
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_DBOARD_EEPROM_HPP */
diff --git a/host/include/uhd/usrp/dboard_id.hpp b/host/include/uhd/usrp/dboard_id.hpp
index 76c9c190b..2b48b0e46 100644
--- a/host/include/uhd/usrp/dboard_id.hpp
+++ b/host/include/uhd/usrp/dboard_id.hpp
@@ -13,74 +13,75 @@
#include <boost/operators.hpp>
#include <string>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
- class UHD_API dboard_id_t : boost::equality_comparable<dboard_id_t>{
- public:
- /*!
- * Create a dboard id from an integer.
- * \param id the integer representation
- */
- dboard_id_t(uint16_t id = 0xffff);
-
- /*!
- * Obtain a dboard id that represents no dboard.
- * \return the dboard id with the 0xffff id.
- */
- static dboard_id_t none(void);
-
- /*!
- * Create a new dboard id from an integer representation.
- * \param uint16 an unsigned 16 bit integer
- * \return a new dboard id containing the integer
- */
- static dboard_id_t from_uint16(uint16_t uint16);
+class UHD_API dboard_id_t : boost::equality_comparable<dboard_id_t>
+{
+public:
+ /*!
+ * Create a dboard id from an integer.
+ * \param id the integer representation
+ */
+ dboard_id_t(uint16_t id = 0xffff);
- /*!
- * Get the dboard id represented as an integer.
- * \return an unsigned 16 bit integer representation
- */
- uint16_t to_uint16(void) const;
+ /*!
+ * Obtain a dboard id that represents no dboard.
+ * \return the dboard id with the 0xffff id.
+ */
+ static dboard_id_t none(void);
- /*!
- * Create a new dboard id from a string representation.
- * If the string has a 0x prefix, it will be parsed as hex.
- * \param string a numeric string, possibly hex
- * \return a new dboard id containing the integer
- */
- static dboard_id_t from_string(const std::string &string);
+ /*!
+ * Create a new dboard id from an integer representation.
+ * \param uint16 an unsigned 16 bit integer
+ * \return a new dboard id containing the integer
+ */
+ static dboard_id_t from_uint16(uint16_t uint16);
- /*!
- * Get the dboard id represented as an integer.
- * \return a hex string representation with 0x prefix
- */
- std::string to_string(void) const;
+ /*!
+ * Get the dboard id represented as an integer.
+ * \return an unsigned 16 bit integer representation
+ */
+ uint16_t to_uint16(void) const;
- /*!
- * Get the dboard id represented as a canonical name.
- * \return the canonical string representation
- */
- std::string to_cname(void) const;
+ /*!
+ * Create a new dboard id from a string representation.
+ * If the string has a 0x prefix, it will be parsed as hex.
+ * \param string a numeric string, possibly hex
+ * \return a new dboard id containing the integer
+ */
+ static dboard_id_t from_string(const std::string& string);
- /*!
- * Get the pretty print representation of this dboard id.
- * \return a string with the dboard name and id number
- */
- std::string to_pp_string(void) const;
+ /*!
+ * Get the dboard id represented as an integer.
+ * \return a hex string representation with 0x prefix
+ */
+ std::string to_string(void) const;
- private:
- uint16_t _id; //internal representation
- };
+ /*!
+ * Get the dboard id represented as a canonical name.
+ * \return the canonical string representation
+ */
+ std::string to_cname(void) const;
/*!
- * Comparator operator overloaded for dboard ids.
- * The boost::equality_comparable provides the !=.
- * \param lhs the dboard id to the left of the operator
- * \param rhs the dboard id to the right of the operator
- * \return true when the dboard ids are equal
+ * Get the pretty print representation of this dboard id.
+ * \return a string with the dboard name and id number
*/
- UHD_API bool operator==(const dboard_id_t &lhs, const dboard_id_t &rhs);
+ std::string to_pp_string(void) const;
+
+private:
+ uint16_t _id; // internal representation
+};
+
+/*!
+ * Comparator operator overloaded for dboard ids.
+ * The boost::equality_comparable provides the !=.
+ * \param lhs the dboard id to the left of the operator
+ * \param rhs the dboard id to the right of the operator
+ * \return true when the dboard ids are equal
+ */
+UHD_API bool operator==(const dboard_id_t& lhs, const dboard_id_t& rhs);
-}} //namespace
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_DBOARD_ID_HPP */
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp
index 60b1954fc..162d0c6a3 100644
--- a/host/include/uhd/usrp/dboard_iface.hpp
+++ b/host/include/uhd/usrp/dboard_iface.hpp
@@ -9,21 +9,22 @@
#define INCLUDED_UHD_USRP_DBOARD_IFACE_HPP
#include <uhd/config.hpp>
-#include <uhd/utils/pimpl.hpp>
#include <uhd/types/serial.hpp>
#include <uhd/types/time_spec.hpp>
#include <uhd/usrp/fe_connection.hpp>
#include <uhd/usrp/gpio_defs.hpp>
-#include <boost/shared_ptr.hpp>
+#include <uhd/utils/pimpl.hpp>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <string>
#include <vector>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
//! Special properties that differentiate this daughterboard slot
-struct UHD_API dboard_iface_special_props_t{
+struct UHD_API dboard_iface_special_props_t
+{
/*!
* Soft clock divider:
* When a motherboard cannot provided a divided dboard clock,
@@ -49,20 +50,21 @@ struct UHD_API dboard_iface_special_props_t{
* This interface provides i2c, spi, gpio, atr, aux dac/adc access.
* Each mboard should have a specially tailored iface for its dboard.
*/
-class UHD_API dboard_iface : public uhd::i2c_iface{
+class UHD_API dboard_iface : public uhd::i2c_iface
+{
public:
typedef boost::shared_ptr<dboard_iface> sptr;
typedef dboard_iface_special_props_t special_props_t;
//! tells the host which unit to use
- enum unit_t{
+ enum unit_t {
UNIT_RX = int('r'),
UNIT_TX = int('t'),
UNIT_BOTH = int('b'),
};
//! aux dac selection enums (per unit)
- enum aux_dac_t{
+ enum aux_dac_t {
AUX_DAC_A = int('a'),
AUX_DAC_B = int('b'),
AUX_DAC_C = int('c'),
@@ -70,14 +72,11 @@ public:
};
//! aux adc selection enums (per unit)
- enum aux_adc_t{
- AUX_ADC_A = int('a'),
- AUX_ADC_B = int('b')
- };
+ enum aux_adc_t { AUX_ADC_A = int('a'), AUX_ADC_B = int('b') };
typedef uhd::usrp::gpio_atr::gpio_atr_reg_t atr_reg_t;
- virtual ~dboard_iface(void) {};
+ virtual ~dboard_iface(void){};
/*!
* Get special properties information for this dboard slot.
@@ -112,9 +111,7 @@ public:
* \param value 16-bits, 0=GPIO controlled, 1=ATR controlled
* \param mask 16-bits, 0=do not change, 1=change value
*/
- virtual void set_pin_ctrl(
- unit_t unit, uint32_t value, uint32_t mask = 0xffff
- ) = 0;
+ virtual void set_pin_ctrl(unit_t unit, uint32_t value, uint32_t mask = 0xffff) = 0;
/*!
* Read back the pin control setting.
@@ -133,8 +130,7 @@ public:
* \param mask 16-bits, 0=do not change, 1=change value
*/
virtual void set_atr_reg(
- unit_t unit, atr_reg_t reg, uint32_t value, uint32_t mask = 0xffff
- ) = 0;
+ unit_t unit, atr_reg_t reg, uint32_t value, uint32_t mask = 0xffff) = 0;
/*!
* Read back an ATR register setting.
@@ -152,9 +148,7 @@ public:
* \param value 16-bits, 0=GPIO input, 1=GPIO output
* \param mask 16-bits, 0=do not change, 1=change value
*/
- virtual void set_gpio_ddr(
- unit_t unit, uint32_t value, uint32_t mask = 0xffff
- ) = 0;
+ virtual void set_gpio_ddr(unit_t unit, uint32_t value, uint32_t mask = 0xffff) = 0;
/*!
* Read back the GPIO data direction setting.
@@ -171,9 +165,7 @@ public:
* \param value 16-bits, 0=GPIO output low, 1=GPIO output high
* \param mask 16-bits, 0=do not change, 1=change value
*/
- virtual void set_gpio_out(
- unit_t unit, uint32_t value, uint32_t mask = 0xffff
- ) = 0;
+ virtual void set_gpio_out(unit_t unit, uint32_t value, uint32_t mask = 0xffff) = 0;
/*!
* Read back the GPIO pin output setting.
@@ -200,11 +192,7 @@ public:
* \param num_bits the number of bits in data
*/
virtual void write_spi(
- unit_t unit,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
- ) = 0;
+ unit_t unit, const spi_config_t& config, uint32_t data, size_t num_bits) = 0;
/*!
* Read and write data to SPI bus peripheral.
@@ -216,11 +204,7 @@ public:
* \return the data that was read
*/
virtual uint32_t read_write_spi(
- unit_t unit,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
- ) = 0;
+ unit_t unit, const spi_config_t& config, uint32_t data, size_t num_bits) = 0;
/*!
* Set the rate of a dboard clock.
@@ -270,15 +254,16 @@ public:
* \param fe_name name of the front-end to update
* \param fe_conn connection parameters class
*/
- virtual void set_fe_connection(
- unit_t unit,
+ virtual void set_fe_connection(unit_t unit,
const std::string& fe_name,
- const uhd::usrp::fe_connection_t& fe_conn
- ) = 0;
+ const uhd::usrp::fe_connection_t& fe_conn) = 0;
/*! Returns the true if set_fe_connection() is implemented on this dboard_iface
*/
- virtual bool has_set_fe_connection(const unit_t) { return false; }
+ virtual bool has_set_fe_connection(const unit_t)
+ {
+ return false;
+ }
/*!
* Get the command time.
@@ -299,6 +284,6 @@ public:
virtual void sleep(const boost::chrono::nanoseconds& time);
};
-}} //namespace
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_DBOARD_IFACE_HPP */
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp
index 9b9384fa8..cda1127fb 100644
--- a/host/include/uhd/usrp/dboard_manager.hpp
+++ b/host/include/uhd/usrp/dboard_manager.hpp
@@ -10,62 +10,61 @@
#include <uhd/config.hpp>
#include <uhd/property_tree.hpp>
#include <uhd/usrp/dboard_base.hpp>
-#include <uhd/usrp/dboard_id.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
-#include <boost/utility.hpp>
+#include <uhd/usrp/dboard_id.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
#include <string>
#include <vector>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
/*!
* A daughter board subdev dboard_manager class.
* Create subdev instances for each subdev on a dboard.
* Provide wax::obj access to the subdevs inside.
*/
-class UHD_API dboard_manager : boost::noncopyable{
+class UHD_API dboard_manager : boost::noncopyable
+{
public:
typedef boost::shared_ptr<dboard_manager> sptr;
- //dboard constructor (each dboard should have a ::make with this signature)
- typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t);
+ // dboard constructor (each dboard should have a ::make with this signature)
+ typedef dboard_base::sptr (*dboard_ctor_t)(dboard_base::ctor_args_t);
/*!
* Register a rx or tx dboard into the system.
* For single subdevice boards, omit subdev_names.
* \param dboard_id the dboard id (rx or tx)
- * \param db_subdev_ctor the dboard sub-device constructor function pointer (one instance per subdev name)
- * \param name the canonical name for the dboard represented
+ * \param db_subdev_ctor the dboard sub-device constructor function pointer (one
+ * instance per subdev name) \param name the canonical name for the dboard represented
* \param subdev_names the names of the subdevs on this dboard
- * \param db_container_ctor the dboard container constructor function pointer (one instance per dboard)
+ * \param db_container_ctor the dboard container constructor function pointer (one
+ * instance per dboard)
*/
- static void register_dboard(
- const dboard_id_t &dboard_id,
+ static void register_dboard(const dboard_id_t& dboard_id,
dboard_ctor_t db_subdev_ctor,
- const std::string &name,
- const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0"),
- dboard_ctor_t db_container_ctor = NULL
- );
+ const std::string& name,
+ const std::vector<std::string>& subdev_names = std::vector<std::string>(1, "0"),
+ dboard_ctor_t db_container_ctor = NULL);
/*!
* Register an xcvr dboard into the system.
* For single subdevice boards, omit subdev_names.
* \param rx_dboard_id the rx unit dboard id
* \param tx_dboard_id the tx unit dboard id
- * \param db_subdev_ctor the dboard sub-device constructor function pointer (one instance per subdev name)
- * \param name the canonical name for the dboard represented
+ * \param db_subdev_ctor the dboard sub-device constructor function pointer (one
+ * instance per subdev name) \param name the canonical name for the dboard represented
* \param subdev_names the names of the subdevs on this dboard
- * \param db_container_ctor the dboard container constructor function pointer (one instance per dboard)
+ * \param db_container_ctor the dboard container constructor function pointer (one
+ * instance per dboard)
*/
- static void register_dboard(
- const dboard_id_t &rx_dboard_id,
- const dboard_id_t &tx_dboard_id,
+ static void register_dboard(const dboard_id_t& rx_dboard_id,
+ const dboard_id_t& tx_dboard_id,
dboard_ctor_t db_subdev_ctor,
- const std::string &name,
- const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0"),
- dboard_ctor_t db_container_ctor = NULL
- );
+ const std::string& name,
+ const std::vector<std::string>& subdev_names = std::vector<std::string>(1, "0"),
+ dboard_ctor_t db_container_ctor = NULL);
/*!
* Register a restricted rx or tx dboard into the system.
@@ -73,18 +72,17 @@ public:
* For single subdevice boards, omit subdev_names.
* The iface for a restricted board is not registered into the property tree.
* \param dboard_id the dboard id (rx or tx)
- * \param db_subdev_ctor the dboard sub-device constructor function pointer (one instance per subdev name)
- * \param name the canonical name for the dboard represented
+ * \param db_subdev_ctor the dboard sub-device constructor function pointer (one
+ * instance per subdev name) \param name the canonical name for the dboard represented
* \param subdev_names the names of the subdevs on this dboard
- * \param db_container_ctor the dboard container constructor function pointer (one instance per dboard)
+ * \param db_container_ctor the dboard container constructor function pointer (one
+ * instance per dboard)
*/
- static void register_dboard_restricted(
- const dboard_id_t &dboard_id,
+ static void register_dboard_restricted(const dboard_id_t& dboard_id,
dboard_ctor_t db_subdev_ctor,
- const std::string &name,
- const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0"),
- dboard_ctor_t db_container_ctor = NULL
- );
+ const std::string& name,
+ const std::vector<std::string>& subdev_names = std::vector<std::string>(1, "0"),
+ dboard_ctor_t db_container_ctor = NULL);
/*!
* Register a restricted xcvr dboard into the system.
@@ -93,19 +91,18 @@ public:
* The iface for a restricted board is not registered into the property tree.
* \param rx_dboard_id the rx unit dboard id
* \param tx_dboard_id the tx unit dboard id
- * \param db_subdev_ctor the dboard sub-device constructor function pointer (one instance per subdev name)
- * \param name the canonical name for the dboard represented
+ * \param db_subdev_ctor the dboard sub-device constructor function pointer (one
+ * instance per subdev name) \param name the canonical name for the dboard represented
* \param subdev_names the names of the subdevs on this dboard
- * \param db_container_ctor the dboard container constructor function pointer (one instance per dboard)
+ * \param db_container_ctor the dboard container constructor function pointer (one
+ * instance per dboard)
*/
- static void register_dboard_restricted(
- const dboard_id_t &rx_dboard_id,
- const dboard_id_t &tx_dboard_id,
+ static void register_dboard_restricted(const dboard_id_t& rx_dboard_id,
+ const dboard_id_t& tx_dboard_id,
dboard_ctor_t db_subdev_ctor,
- const std::string &name,
- const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0"),
- dboard_ctor_t db_container_ctor = NULL
- );
+ const std::string& name,
+ const std::vector<std::string>& subdev_names = std::vector<std::string>(1, "0"),
+ dboard_ctor_t db_container_ctor = NULL);
/*!
* Make a new dboard manager.
@@ -117,14 +114,12 @@ public:
* \param defer_db_init initialising the daughterboards (DEPRECATED)
* \return an sptr to the new dboard manager
*/
- static sptr make(
- dboard_id_t rx_dboard_id,
+ static sptr make(dboard_id_t rx_dboard_id,
dboard_id_t tx_dboard_id,
dboard_id_t gdboard_id,
dboard_iface::sptr iface,
property_tree::sptr subtree,
- bool defer_db_init = false
- );
+ bool defer_db_init = false);
/*!
* Make a new dboard manager.
@@ -136,14 +131,12 @@ public:
* \param defer_db_init initialising the daughterboards (DEPRECATED)
* \return an sptr to the new dboard manager
*/
- static sptr make(
- dboard_eeprom_t rx_eeprom,
+ static sptr make(dboard_eeprom_t rx_eeprom,
dboard_eeprom_t tx_eeprom,
dboard_eeprom_t gdb_eeprom,
dboard_iface::sptr iface,
property_tree::sptr subtree,
- bool defer_db_init = false
- );
+ bool defer_db_init = false);
virtual ~dboard_manager() {}
@@ -165,6 +158,6 @@ public:
virtual const std::vector<std::string>& get_tx_frontends() const = 0;
};
-}} //namespace
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP */
diff --git a/host/include/uhd/usrp/fe_connection.hpp b/host/include/uhd/usrp/fe_connection.hpp
index d2050bb0f..0b34af40d 100644
--- a/host/include/uhd/usrp/fe_connection.hpp
+++ b/host/include/uhd/usrp/fe_connection.hpp
@@ -14,104 +14,114 @@
namespace uhd { namespace usrp {
- class UHD_API fe_connection_t : boost::equality_comparable<fe_connection_t> {
- public:
- /** Sampling mode.
- * Represents the sampling architecture for the front-end
- */
- enum sampling_t {
- QUADRATURE, /**< Complex sampling (Complex input, Complex output). */
- HETERODYNE, /**< Heterodyne sampling (Real input, Complex output). Only one of the I and Q inputs is used. */
- REAL /**< Real sampling (Real input, Real output). Only one of the I and Q inputs is used. */
- };
-
- /*!
- * Create a frontend connection class from individual settings.
- * \param sampling_mode can be { QUADRATURE, HETERODYNE, REAL }
- * \param iq_swapped indicates if the IQ channels are swapped (after inverion and heterodyne correction)
- * \param i_inverted indicates if the I channel is inverted (negated)
- * \param q_inverted indicates if the Q channel is inverted (negated)
- * \param if_freq the baseband sampling frequency.
- */
- fe_connection_t(
- sampling_t sampling_mode, bool iq_swapped,
- bool i_inverted, bool q_inverted, double if_freq = 0.0
- );
-
- /*!
- * Create a frontend connection class from a connection string
- * The connection string can be:
- * - in {I, Q}: Real mode sampling with no inversion.
- * - in {Ib, Qb}: Real mode sampling with inversion.
- * - in {IQ, QI}: Quadrature sampling with no inversion.
- * - in {IbQb, QbIb}: Quadrature sampling with inversion.
- * - in {II, QQ}: Heterodyne sampling with no inversion.
- * - in {IbIb, QbQb}: Heterodyne sampling with inversion.
- *
- * \param conn_str the connection string.
- * \param if_freq the baseband sampling frequency.
- */
- fe_connection_t(const std::string& conn_str, double if_freq = 0.0);
-
- /*!
- * Accessor for sampling mode
- */
- inline sampling_t get_sampling_mode() const {
- return _sampling_mode;
- }
-
- /*!
- * Accessor for IQ swap parameter
- */
- inline bool is_iq_swapped() const {
- return _iq_swapped;
- }
-
- /*!
- * Accessor for I inversion parameter
- */
- inline bool is_i_inverted() const {
- return _i_inverted;
- }
-
- /*!
- * Accessor for Q inversion parameter
- */
- inline bool is_q_inverted() const {
- return _q_inverted;
- }
-
- /*!
- * Accessor for IF frequency
- */
- inline double get_if_freq() const {
- return _if_freq;
- }
-
- /*!
- * Mutator for IF frequency
- */
- inline void set_if_freq(double freq) {
- _if_freq = freq;
- }
-
- private:
- sampling_t _sampling_mode;
- bool _iq_swapped;
- bool _i_inverted;
- bool _q_inverted;
- double _if_freq;
+class UHD_API fe_connection_t : boost::equality_comparable<fe_connection_t>
+{
+public:
+ /** Sampling mode.
+ * Represents the sampling architecture for the front-end
+ */
+ enum sampling_t {
+ QUADRATURE, /**< Complex sampling (Complex input, Complex output). */
+ HETERODYNE, /**< Heterodyne sampling (Real input, Complex output). Only one of the
+ I and Q inputs is used. */
+ REAL /**< Real sampling (Real input, Real output). Only one of the I and Q inputs
+ is used. */
};
/*!
- * Comparator operator overloaded for fe_connection_t.
- * The boost::equality_comparable provides the !=.
- * \param lhs the fe_connection_t to the left of the operator
- * \param rhs the fe_connection_t to the right of the operator
- * \return true when the fe connections are equal
+ * Create a frontend connection class from individual settings.
+ * \param sampling_mode can be { QUADRATURE, HETERODYNE, REAL }
+ * \param iq_swapped indicates if the IQ channels are swapped (after inverion and
+ * heterodyne correction) \param i_inverted indicates if the I channel is inverted
+ * (negated) \param q_inverted indicates if the Q channel is inverted (negated) \param
+ * if_freq the baseband sampling frequency.
+ */
+ fe_connection_t(sampling_t sampling_mode,
+ bool iq_swapped,
+ bool i_inverted,
+ bool q_inverted,
+ double if_freq = 0.0);
+
+ /*!
+ * Create a frontend connection class from a connection string
+ * The connection string can be:
+ * - in {I, Q}: Real mode sampling with no inversion.
+ * - in {Ib, Qb}: Real mode sampling with inversion.
+ * - in {IQ, QI}: Quadrature sampling with no inversion.
+ * - in {IbQb, QbIb}: Quadrature sampling with inversion.
+ * - in {II, QQ}: Heterodyne sampling with no inversion.
+ * - in {IbIb, QbQb}: Heterodyne sampling with inversion.
+ *
+ * \param conn_str the connection string.
+ * \param if_freq the baseband sampling frequency.
*/
- UHD_API bool operator==(const fe_connection_t &lhs, const fe_connection_t &rhs);
+ fe_connection_t(const std::string& conn_str, double if_freq = 0.0);
-}} //namespace
+ /*!
+ * Accessor for sampling mode
+ */
+ inline sampling_t get_sampling_mode() const
+ {
+ return _sampling_mode;
+ }
+
+ /*!
+ * Accessor for IQ swap parameter
+ */
+ inline bool is_iq_swapped() const
+ {
+ return _iq_swapped;
+ }
+
+ /*!
+ * Accessor for I inversion parameter
+ */
+ inline bool is_i_inverted() const
+ {
+ return _i_inverted;
+ }
+
+ /*!
+ * Accessor for Q inversion parameter
+ */
+ inline bool is_q_inverted() const
+ {
+ return _q_inverted;
+ }
+
+ /*!
+ * Accessor for IF frequency
+ */
+ inline double get_if_freq() const
+ {
+ return _if_freq;
+ }
+
+ /*!
+ * Mutator for IF frequency
+ */
+ inline void set_if_freq(double freq)
+ {
+ _if_freq = freq;
+ }
+
+private:
+ sampling_t _sampling_mode;
+ bool _iq_swapped;
+ bool _i_inverted;
+ bool _q_inverted;
+ double _if_freq;
+};
+
+/*!
+ * Comparator operator overloaded for fe_connection_t.
+ * The boost::equality_comparable provides the !=.
+ * \param lhs the fe_connection_t to the left of the operator
+ * \param rhs the fe_connection_t to the right of the operator
+ * \return true when the fe connections are equal
+ */
+UHD_API bool operator==(const fe_connection_t& lhs, const fe_connection_t& rhs);
+
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_FE_CONNECTION_HPP */
diff --git a/host/include/uhd/usrp/gpio_defs.hpp b/host/include/uhd/usrp/gpio_defs.hpp
index 65d6a761e..5cf09b496 100644
--- a/host/include/uhd/usrp/gpio_defs.hpp
+++ b/host/include/uhd/usrp/gpio_defs.hpp
@@ -10,13 +10,13 @@
namespace uhd { namespace usrp { namespace gpio_atr {
- enum gpio_atr_reg_t {
- ATR_REG_IDLE = int('i'),
- ATR_REG_TX_ONLY = int('t'),
- ATR_REG_RX_ONLY = int('r'),
- ATR_REG_FULL_DUPLEX = int('f')
- };
+enum gpio_atr_reg_t {
+ ATR_REG_IDLE = int('i'),
+ ATR_REG_TX_ONLY = int('t'),
+ ATR_REG_RX_ONLY = int('r'),
+ ATR_REG_FULL_DUPLEX = int('f')
+};
-}}} //namespaces
+}}} // namespace uhd::usrp::gpio_atr
#endif /* INCLUDED_LIBUHD_USRP_GPIO_DEFS_HPP */
diff --git a/host/include/uhd/usrp/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp
index 1e0d35b91..91d653759 100644
--- a/host/include/uhd/usrp/gps_ctrl.hpp
+++ b/host/include/uhd/usrp/gps_ctrl.hpp
@@ -8,46 +8,46 @@
#ifndef INCLUDED_GPS_CTRL_HPP
#define INCLUDED_GPS_CTRL_HPP
-#include <uhd/types/serial.hpp>
#include <uhd/types/sensors.hpp>
+#include <uhd/types/serial.hpp>
+#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-#include <boost/function.hpp>
#include <vector>
-namespace uhd{
+namespace uhd {
-class UHD_API gps_ctrl : boost::noncopyable{
+class UHD_API gps_ctrl : boost::noncopyable
+{
public:
- typedef boost::shared_ptr<gps_ctrl> sptr;
-
- virtual ~gps_ctrl(void) = 0;
+ typedef boost::shared_ptr<gps_ctrl> sptr;
- /*!
- * Make a GPS config for internal GPSDOs or generic NMEA GPS devices
- */
- static sptr make(uart_iface::sptr uart);
+ virtual ~gps_ctrl(void) = 0;
- /*!
- * Retrieve the list of sensors this GPS object provides
- */
- virtual std::vector<std::string> get_sensors(void) = 0;
+ /*!
+ * Make a GPS config for internal GPSDOs or generic NMEA GPS devices
+ */
+ static sptr make(uart_iface::sptr uart);
- /*!
- * Retrieve the named sensor
- */
- virtual uhd::sensor_value_t get_sensor(std::string key) = 0;
+ /*!
+ * Retrieve the list of sensors this GPS object provides
+ */
+ virtual std::vector<std::string> get_sensors(void) = 0;
- /*!
- * Tell you if there's a supported GPS connected or not
- * \return true if a supported GPS is connected
- */
- virtual bool gps_detected(void) = 0;
+ /*!
+ * Retrieve the named sensor
+ */
+ virtual uhd::sensor_value_t get_sensor(std::string key) = 0;
- //TODO: other fun things you can do with a GPS.
+ /*!
+ * Tell you if there's a supported GPS connected or not
+ * \return true if a supported GPS is connected
+ */
+ virtual bool gps_detected(void) = 0;
+ // TODO: other fun things you can do with a GPS.
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_GPS_CTRL_HPP */
diff --git a/host/include/uhd/usrp/mboard_eeprom.hpp b/host/include/uhd/usrp/mboard_eeprom.hpp
index 72efd7c99..fcc587e08 100644
--- a/host/include/uhd/usrp/mboard_eeprom.hpp
+++ b/host/include/uhd/usrp/mboard_eeprom.hpp
@@ -12,20 +12,20 @@
#include <uhd/types/dict.hpp>
#include <string>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
- /*! The motherboard EEPROM object.
- *
- * The specific implementation knows how to read and write the EEPROM for
- * various USRPs. By itself, this class is nothing but a thin wrapper
- * around a string -> string dictionary.
- *
- * Note that writing to an object of type mboard_eeprom_t does not actually
- * write to the EEPROM. Devices have their own APIs to read/write from the
- * EEPROM chips themselves. Most devices will write the EEPROM itself when
- * the according property is updated.
- */
- typedef uhd::dict<std::string, std::string> mboard_eeprom_t;
+/*! The motherboard EEPROM object.
+ *
+ * The specific implementation knows how to read and write the EEPROM for
+ * various USRPs. By itself, this class is nothing but a thin wrapper
+ * around a string -> string dictionary.
+ *
+ * Note that writing to an object of type mboard_eeprom_t does not actually
+ * write to the EEPROM. Devices have their own APIs to read/write from the
+ * EEPROM chips themselves. Most devices will write the EEPROM itself when
+ * the according property is updated.
+ */
+typedef uhd::dict<std::string, std::string> mboard_eeprom_t;
}} // namespace uhd::usrp
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 71b2a1161..a99cba845 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -8,7 +8,7 @@
#ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
#define INCLUDED_UHD_USRP_MULTI_USRP_HPP
-//define API capabilities for compile time detection of new features
+// define API capabilities for compile time detection of new features
#define UHD_USRP_MULTI_USRP_REF_SOURCES_API
#define UHD_USRP_MULTI_USRP_GET_RATES_API
#define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
@@ -25,17 +25,17 @@
#define UHD_USRP_MULTI_USRP_TX_LO_CONFIG_API
#include <uhd/config.hpp>
-#include <uhd/device.hpp>
#include <uhd/deprecated.hpp>
+#include <uhd/device.hpp>
+#include <uhd/types/filters.hpp>
#include <uhd/types/ranges.hpp>
+#include <uhd/types/sensors.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/tune_request.hpp>
#include <uhd/types/tune_result.hpp>
-#include <uhd/types/sensors.hpp>
-#include <uhd/types/filters.hpp>
#include <uhd/types/wb_iface.hpp>
-#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/usrp/dboard_iface.hpp>
+#include <uhd/usrp/subdev_spec.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <complex>
@@ -43,9 +43,9 @@
#include <vector>
namespace uhd {
- class device3;
+class device3;
- namespace usrp{
+namespace usrp {
/*!
* The Multi-USRP device class:
@@ -93,7 +93,8 @@ namespace uhd {
*
* </pre>
*/
-class UHD_API multi_usrp : boost::noncopyable{
+class UHD_API multi_usrp : boost::noncopyable
+{
public:
typedef boost::shared_ptr<multi_usrp> sptr;
@@ -118,7 +119,7 @@ public:
* \throws uhd::key_error no device found
* \throws uhd::index_error fewer devices found than expected
*/
- static sptr make(const device_addr_t &dev_addr);
+ static sptr make(const device_addr_t& dev_addr);
/*!
* Get the underlying device object.
@@ -142,10 +143,10 @@ public:
virtual boost::shared_ptr<uhd::device3> get_device3(void) = 0;
//! Convenience method to get a RX streamer. See also uhd::device::get_rx_stream().
- virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
+ virtual rx_streamer::sptr get_rx_stream(const stream_args_t& args) = 0;
//! Convenience method to get a TX streamer. See also uhd::device::get_tx_stream().
- virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
+ virtual tx_streamer::sptr get_tx_stream(const stream_args_t& args) = 0;
/*!
* Returns identifying information about this USRP's configuration.
@@ -163,7 +164,7 @@ public:
* \param chan channel index 0 to N-1
* \return TX info
*/
- virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
+ virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
/*******************************************************************
* Mboard methods
@@ -258,7 +259,8 @@ public:
* \param time_spec the time to latch into the usrp device
* \param mboard the motherboard index 0 to M-1
*/
- virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_time_now(
+ const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
/*!
* Set the time registers on the usrp at the next pps tick.
@@ -272,7 +274,8 @@ public:
* \param time_spec the time to latch into the usrp device
* \param mboard the motherboard index 0 to M-1
*/
- virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_time_next_pps(
+ const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
/*!
* Synchronize the times across all motherboards in this configuration.
@@ -289,7 +292,7 @@ public:
*
* \param time_spec the time to latch at the next pps after catching the edge
*/
- virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
+ virtual void set_time_unknown_pps(const time_spec_t& time_spec) = 0;
/*!
* Are the times across all motherboards in this configuration synchronized?
@@ -309,7 +312,8 @@ public:
* \param time_spec the time at which the next command will activate
* \param mboard which motherboard to set the config
*/
- virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_command_time(
+ const uhd::time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
/*!
* Clear the command time so future commands are sent ASAP.
@@ -330,7 +334,8 @@ public:
* \param stream_cmd the stream command to issue
* \param chan the channel index 0 to N-1
*/
- virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
+ virtual void issue_stream_cmd(
+ const stream_cmd_t& stream_cmd, size_t chan = ALL_CHANS) = 0;
/*!
* Set the clock configuration for the usrp device.
@@ -340,7 +345,8 @@ public:
* \param clock_config the clock configuration to set
* \param mboard which motherboard to set the config
*/
- virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_clock_config(
+ const clock_config_t& clock_config, size_t mboard = ALL_MBOARDS) = 0;
/*! Set the time source for the USRP device
*
@@ -385,9 +391,7 @@ public:
* \throws uhd::value_error if \p source is an invalid option
*/
virtual void set_time_source(
- const std::string &source,
- const size_t mboard = ALL_MBOARDS
- ) = 0;
+ const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
/*!
* Get the currently set time source.
@@ -446,9 +450,7 @@ public:
* \throws uhd::value_error if \p source is an invalid option
*/
virtual void set_clock_source(
- const std::string &source,
- const size_t mboard = ALL_MBOARDS
- ) = 0;
+ const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
/*!
* Get the currently set clock source.
@@ -474,11 +476,9 @@ public:
* \param mboard which motherboard to set the config
* \throws uhd::value_error if the sources don't actually exist
*/
- virtual void set_sync_source(
- const std::string &clock_source,
- const std::string &time_source,
- const size_t mboard = ALL_MBOARDS
- ) = 0;
+ virtual void set_sync_source(const std::string& clock_source,
+ const std::string& time_source,
+ const size_t mboard = ALL_MBOARDS) = 0;
/*! Set the reference/synchronization sources for the USRP device
*
@@ -503,9 +503,7 @@ public:
* combination of clock and time source is invalid.
*/
virtual void set_sync_source(
- const device_addr_t& sync_source,
- const size_t mboard = ALL_MBOARDS
- ) = 0;
+ const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS) = 0;
/*! Get the currently set sync source.
*
@@ -529,7 +527,8 @@ public:
* \param enb true to output the clock source.
* \param mboard which motherboard to set
*/
- virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_clock_source_out(
+ const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
/*!
* Send the time source to an output connector.
@@ -539,7 +538,8 @@ public:
* \param enb true to output the time source.
* \param mboard which motherboard to set
*/
- virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_time_source_out(
+ const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
/*!
* Get the number of USRP motherboards in this configuration.
@@ -552,7 +552,8 @@ public:
* \param mboard the motherboard index 0 to M-1
* \return a sensor value object
*/
- virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
+ virtual sensor_value_t get_mboard_sensor(
+ const std::string& name, size_t mboard = 0) = 0;
/*!
* Get a list of possible motherboard sensor names.
@@ -568,7 +569,8 @@ public:
* \param data 32-bit register value
* \param mboard which motherboard to set the user register
*/
- virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_user_register(
+ const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
/*! Return a user settings interface object
*
@@ -607,7 +609,8 @@ public:
* \param spec the new frontend specification
* \param mboard the motherboard index 0 to M-1
*/
- virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_rx_subdev_spec(
+ const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
/*!
* Get the RX frontend specification.
@@ -658,8 +661,7 @@ public:
* \return a tune result object
*/
virtual tune_result_t set_rx_freq(
- const tune_request_t &tune_request, size_t chan = 0
- ) = 0;
+ const tune_request_t& tune_request, size_t chan = 0) = 0;
/*!
* Get the RX center frequency.
@@ -716,10 +718,7 @@ public:
* \param chan the channel index 0 to N-1
*/
virtual void set_rx_lo_source(
- const std::string &src,
- const std::string &name = ALL_LOS,
- size_t chan = 0
- ) = 0;
+ const std::string& src, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
/*! Get the currently selected LO source.
*
@@ -730,9 +729,7 @@ public:
* \return the configured LO source
*/
virtual const std::string get_rx_lo_source(
- const std::string &name = ALL_LOS,
- size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, size_t chan = 0) = 0;
/*! Get a list of possible LO sources.
*
@@ -746,9 +743,7 @@ public:
* \return a vector of strings for possible settings
*/
virtual std::vector<std::string> get_rx_lo_sources(
- const std::string &name = ALL_LOS,
- size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, size_t chan = 0) = 0;
/*! Set whether the LO used by the device is exported
*
@@ -761,10 +756,7 @@ public:
* \throws uhd::runtime_error if LO exporting is not enabled
*/
virtual void set_rx_lo_export_enabled(
- bool enabled,
- const std::string &name = ALL_LOS,
- size_t chan = 0
- ) = 0;
+ bool enabled, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
/*! Returns true if the currently selected LO is being exported.
*
@@ -772,9 +764,7 @@ public:
* \param chan the channel index 0 to N-1
*/
virtual bool get_rx_lo_export_enabled(
- const std::string &name = ALL_LOS,
- size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, size_t chan = 0) = 0;
/*! Set the RX LO frequency (Advanced).
*
@@ -800,10 +790,7 @@ public:
* \return a coerced LO frequency
*/
virtual double set_rx_lo_freq(
- double freq,
- const std::string &name,
- size_t chan = 0
- ) = 0;
+ double freq, const std::string& name, size_t chan = 0) = 0;
/*! Get the current RX LO frequency (Advanced).
*
@@ -815,10 +802,7 @@ public:
* \param chan the channel index 0 to N-1
* \return the configured LO frequency
*/
- virtual double get_rx_lo_freq(
- const std::string &name,
- size_t chan = 0
- ) = 0;
+ virtual double get_rx_lo_freq(const std::string& name, size_t chan = 0) = 0;
/*! Get the LO frequency range of the RX LO.
*
@@ -830,9 +814,7 @@ public:
* \return a frequency range object
*/
virtual freq_range_t get_rx_lo_freq_range(
- const std::string &name,
- size_t chan = 0
- ) = 0;
+ const std::string& name, size_t chan = 0) = 0;
/*! Get a list of possible TX LO stage names
*
@@ -859,11 +841,9 @@ public:
* this channel.
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_lo_source(
- const std::string &src,
- const std::string &name = ALL_LOS,
- const size_t chan = 0
- ) = 0;
+ virtual void set_tx_lo_source(const std::string& src,
+ const std::string& name = ALL_LOS,
+ const size_t chan = 0) = 0;
/*! Get the currently selected TX LO source.
*
@@ -874,9 +854,7 @@ public:
* \return the configured LO source
*/
virtual const std::string get_tx_lo_source(
- const std::string &name = ALL_LOS,
- const size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
/*! Get a list of possible LO sources.
*
@@ -889,9 +867,7 @@ public:
* \return a vector of strings for possible settings
*/
virtual std::vector<std::string> get_tx_lo_sources(
- const std::string &name = ALL_LOS,
- const size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
/*! Set whether the TX LO used by the device is exported
*
@@ -904,10 +880,7 @@ public:
* \throws uhd::runtime_error if LO exporting is not enabled
*/
virtual void set_tx_lo_export_enabled(
- const bool enabled,
- const std::string &name = ALL_LOS,
- const size_t chan = 0
- ) = 0;
+ const bool enabled, const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
/*! Returns true if the currently selected LO is being exported.
*
@@ -915,9 +888,7 @@ public:
* \param chan the channel index 0 to N-1
*/
virtual bool get_tx_lo_export_enabled(
- const std::string &name = ALL_LOS,
- const size_t chan = 0
- ) = 0;
+ const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
/*! Set the TX LO frequency (Advanced).
*
@@ -943,10 +914,7 @@ public:
* \return a coerced LO frequency
*/
virtual double set_tx_lo_freq(
- const double freq,
- const std::string &name,
- const size_t chan=0
- ) = 0;
+ const double freq, const std::string& name, const size_t chan = 0) = 0;
/*! Get the current TX LO frequency (Advanced).
*
@@ -958,10 +926,7 @@ public:
* \param chan the channel index 0 to N-1
* \return the configured LO frequency
*/
- virtual double get_tx_lo_freq(
- const std::string &name,
- const size_t chan=0
- ) = 0;
+ virtual double get_tx_lo_freq(const std::string& name, const size_t chan = 0) = 0;
/*! Get the LO frequency range of the TX LO.
*
@@ -973,9 +938,7 @@ public:
* \return a frequency range object
*/
virtual freq_range_t get_tx_lo_freq_range(
- const std::string &name,
- const size_t chan=0
- ) = 0;
+ const std::string& name, const size_t chan = 0) = 0;
/**************************************************************************
* Gain controls
@@ -987,15 +950,15 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
+ virtual void set_rx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
/*! Get a list of possible RX gain profile options
*
- * Example: On the TwinRX, this will return "low-noise", "low-distortion" or "default".
- * These names can be used in gain-profile related API called.
- * An empty return value doesn't mean there are no profile options, it means that
- * this radio does not have any gain profiles implemented, and typically means
- * there is only one default profile of set gain
+ * Example: On the TwinRX, this will return "low-noise", "low-distortion" or
+ * "default". These names can be used in gain-profile related API called. An empty
+ * return value doesn't mean there are no profile options, it means that this radio
+ * does not have any gain profiles implemented, and typically means there is only one
+ * default profile of set gain
*
* \param chan the channel index 0 to N-1
* \return a vector of strings for possible gain profile options, or an empty list of
@@ -1008,7 +971,8 @@ public:
* \param profile the profile string option
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
+ virtual void set_rx_gain_profile(
+ const std::string& profile, const size_t chan = 0) = 0;
/*!
* Get the RX gain profile.
@@ -1018,7 +982,8 @@ public:
virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
//! A convenience wrapper for setting overall RX gain
- void set_rx_gain(double gain, size_t chan = 0){
+ void set_rx_gain(double gain, size_t chan = 0)
+ {
return this->set_rx_gain(gain, ALL_GAINS, chan);
}
@@ -1043,8 +1008,8 @@ public:
/*!
* Enable or disable the RX AGC module.
* Once this module is enabled manual gain settings will be ignored.
- * The AGC will start in a default configuration which should be good for most use cases.
- * Device specific configuration parameters can be found in the property tree.
+ * The AGC will start in a default configuration which should be good for most use
+ * cases. Device specific configuration parameters can be found in the property tree.
* \param enable Enable or Disable the AGC
* \param chan the channel index 0 to N-1
*/
@@ -1057,10 +1022,11 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
+ virtual double get_rx_gain(const std::string& name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall RX gain
- double get_rx_gain(size_t chan = 0){
+ double get_rx_gain(size_t chan = 0)
+ {
return this->get_rx_gain(ALL_GAINS, chan);
}
@@ -1083,10 +1049,11 @@ public:
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
+ virtual gain_range_t get_rx_gain_range(const std::string& name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall RX gain range
- gain_range_t get_rx_gain_range(size_t chan = 0){
+ gain_range_t get_rx_gain_range(size_t chan = 0)
+ {
return this->get_rx_gain_range(ALL_GAINS, chan);
}
@@ -1103,7 +1070,7 @@ public:
* \param ant the antenna name
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
+ virtual void set_rx_antenna(const std::string& ant, size_t chan = 0) = 0;
/*!
* Get the selected RX antenna on the frontend.
@@ -1155,7 +1122,7 @@ public:
* \param chan the channel index 0 to N-1
* \return a sensor value object
*/
- virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
+ virtual sensor_value_t get_rx_sensor(const std::string& name, size_t chan = 0) = 0;
/*!
* Get a list of possible RX frontend sensor names.
@@ -1185,7 +1152,8 @@ public:
* \param offset the dc offset (1.0 is full-scale)
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
+ virtual void set_rx_dc_offset(
+ const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
/*!
* Get the valid range for RX DC offset values.
@@ -1208,7 +1176,8 @@ public:
* \param correction the complex correction (1.0 is full-scale)
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
+ virtual void set_rx_iq_balance(
+ const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
/*******************************************************************
* TX methods
@@ -1221,7 +1190,8 @@ public:
* \param spec the new frontend specification
* \param mboard the motherboard index 0 to M-1
*/
- virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
+ virtual void set_tx_subdev_spec(
+ const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
/*!
* Get the TX frontend specification.
@@ -1272,8 +1242,7 @@ public:
* \return a tune result object
*/
virtual tune_result_t set_tx_freq(
- const tune_request_t &tune_request, size_t chan = 0
- ) = 0;
+ const tune_request_t& tune_request, size_t chan = 0) = 0;
/*!
* Get the TX center frequency.
@@ -1307,7 +1276,7 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
+ virtual void set_tx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
/*! Get a list of possible TX gain profile options
*
@@ -1328,7 +1297,8 @@ public:
* \param profile the profile string option
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
+ virtual void set_tx_gain_profile(
+ const std::string& profile, const size_t chan = 0) = 0;
/*!
* Get the TX gain profile.
@@ -1338,7 +1308,8 @@ public:
virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
//! A convenience wrapper for setting overall TX gain
- void set_tx_gain(double gain, size_t chan = 0){
+ void set_tx_gain(double gain, size_t chan = 0)
+ {
return this->set_tx_gain(gain, ALL_GAINS, chan);
}
@@ -1361,10 +1332,11 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
+ virtual double get_tx_gain(const std::string& name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall TX gain
- double get_tx_gain(size_t chan = 0){
+ double get_tx_gain(size_t chan = 0)
+ {
return this->get_tx_gain(ALL_GAINS, chan);
}
@@ -1387,10 +1359,11 @@ public:
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
+ virtual gain_range_t get_tx_gain_range(const std::string& name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall TX gain range
- gain_range_t get_tx_gain_range(size_t chan = 0){
+ gain_range_t get_tx_gain_range(size_t chan = 0)
+ {
return this->get_tx_gain_range(ALL_GAINS, chan);
}
@@ -1407,7 +1380,7 @@ public:
* \param ant the antenna name
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
+ virtual void set_tx_antenna(const std::string& ant, size_t chan = 0) = 0;
/*!
* Get the selected TX antenna on the frontend.
@@ -1459,7 +1432,7 @@ public:
* \param chan the channel index 0 to N-1
* \return a sensor value object
*/
- virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
+ virtual sensor_value_t get_tx_sensor(const std::string& name, size_t chan = 0) = 0;
/*!
* Get a list of possible TX frontend sensor names.
@@ -1474,7 +1447,8 @@ public:
* \param offset the dc offset (1.0 is full-scale)
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
+ virtual void set_tx_dc_offset(
+ const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
/*!
* Get the valid range for TX DC offset values.
@@ -1489,7 +1463,8 @@ public:
* \param correction the complex correction (1.0 is full-scale)
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
+ virtual void set_tx_iq_balance(
+ const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
/*******************************************************************
* GPIO methods
@@ -1518,13 +1493,18 @@ public:
* \param mask the bit mask to effect which pins are changed
* \param mboard the motherboard index 0 to M-1
*/
- virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const uint32_t value, const uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
+ virtual void set_gpio_attr(const std::string& bank,
+ const std::string& attr,
+ const uint32_t value,
+ const uint32_t mask = 0xffffffff,
+ const size_t mboard = 0) = 0;
/*!
* Set a GPIO attribute on a particular GPIO bank.
* Possible attribute names:
* - SRC - "PS" for handling by processing system
- * - "RADIO_N/M" for handling by radio block with N is in [0..Number of Radio]; M is in [0..Number of port per Radio]
+ * - "RADIO_N/M" for handling by radio block with N is in [0..Number of
+ * Radio]; M is in [0..Number of port per Radio]
* - CTRL - "ATR" for ATR mode
* - "GPIO" for GPIO mode
* - DDR - "OUT" for output
@@ -1532,20 +1512,28 @@ public:
* - OUT - a string of numbers representing GPIO output level (not ATR mode)
* - "HIGH"or "LOW" as GPIO output level that apply for each bit mask that is 1
* - ATR_0X - a string of numbers representing a value of the ATR idle state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR idle state register
- * - ATR_RX - a string of numbers representing a value of a ATR receive only state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR receive only state register
- * - ATR_TX - a string of numbers representing a value of the ATR transmit only state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR transmit only state register
- * - ATR_XX - a string of numbers representing a value of the ATR full duplex state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR full duplex state register
- * \param bank the name of a GPIO bank
- * \param attr the name of a GPIO attribute
- * \param value the new value for this GPIO bank
- * \param mask the bit mask to effect which pins are changed
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const std::string &value, const uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR idle state
+ * register
+ * - ATR_RX - a string of numbers representing a value of a ATR receive only state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR receive only
+ * state register
+ * - ATR_TX - a string of numbers representing a value of the ATR transmit only state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR transmit only
+ * state register
+ * - ATR_XX - a string of numbers representing a value of the ATR full duplex state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR full duplex
+ * state register \param bank the name of a GPIO bank \param attr the name of a GPIO
+ * attribute \param value the new value for this GPIO bank \param mask the bit mask to
+ * effect which pins are changed \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_gpio_attr(const std::string& bank,
+ const std::string& attr,
+ const std::string& value,
+ const uint32_t mask = 0xffffffff,
+ const size_t mboard = 0) = 0;
/*!
* Get a GPIO attribute on a particular GPIO bank.
@@ -1563,13 +1551,15 @@ public:
* \param mboard the motherboard index 0 to M-1
* \return the value set for this attribute
*/
- virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
+ virtual uint32_t get_gpio_attr(
+ const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
/*!
* Get a GPIO attribute on a particular GPIO bank.
* Possible attribute names:
* - SRC - "PS" for handling by processing system
- * - "RADIO_N/M" for handling by radio block with N is in [0..Number of Radio]; M is in [0..Number of port per Radio]
+ * - "RADIO_N/M" for handling by radio block with N is in [0..Number of
+ * Radio]; M is in [0..Number of port per Radio]
* - CTRL - "ATR" for ATR mode
* - "GPIO" for GPIO mode
* - DDR - "OUT" for output
@@ -1577,25 +1567,34 @@ public:
* - OUT - a string of numbers representing GPIO output level (not ATR mode)
* - "HIGH"or "LOW" as GPIO output level that apply for each bit mask that is 1
* - ATR_0X - a string of numbers representing a value of the ATR idle state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR idle state register
- * - ATR_RX - a string of numbers representing a value of a ATR receive only state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR receive only state register
- * - ATR_TX - a string of numbers representing a value of the ATR transmit only state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR transmit only state register
- * - ATR_XX - a string of numbers representing a value of the ATR full duplex state register
- * - "HIGH" or "LOW" as a value set on each bit on of the ATR full duplex state register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR idle state
+ * register
+ * - ATR_RX - a string of numbers representing a value of a ATR receive only state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR receive only
+ * state register
+ * - ATR_TX - a string of numbers representing a value of the ATR transmit only state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR transmit only
+ * state register
+ * - ATR_XX - a string of numbers representing a value of the ATR full duplex state
+ * register
+ * - "HIGH" or "LOW" as a value set on each bit on of the ATR full duplex
+ * state register
* - READBACK - readback input GPIOs
* \param bank the name of a GPIO bank
* \param attr the name of a GPIO attribute
* \param mboard the motherboard index 0 to M-1
* \return the value set for this attribute in vector of strings
*/
- virtual std::vector<std::string> get_gpio_string_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
+ virtual std::vector<std::string> get_gpio_string_attr(
+ const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
/*******************************************************************
* Register IO methods
******************************************************************/
- struct register_info_t {
+ struct register_info_t
+ {
size_t bitwidth;
bool readable;
bool writable;
@@ -1612,18 +1611,23 @@ public:
* Get more information about a low-level device register
* \param path the full path to the register
* \param mboard the motherboard index 0 to M-1
- * \return the info struct which contains the bitwidth and read-write access information
+ * \return the info struct which contains the bitwidth and read-write access
+ * information
*/
- virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
+ virtual register_info_t get_register_info(
+ const std::string& path, const size_t mboard = 0) = 0;
/*!
* Write a low-level register field for a register in the USRP hardware
* \param path the full path to the register
- * \param field the identifier of bitfield to be written (all other bits remain unchanged)
- * \param value the value to write to the register field
- * \param mboard the motherboard index 0 to M-1
+ * \param field the identifier of bitfield to be written (all other bits remain
+ * unchanged) \param value the value to write to the register field \param mboard the
+ * motherboard index 0 to M-1
*/
- virtual void write_register(const std::string &path, const uint32_t field, const uint64_t value, const size_t mboard = 0) = 0;
+ virtual void write_register(const std::string& path,
+ const uint32_t field,
+ const uint64_t value,
+ const size_t mboard = 0) = 0;
/*!
* Read a low-level register field from a register in the USRP hardware
@@ -1632,7 +1636,8 @@ public:
* \param mboard the motherboard index 0 to M-1
* \return the value of the register field
*/
- virtual uint64_t read_register(const std::string &path, const uint32_t field, const size_t mboard = 0) = 0;
+ virtual uint64_t read_register(
+ const std::string& path, const uint32_t field, const size_t mboard = 0) = 0;
/*******************************************************************
* Filter API methods
@@ -1644,18 +1649,19 @@ public:
* \parblock
* Select only certain filter names by specifying this search mask.
*
- * E.g. if search mask is set to "rx_frontends/A" only filter names including that string will be returned.
- * \endparblock
- * \return a vector of strings representing the selected filter names.
+ * E.g. if search mask is set to "rx_frontends/A" only filter names including that
+ * string will be returned. \endparblock \return a vector of strings representing the
+ * selected filter names.
*/
- virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
+ virtual std::vector<std::string> get_filter_names(
+ const std::string& search_mask = "") = 0;
/*!
* Return the filter object for the given name.
* \param path the name of the filter as returned from get_filter_names().
* \return a filter_info_base::sptr.
*/
- virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
+ virtual filter_info_base::sptr get_filter(const std::string& path) = 0;
/*!
* Write back a filter obtained by get_filter() to the signal path.
@@ -1664,10 +1670,10 @@ public:
* \param path the name of the filter as returned from get_filter_names().
* \param filter the filter_info_base::sptr of the filter object to be written
*/
- virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
-
+ virtual void set_filter(const std::string& path, filter_info_base::sptr filter) = 0;
};
-}}
+} // namespace usrp
+} // namespace uhd
#endif /* INCLUDED_UHD_USRP_MULTI_USRP_HPP */
diff --git a/host/include/uhd/usrp/subdev_spec.hpp b/host/include/uhd/usrp/subdev_spec.hpp
index 37746a7be..eb526e536 100644
--- a/host/include/uhd/usrp/subdev_spec.hpp
+++ b/host/include/uhd/usrp/subdev_spec.hpp
@@ -10,78 +10,76 @@
#include <uhd/config.hpp>
#include <boost/operators.hpp>
-#include <vector>
#include <string>
+#include <vector>
-namespace uhd{ namespace usrp{
+namespace uhd { namespace usrp {
- /*!
- * A subdevice specification (daughterboard slot, subdevice) name pairing.
- */
- struct UHD_API subdev_spec_pair_t : boost::equality_comparable<subdev_spec_pair_t>{
- //! The daughterboard slot name
- std::string db_name;
+/*!
+ * A subdevice specification (daughterboard slot, subdevice) name pairing.
+ */
+struct UHD_API subdev_spec_pair_t : boost::equality_comparable<subdev_spec_pair_t>
+{
+ //! The daughterboard slot name
+ std::string db_name;
- //! The subdevice name
- std::string sd_name;
+ //! The subdevice name
+ std::string sd_name;
- /*!
- * Create a new subdevice specification pair from dboard and subdev names.
- * \param db_name the name of a daughterboard slot
- * \param sd_name the name of a subdevice on that daughterboard
- */
- subdev_spec_pair_t(
- const std::string &db_name = "",
- const std::string &sd_name = ""
- );
+ /*!
+ * Create a new subdevice specification pair from dboard and subdev names.
+ * \param db_name the name of a daughterboard slot
+ * \param sd_name the name of a subdevice on that daughterboard
+ */
+ subdev_spec_pair_t(const std::string& db_name = "", const std::string& sd_name = "");
- //! overloaded equality operator
- bool operator==(const subdev_spec_pair_t &other);
+ //! overloaded equality operator
+ bool operator==(const subdev_spec_pair_t& other);
- //! overloaded inquality operator
- bool operator!=(const subdev_spec_pair_t &other);
- };
+ //! overloaded inquality operator
+ bool operator!=(const subdev_spec_pair_t& other);
+};
- //! overloaded comparison operator for subdev_spec_pair_t
- UHD_API bool operator==(const subdev_spec_pair_t &, const subdev_spec_pair_t &);
+//! overloaded comparison operator for subdev_spec_pair_t
+UHD_API bool operator==(const subdev_spec_pair_t&, const subdev_spec_pair_t&);
+/*!
+ * A list of (daughterboard slot name, subdevice name) pairs:
+ *
+ * A subdevice specification represents a list of subdevices on a motherboard.
+ * The subdevices specified may span across multiple daughterboards;
+ * Hence the need for a subdevice specification over a simple list of strings.
+ * Typically, the user will pass a RX or TX subdevice specification into the API,
+ * and the implementation will infer the channel configuration from the specification.
+ *
+ * The subdevice specification can be represented as a markup-string.
+ * The markup-string is a whitespace separated list of dboard:subdev pairs.
+ * The first pair represents the subdevice for channel zero,
+ * the second pair represents the subdevice for channel one, and so on.
+ */
+class UHD_API subdev_spec_t : public std::vector<subdev_spec_pair_t>
+{
+public:
/*!
- * A list of (daughterboard slot name, subdevice name) pairs:
- *
- * A subdevice specification represents a list of subdevices on a motherboard.
- * The subdevices specified may span across multiple daughterboards;
- * Hence the need for a subdevice specification over a simple list of strings.
- * Typically, the user will pass a RX or TX subdevice specification into the API,
- * and the implementation will infer the channel configuration from the specification.
- *
- * The subdevice specification can be represented as a markup-string.
- * The markup-string is a whitespace separated list of dboard:subdev pairs.
- * The first pair represents the subdevice for channel zero,
- * the second pair represents the subdevice for channel one, and so on.
+ * Create a subdev specification from a markup string.
+ * \param markup the markup string
*/
- class UHD_API subdev_spec_t : public std::vector<subdev_spec_pair_t>{
- public:
+ subdev_spec_t(const std::string& markup = "");
- /*!
- * Create a subdev specification from a markup string.
- * \param markup the markup string
- */
- subdev_spec_t(const std::string &markup = "");
-
- /*!
- * Convert a subdev specification into a pretty print string.
- * \return a printable string representing the subdev specification
- */
- std::string to_pp_string(void) const;
+ /*!
+ * Convert a subdev specification into a pretty print string.
+ * \return a printable string representing the subdev specification
+ */
+ std::string to_pp_string(void) const;
- /*!
- * Convert the subdevice specification into a markup string.
- * The markup string contains the delimiter symbols.
- * \return a string with delimiter markup
- */
- std::string to_string(void) const;
- };
+ /*!
+ * Convert the subdevice specification into a markup string.
+ * The markup string contains the delimiter symbols.
+ * \return a string with delimiter markup
+ */
+ std::string to_string(void) const;
+};
-}}
+}} // namespace uhd::usrp
#endif /* INCLUDED_UHD_USRP_SUBDEV_SPEC_HPP */
diff --git a/host/include/uhd/usrp_clock/multi_usrp_clock.hpp b/host/include/uhd/usrp_clock/multi_usrp_clock.hpp
index a8fe67684..05759c383 100644
--- a/host/include/uhd/usrp_clock/multi_usrp_clock.hpp
+++ b/host/include/uhd/usrp_clock/multi_usrp_clock.hpp
@@ -8,15 +8,14 @@
#ifndef INCLUDED_UHD_MULTI_USRP_CLOCK_HPP
#define INCLUDED_UHD_MULTI_USRP_CLOCK_HPP
-#include <string>
-#include <vector>
-
#include <uhd/config.hpp>
#include <uhd/device.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/sensors.hpp>
+#include <string>
+#include <vector>
-namespace uhd{ namespace usrp_clock{
+namespace uhd { namespace usrp_clock {
/*!
* The Multi-USRP-Clock device class:
@@ -43,7 +42,8 @@ namespace uhd{ namespace usrp_clock{
* multi_usrp_clock::sptr clock = multi_usrp_clock::make(dev);
* </pre>
*/
-class UHD_API multi_usrp_clock : boost::noncopyable {
+class UHD_API multi_usrp_clock : boost::noncopyable
+{
public:
typedef boost::shared_ptr<multi_usrp_clock> sptr;
@@ -54,7 +54,7 @@ public:
* \param dev_addr the device address
* \return a new Multi-USRP-Clock object
*/
- static sptr make(const device_addr_t &dev_addr);
+ static sptr make(const device_addr_t& dev_addr);
/*!
* Return the underlying device.
@@ -81,7 +81,7 @@ public:
* \param board the board index (0 to M-1)
* \return a sensor value object
*/
- virtual sensor_value_t get_sensor(const std::string &name, size_t board = 0) = 0;
+ virtual sensor_value_t get_sensor(const std::string& name, size_t board = 0) = 0;
/*!
* Get a list of possible USRP Clock sensor names.
@@ -91,7 +91,6 @@ public:
virtual std::vector<std::string> get_sensor_names(size_t board = 0) = 0;
};
-} //namespace
-} //namespace
+}} // namespace uhd::usrp_clock
#endif /* INCLUDED_UHD_MULTI_USRP_CLOCK_HPP */
diff --git a/host/include/uhd/usrp_clock/octoclock_eeprom.hpp b/host/include/uhd/usrp_clock/octoclock_eeprom.hpp
index 3aaa0ad7c..3d514ebc2 100644
--- a/host/include/uhd/usrp_clock/octoclock_eeprom.hpp
+++ b/host/include/uhd/usrp_clock/octoclock_eeprom.hpp
@@ -13,7 +13,7 @@
#include <uhd/types/dict.hpp>
#include <string>
-namespace uhd{ namespace usrp_clock{
+namespace uhd { namespace usrp_clock {
/*!
* The OctoClock EEPROM object:
@@ -22,7 +22,8 @@ namespace uhd{ namespace usrp_clock{
* Use the dictionary interface to get and set values.
* Commit to the EEPROM to save changed settings.
*/
-class UHD_API octoclock_eeprom_t : public uhd::dict<std::string, std::string>{
+class UHD_API octoclock_eeprom_t : public uhd::dict<std::string, std::string>
+{
public:
//! Make a new empty OctoClock EEPROM handler
octoclock_eeprom_t(void);
@@ -44,10 +45,8 @@ private:
uint32_t _proto_ver;
void _load();
void _store() const;
-
};
-} //namespace
-} //namespace
+}} // namespace uhd::usrp_clock
#endif /* INCLUDED_UHD_USRP_CLOCK_OCTOCLOCK_EEPROM_HPP */
diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp
index 6c2067918..6a6c611d6 100644
--- a/host/include/uhd/utils/algorithm.hpp
+++ b/host/include/uhd/utils/algorithm.hpp
@@ -8,74 +8,84 @@
#ifndef INCLUDED_UHD_UTILS_ALGORITHM_HPP
#define INCLUDED_UHD_UTILS_ALGORITHM_HPP
-#include <algorithm>
#include <stdint.h>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
+#include <algorithm>
/*!
* 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.
*/
-namespace uhd{
- /*!
- * 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(...)
- *
- * \param range the range of elements to be sorted
- * \return a new range with the elements sorted
- */
- template<typename Range> UHD_INLINE Range sorted(const Range &range){
- Range r(range); std::sort(boost::begin(r), boost::end(r)); return r;
- }
+namespace uhd {
+/*!
+ * 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(...)
+ *
+ * \param range the range of elements to be sorted
+ * \return a new range with the elements sorted
+ */
+template <typename Range> UHD_INLINE Range sorted(const Range& range)
+{
+ Range r(range);
+ std::sort(boost::begin(r), boost::end(r));
+ return r;
+}
- /*!
- * 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(...)
- *
- * \param range the range of elements to be reversed
- * \return a new range with the elements reversed
- */
- template<typename Range> UHD_INLINE Range reversed(const Range &range){
- Range r(range); std::reverse(boost::begin(r), boost::end(r)); return r;
- }
+/*!
+ * 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(...)
+ *
+ * \param range the range of elements to be reversed
+ * \return a new range with the elements reversed
+ */
+template <typename Range> UHD_INLINE Range reversed(const Range& range)
+{
+ Range r(range);
+ std::reverse(boost::begin(r), boost::end(r));
+ return r;
+}
- /*!
- * Is the value found within the elements in this range?
- *
- * Uses std::find to search the iterable for an element.
- *
- * \param range the elements to search through
- * \param value the match to look for in the range
- * \return true when the value is found in the range
- */
- template<typename Range, typename T> UHD_INLINE
- bool has(const Range &range, const T &value){
- return boost::end(range) != std::find(boost::begin(range), boost::end(range), value);
- }
+/*!
+ * Is the value found within the elements in this range?
+ *
+ * Uses std::find to search the iterable for an element.
+ *
+ * \param range the elements to search through
+ * \param value the match to look for in the range
+ * \return true when the value is found in the range
+ */
+template <typename Range, typename T>
+UHD_INLINE bool has(const Range& range, const T& value)
+{
+ return boost::end(range) != std::find(boost::begin(range), boost::end(range), value);
+}
- /*!
- * A templated clip implementation.
- * \param val the value to clip between an upper and lower limit
- * \param bound1 the upper or lower bound
- * \param bound2 the upper or lower bound
- * \return the value clipped at the bounds
- */
- template<typename T> UHD_INLINE T clip(const T &val, const T &bound1, const T &bound2){
- const T minimum = std::min(bound1, bound2);
- if (val < minimum) return minimum;
- const T maximum = std::max(bound1, bound2);
- if (val > maximum) return maximum;
- return val;
- }
+/*!
+ * A templated clip implementation.
+ * \param val the value to clip between an upper and lower limit
+ * \param bound1 the upper or lower bound
+ * \param bound2 the upper or lower bound
+ * \return the value clipped at the bounds
+ */
+template <typename T> UHD_INLINE T clip(const T& val, const T& bound1, const T& bound2)
+{
+ const T minimum = std::min(bound1, bound2);
+ if (val < minimum)
+ return minimum;
+ const T maximum = std::max(bound1, bound2);
+ if (val > maximum)
+ return maximum;
+ return val;
+}
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_ALGORITHM_HPP */
diff --git a/host/include/uhd/utils/assert_has.hpp b/host/include/uhd/utils/assert_has.hpp
index 25f3a2620..281c61ddf 100644
--- a/host/include/uhd/utils/assert_has.hpp
+++ b/host/include/uhd/utils/assert_has.hpp
@@ -11,26 +11,23 @@
#include <uhd/config.hpp>
#include <string>
-namespace uhd{
+namespace uhd {
- /*!
- * 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.
- *
- * \param range a list of possible settings
- * \param value an element that may be in the list
- * \param what a description of what the value is
- * \throw assertion_error when elem not in list
- */
- template<typename T, typename Range> void 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.
+ *
+ * \param range a list of possible settings
+ * \param value an element that may be in the list
+ * \param what a description of what the value is
+ * \throw assertion_error when elem not in list
+ */
+template <typename T, typename Range>
+void assert_has(const Range& range, const T& value, const std::string& what = "unknown");
-}//namespace uhd
+} // namespace uhd
#include <uhd/utils/assert_has.ipp>
diff --git a/host/include/uhd/utils/byteswap.hpp b/host/include/uhd/utils/byteswap.hpp
index a8fa81e19..e05a6cced 100644
--- a/host/include/uhd/utils/byteswap.hpp
+++ b/host/include/uhd/utils/byteswap.hpp
@@ -16,36 +16,36 @@
* Provide fast byteswaping routines for 16, 32, and 64 bit integers,
* by using the system's native routines/intrinsics when available.
*/
-namespace uhd{
+namespace uhd {
- //! perform a byteswap on a 16 bit integer
- uint16_t byteswap(uint16_t);
+//! perform a byteswap on a 16 bit integer
+uint16_t byteswap(uint16_t);
- //! perform a byteswap on a 32 bit integer
- uint32_t byteswap(uint32_t);
+//! perform a byteswap on a 32 bit integer
+uint32_t byteswap(uint32_t);
- //! perform a byteswap on a 64 bit integer
- uint64_t byteswap(uint64_t);
+//! perform a byteswap on a 64 bit integer
+uint64_t byteswap(uint64_t);
- //! network to host: short, long, or long-long
- template<typename T> T ntohx(T);
+//! network to host: short, long, or long-long
+template <typename T> T ntohx(T);
- //! host to network: short, long, or long-long
- template<typename T> T htonx(T);
+//! host to network: short, long, or long-long
+template <typename T> T htonx(T);
- //! worknet to host: short, long, or long-long
- //
- // The argument is assumed to be little-endian (i.e, the inverse
- // of typical network endianness).
- template<typename T> T wtohx(T);
+//! worknet to host: short, long, or long-long
+//
+// The argument is assumed to be little-endian (i.e, the inverse
+// of typical network endianness).
+template <typename T> T wtohx(T);
- //! host to worknet: short, long, or long-long
- //
- // The return value is little-endian (i.e, the inverse
- // of typical network endianness).
- template<typename T> T htowx(T);
+//! host to worknet: short, long, or long-long
+//
+// The return value is little-endian (i.e, the inverse
+// of typical network endianness).
+template <typename T> T htowx(T);
-} //namespace uhd
+} // namespace uhd
#include <uhd/utils/byteswap.ipp>
diff --git a/host/include/uhd/utils/cast.hpp b/host/include/uhd/utils/cast.hpp
index 0944c012a..d6d86d119 100644
--- a/host/include/uhd/utils/cast.hpp
+++ b/host/include/uhd/utils/cast.hpp
@@ -9,25 +9,24 @@
#define INCLUDED_UHD_UTILS_CAST_HPP
#include <uhd/config.hpp>
-#include <string>
#include <sstream>
+#include <string>
-namespace uhd{ namespace cast{
- //! Convert a hexadecimal string into a value.
- //
- // Example:
- // uint16_t x = hexstr_cast<uint16_t>("0xDEADBEEF");
- // Uses stringstream.
- template<typename T> UHD_INLINE T hexstr_cast(const std::string &in)
- {
- T x;
- std::stringstream ss;
- ss << std::hex << in;
- ss >> x;
- return x;
- }
+namespace uhd { namespace cast {
+//! Convert a hexadecimal string into a value.
+//
+// Example:
+// uint16_t x = hexstr_cast<uint16_t>("0xDEADBEEF");
+// Uses stringstream.
+template <typename T> UHD_INLINE T hexstr_cast(const std::string& in)
+{
+ T x;
+ std::stringstream ss;
+ ss << std::hex << in;
+ ss >> x;
+ return x;
+}
-}} //namespace uhd::cast
+}} // namespace uhd::cast
#endif /* INCLUDED_UHD_UTILS_CAST_HPP */
-
diff --git a/host/include/uhd/utils/csv.hpp b/host/include/uhd/utils/csv.hpp
index dbc73695b..90933d416 100644
--- a/host/include/uhd/utils/csv.hpp
+++ b/host/include/uhd/utils/csv.hpp
@@ -9,17 +9,17 @@
#define INCLUDED_UHD_UTILS_CSV_HPP
#include <uhd/config.hpp>
-#include <vector>
-#include <string>
#include <istream>
+#include <string>
+#include <vector>
-namespace uhd{ namespace csv{
- typedef std::vector<std::string> row_type;
- typedef std::vector<row_type> rows_type;
+namespace uhd { namespace csv {
+typedef std::vector<std::string> row_type;
+typedef std::vector<row_type> rows_type;
- //! Convert an input stream to csv rows.
- UHD_API rows_type to_rows(std::istream &input);
+//! Convert an input stream to csv rows.
+UHD_API rows_type to_rows(std::istream& input);
-}} //namespace uhd::csv
+}} // namespace uhd::csv
#endif /* INCLUDED_UHD_UTILS_CSV_HPP */
diff --git a/host/include/uhd/utils/dirty_tracked.hpp b/host/include/uhd/utils/dirty_tracked.hpp
index 1fbfddc6f..8fb390a8b 100644
--- a/host/include/uhd/utils/dirty_tracked.hpp
+++ b/host/include/uhd/utils/dirty_tracked.hpp
@@ -8,115 +8,126 @@
#ifndef INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
#define INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
-namespace uhd{
+namespace uhd {
+/*!
+ * A class that wraps a data value with a dirty flag
+ * When the client uses the assignment operator on this object, the object
+ * automatically dirties itself if the assigned type is not equal the underlying
+ * data. Data can be cleaned using the mark_clean entry-point.
+ *
+ * Requirements for data_t
+ * - Must have a default constructor
+ * - Must have a copy constructor
+ * - Must have an assignment operator (=)
+ * - Must have an equality operator (==)
+ */
+template <typename data_t> class dirty_tracked
+{
+public:
/*!
- * A class that wraps a data value with a dirty flag
- * When the client uses the assignment operator on this object, the object
- * automatically dirties itself if the assigned type is not equal the underlying
- * data. Data can be cleaned using the mark_clean entry-point.
- *
- * Requirements for data_t
- * - Must have a default constructor
- * - Must have a copy constructor
- * - Must have an assignment operator (=)
- * - Must have an equality operator (==)
+ * Default ctor: Initialize to default value and dirty
*/
- template<typename data_t>
- class dirty_tracked {
- public:
- /*!
- * Default ctor: Initialize to default value and dirty
- */
- dirty_tracked() :
- _data(), //data_t must have a default ctor
- _dirty(true)
- {}
+ dirty_tracked()
+ : _data()
+ , // data_t must have a default ctor
+ _dirty(true)
+ {
+ }
- /*!
- * Initialize to specified value and dirty
- */
- dirty_tracked(const data_t& value) :
- _data(value), //data_t must have a copy ctor
- _dirty(true)
- {}
+ /*!
+ * Initialize to specified value and dirty
+ */
+ dirty_tracked(const data_t& value)
+ : _data(value)
+ , // data_t must have a copy ctor
+ _dirty(true)
+ {
+ }
- /*!
- * Copy ctor: Assign source to this type
- */
- dirty_tracked(const dirty_tracked& source) {
- *this = source;
- }
+ /*!
+ * Copy ctor: Assign source to this type
+ */
+ dirty_tracked(const dirty_tracked& source)
+ {
+ *this = source;
+ }
- /*!
- * Get underlying data
- */
- UHD_INLINE const data_t& get() const {
- return _data;
- }
+ /*!
+ * Get underlying data
+ */
+ UHD_INLINE const data_t& get() const
+ {
+ return _data;
+ }
- /*!
- * Has the underlying data changed since the last
- * time it was cleaned?
- */
- UHD_INLINE bool is_dirty() const {
- return _dirty;
- }
+ /*!
+ * Has the underlying data changed since the last
+ * time it was cleaned?
+ */
+ UHD_INLINE bool is_dirty() const
+ {
+ return _dirty;
+ }
- /*!
- * Mark the underlying data as clean
- */
- UHD_INLINE void mark_clean() {
- _dirty = false;
- }
+ /*!
+ * Mark the underlying data as clean
+ */
+ UHD_INLINE void mark_clean()
+ {
+ _dirty = false;
+ }
- /*!
- * Mark the underlying data as dirty
- */
- UHD_INLINE void force_dirty() {
- _dirty = true;
- }
+ /*!
+ * Mark the underlying data as dirty
+ */
+ UHD_INLINE void force_dirty()
+ {
+ _dirty = true;
+ }
- /*!
- * Assignment with data.
- * Store the specified value and mark it as dirty
- * if it is not equal to the underlying data.
- */
- UHD_INLINE dirty_tracked& operator=(const data_t& value)
- {
- if(!(_data == value)) { //data_t must have an equality operator
- _dirty = true;
- _data = value; //data_t must have an assignment operator
- }
- return *this;
+ /*!
+ * Assignment with data.
+ * Store the specified value and mark it as dirty
+ * if it is not equal to the underlying data.
+ */
+ UHD_INLINE dirty_tracked& operator=(const data_t& value)
+ {
+ if (!(_data == value)) { // data_t must have an equality operator
+ _dirty = true;
+ _data = value; // data_t must have an assignment operator
}
+ return *this;
+ }
- /*!
- * Assignment with dirty tracked type.
- * Store the specified value from dirty type and mark it as dirty
- * if it is not equal to the underlying data.
- * This exists to optimize out an implicit cast from dirty_tracked
- * type to data type.
- */
- UHD_INLINE dirty_tracked& operator=(const dirty_tracked& source) {
- if (!(_data == source._data)) {
- _dirty = true;
- _data = source._data;
- }
- return *this;
+ /*!
+ * Assignment with dirty tracked type.
+ * Store the specified value from dirty type and mark it as dirty
+ * if it is not equal to the underlying data.
+ * This exists to optimize out an implicit cast from dirty_tracked
+ * type to data type.
+ */
+ UHD_INLINE dirty_tracked& operator=(const dirty_tracked& source)
+ {
+ if (!(_data == source._data)) {
+ _dirty = true;
+ _data = source._data;
}
+ return *this;
+ }
- /*!
- * Explicit conversion from this type to data_t
- */
- UHD_INLINE operator const data_t&() const {
- return get();
- }
+ /*!
+ * Explicit conversion from this type to data_t
+ */
+ UHD_INLINE operator const data_t&() const
+ {
+ return get();
+ }
- private:
- data_t _data;
- bool _dirty;
- };
+private:
+ data_t _data;
+ bool _dirty;
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
diff --git a/host/include/uhd/utils/gain_group.hpp b/host/include/uhd/utils/gain_group.hpp
index 128577c39..9822f3620 100644
--- a/host/include/uhd/utils/gain_group.hpp
+++ b/host/include/uhd/utils/gain_group.hpp
@@ -10,24 +10,26 @@
#include <uhd/config.hpp>
#include <uhd/types/ranges.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-#include <vector>
#include <string>
+#include <vector>
-namespace uhd{
+namespace uhd {
/*!
* A set of function to control a gain element.
*/
-struct UHD_API gain_fcns_t{
+struct UHD_API gain_fcns_t
+{
boost::function<gain_range_t(void)> get_range;
- boost::function<double(void)> get_value;
- boost::function<void(double)> set_value;
+ boost::function<double(void)> get_value;
+ boost::function<void(double)> set_value;
};
-class UHD_API gain_group : boost::noncopyable{
+class UHD_API gain_group : boost::noncopyable
+{
public:
typedef boost::shared_ptr<gain_group> sptr;
@@ -40,7 +42,7 @@ public:
* \param name name of the gain element (optional)
* \return a gain range with overall min, max, step
*/
- virtual gain_range_t get_range(const std::string &name = "") = 0;
+ virtual gain_range_t get_range(const std::string& name = "") = 0;
/*!
* Get the gain value for the gain element specified by name.
@@ -48,7 +50,7 @@ public:
* \param name name of the gain element (optional)
* \return a gain value of the element or all elements
*/
- virtual double get_value(const std::string &name = "") = 0;
+ virtual double get_value(const std::string& name = "") = 0;
/*!
* Set the gain value for the gain element specified by name.
@@ -58,7 +60,7 @@ public:
* \param gain the gain to set for the element or across the group
* \param name name of the gain element (optional)
*/
- virtual void set_value(double gain, const std::string &name = "") = 0;
+ virtual void set_value(double gain, const std::string& name = "") = 0;
/*!
* Get a list of names of registered gain elements.
@@ -82,10 +84,7 @@ public:
* \param priority the priority of the gain element
*/
virtual void register_fcns(
- const std::string &name,
- const gain_fcns_t &gain_fcns,
- size_t priority = 0
- ) = 0;
+ const std::string& name, const gain_fcns_t& gain_fcns, size_t priority = 0) = 0;
/*!
* Make a new empty gain group.
@@ -94,7 +93,6 @@ public:
static sptr make(void);
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_GAIN_GROUP_HPP */
-
diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp
index 584ba2cad..95ba8e670 100644
--- a/host/include/uhd/utils/log.hpp
+++ b/host/include/uhd/utils/log.hpp
@@ -11,10 +11,10 @@
#include <uhd/config.hpp>
#include <boost/current_function.hpp>
#include <boost/thread/thread.hpp>
+#include <iostream>
#include <ostream>
-#include <string>
#include <sstream>
-#include <iostream>
+#include <string>
/*! \file log.hpp
*
@@ -94,85 +94,83 @@
* fatal: 5
*/
-namespace uhd {
- namespace log {
- /*! Logging severity levels
- *
- * Either numeric value or string can be used to define loglevel in
- * CMake and environment variables
- */
- enum severity_level {
- trace = 0, /**< displays every available log message */
- debug = 1, /**< displays most log messages necessary for debugging internals */
- info = 2, /**< informational messages about setup and what is going on*/
- warning = 3, /**< something is not right but operation can continue */
- error = 4, /**< something has gone wrong */
- fatal = 5, /**< something has gone horribly wrong */
- off = 6, /**< logging is turned off */
- };
-
- /*! Logging info structure
- *
- * Information needed to create a log entry is fully contained in the
- * logging_info structure.
- */
- struct UHD_API logging_info {
- logging_info()
- : verbosity(uhd::log::off) {}
- logging_info(
- const boost::posix_time::ptime &time_,
- const uhd::log::severity_level &verbosity_,
- const std::string &file_,
- const unsigned int &line_,
- const std::string &component_,
- const boost::thread::id &thread_id_
- ) : time(time_),
- verbosity(verbosity_),
- file(file_),
- line(line_),
- component(component_),
- thread_id(thread_id_)
- { /* nop */ }
-
- boost::posix_time::ptime time;
- uhd::log::severity_level verbosity;
- std::string file;
- unsigned int line;
- std::string component;
- boost::thread::id thread_id;
- std::string message;
- };
-
- /*! Set the global log level
- *
- * The global log level gets applied before the specific log level.
- * So, if the global log level is 'info', no logger can can print
- * messages at level 'debug' or below.
- */
- UHD_API void set_log_level(uhd::log::severity_level level);
-
- /*! Set the log level for the console logger (if defined).
- *
- * Short-hand for `set_logger_level("console", level);`
- */
- UHD_API void set_console_level(uhd::log::severity_level level);
-
- /*! Set the log level for the file logger (if defined)
- *
- * Short-hand for `set_logger_level("file", level);`
- */
- UHD_API void set_file_level(uhd::log::severity_level level);
-
- /*! Set the log level for any specific logger.
- *
- * \param logger Name of the logger
- * \param level New log level for this logger.
- *
- * \throws uhd::key_error if \p logger was not defined
- */
- UHD_API void set_logger_level(const std::string &logger, uhd::log::severity_level level);
+namespace uhd { namespace log {
+/*! Logging severity levels
+ *
+ * Either numeric value or string can be used to define loglevel in
+ * CMake and environment variables
+ */
+enum severity_level {
+ trace = 0, /**< displays every available log message */
+ debug = 1, /**< displays most log messages necessary for debugging internals */
+ info = 2, /**< informational messages about setup and what is going on*/
+ warning = 3, /**< something is not right but operation can continue */
+ error = 4, /**< something has gone wrong */
+ fatal = 5, /**< something has gone horribly wrong */
+ off = 6, /**< logging is turned off */
+};
+
+/*! Logging info structure
+ *
+ * Information needed to create a log entry is fully contained in the
+ * logging_info structure.
+ */
+struct UHD_API logging_info
+{
+ logging_info() : verbosity(uhd::log::off) {}
+ logging_info(const boost::posix_time::ptime& time_,
+ const uhd::log::severity_level& verbosity_,
+ const std::string& file_,
+ const unsigned int& line_,
+ const std::string& component_,
+ const boost::thread::id& thread_id_)
+ : time(time_)
+ , verbosity(verbosity_)
+ , file(file_)
+ , line(line_)
+ , component(component_)
+ , thread_id(thread_id_)
+ { /* nop */
}
-}
+
+ boost::posix_time::ptime time;
+ uhd::log::severity_level verbosity;
+ std::string file;
+ unsigned int line;
+ std::string component;
+ boost::thread::id thread_id;
+ std::string message;
+};
+
+/*! Set the global log level
+ *
+ * The global log level gets applied before the specific log level.
+ * So, if the global log level is 'info', no logger can can print
+ * messages at level 'debug' or below.
+ */
+UHD_API void set_log_level(uhd::log::severity_level level);
+
+/*! Set the log level for the console logger (if defined).
+ *
+ * Short-hand for `set_logger_level("console", level);`
+ */
+UHD_API void set_console_level(uhd::log::severity_level level);
+
+/*! Set the log level for the file logger (if defined)
+ *
+ * Short-hand for `set_logger_level("file", level);`
+ */
+UHD_API void set_file_level(uhd::log::severity_level level);
+
+/*! Set the log level for any specific logger.
+ *
+ * \param logger Name of the logger
+ * \param level New log level for this logger.
+ *
+ * \throws uhd::key_error if \p logger was not defined
+ */
+UHD_API void set_logger_level(const std::string& logger, uhd::log::severity_level level);
+}} // namespace uhd::log
//! \cond
//! Internal logging macro to be used in other macros
@@ -182,45 +180,45 @@ namespace uhd {
// macro-style logging (compile-time determined)
#if UHD_LOG_MIN_LEVEL < 1
-#define UHD_LOG_TRACE(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::trace) << message;
+# define UHD_LOG_TRACE(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::trace) << message;
#else
-#define UHD_LOG_TRACE(component, message)
+# define UHD_LOG_TRACE(component, message)
#endif
#if UHD_LOG_MIN_LEVEL < 2
-#define UHD_LOG_DEBUG(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::debug) << message;
+# define UHD_LOG_DEBUG(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::debug) << message;
#else
-#define UHD_LOG_DEBUG(component, message)
+# define UHD_LOG_DEBUG(component, message)
#endif
#if UHD_LOG_MIN_LEVEL < 3
-#define UHD_LOG_INFO(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::info) << message;
+# define UHD_LOG_INFO(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::info) << message;
#else
-#define UHD_LOG_INFO(component, message)
+# define UHD_LOG_INFO(component, message)
#endif
#if UHD_LOG_MIN_LEVEL < 4
-#define UHD_LOG_WARNING(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::warning) << message;
+# define UHD_LOG_WARNING(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::warning) << message;
#else
-#define UHD_LOG_WARNING(component, message)
+# define UHD_LOG_WARNING(component, message)
#endif
#if UHD_LOG_MIN_LEVEL < 5
-#define UHD_LOG_ERROR(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::error) << message;
+# define UHD_LOG_ERROR(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::error) << message;
#else
-#define UHD_LOG_ERROR(component, message)
+# define UHD_LOG_ERROR(component, message)
#endif
#if UHD_LOG_MIN_LEVEL < 6
-#define UHD_LOG_FATAL(component, message) \
- _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message;
+# define UHD_LOG_FATAL(component, message) \
+ _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message;
#else
-#define UHD_LOG_FATAL(component, message)
+# define UHD_LOG_FATAL(component, message)
#endif
#ifndef UHD_LOG_FASTPATH_DISABLE
@@ -228,10 +226,9 @@ namespace uhd {
// No metadata is tracked. Only the message is displayed. This does not go
// through the regular backends. Mostly used for printing the UOSDL characters
// during streaming.
-#define UHD_LOG_FASTPATH(message) \
- uhd::_log::log_fastpath(message);
+# define UHD_LOG_FASTPATH(message) uhd::_log::log_fastpath(message);
#else
-#define UHD_LOG_FASTPATH(message)
+# define UHD_LOG_FASTPATH(message)
#endif
// iostream-style logging
@@ -245,67 +242,67 @@ namespace uhd {
#if defined(__GNUG__)
//! Helpful debug tool to print site info
-#define UHD_HERE() \
- UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__ << " (" << __PRETTY_FUNCTION__ << ")";
+# define UHD_HERE() \
+ UHD_LOGGER_DEBUG("DEBUG") \
+ << __FILE__ << ":" << __LINE__ << " (" << __PRETTY_FUNCTION__ << ")";
#else
//! Helpful debug tool to print site info
-#define UHD_HERE() \
- UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__;
+# define UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__;
#endif
//! Helpful debug tool to print a variable
-#define UHD_VAR(var) \
- UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var;
+#define UHD_VAR(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var;
//! Helpful debug tool to print a variable in hex
-#define UHD_HEX(var) \
- UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec;
+#define UHD_HEX(var) \
+ UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') \
+ << std::setw(8) << var << std::dec;
//! \cond
-namespace uhd{ namespace _log {
-
- //! Fastpath logging
- void UHD_API log_fastpath(const std::string &);
-
- //! Internal logging object (called by UHD_LOG* macros)
- class UHD_API log {
- public:
- log(
- const uhd::log::severity_level verbosity,
- const std::string &file,
- const unsigned int line,
- const std::string &component,
- const boost::thread::id thread_id
- );
-
- ~log(void);
-
- // Macro for overloading insertion operators to avoid costly
- // conversion of types if not logging.
- #define INSERTION_OVERLOAD(x) log& operator<< (x) \
- { \
- if(_log_it) { \
- _ss << val ; \
- } \
- return *this; \
- }
-
- // General insertion overload
- template <typename T>
- INSERTION_OVERLOAD(T val)
-
- // Insertion overloads for std::ostream manipulators
- INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&))
+namespace uhd {
+namespace _log {
+
+//! Fastpath logging
+void UHD_API log_fastpath(const std::string&);
+
+//! Internal logging object (called by UHD_LOG* macros)
+class UHD_API log
+{
+public:
+ log(const uhd::log::severity_level verbosity,
+ const std::string& file,
+ const unsigned int line,
+ const std::string& component,
+ const boost::thread::id thread_id);
+
+ ~log(void);
+
+// Macro for overloading insertion operators to avoid costly
+// conversion of types if not logging.
+#define INSERTION_OVERLOAD(x) \
+ log& operator<<(x) \
+ { \
+ if (_log_it) { \
+ _ss << val; \
+ } \
+ return *this; \
+ }
+
+ // General insertion overload
+ template <typename T>
+ INSERTION_OVERLOAD(T val)
+
+ // Insertion overloads for std::ostream manipulators
+ INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&))
INSERTION_OVERLOAD(std::ios& (*val)(std::ios&))
- INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&))
+ INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&))
- private:
- uhd::log::logging_info _log_info;
- std::ostringstream _ss;
- const bool _log_it;
- };
+ private : uhd::log::logging_info _log_info;
+ std::ostringstream _ss;
+ const bool _log_it;
+};
-} //namespace uhd::_log
+} // namespace _log
//! \endcond
} /* namespace uhd */
diff --git a/host/include/uhd/utils/log_add.hpp b/host/include/uhd/utils/log_add.hpp
index 3b552d3a4..36a34523e 100644
--- a/host/include/uhd/utils/log_add.hpp
+++ b/host/include/uhd/utils/log_add.hpp
@@ -13,23 +13,21 @@
#include <uhd/utils/log.hpp>
#include <functional>
-namespace uhd {
- namespace log {
+namespace uhd { namespace log {
- /*! Logging function type
- *
- * Every logging_backend has to define a function with this signature.
- * Can be added to the logging core.
- */
- typedef std::function<void(const uhd::log::logging_info&)> log_fn_t ;
+/*! Logging function type
+ *
+ * Every logging_backend has to define a function with this signature.
+ * Can be added to the logging core.
+ */
+typedef std::function<void(const uhd::log::logging_info&)> log_fn_t;
- /*! Add logging backend to the log system
- *
- * \param key Identifies the logging backend in the logging core
- * \param logger_fn function which actually logs messages to this backend
- */
- UHD_API void add_logger(const std::string &key, log_fn_t logger_fn);
- }
-} /* namespace uhd::log */
+/*! Add logging backend to the log system
+ *
+ * \param key Identifies the logging backend in the logging core
+ * \param logger_fn function which actually logs messages to this backend
+ */
+UHD_API void add_logger(const std::string& key, log_fn_t logger_fn);
+}} /* namespace uhd::log */
#endif /* INCLUDED_UHD_UTILS_LOG_ADD_HPP */
diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp
index b0e7dd145..e9f8efb57 100644
--- a/host/include/uhd/utils/math.hpp
+++ b/host/include/uhd/utils/math.hpp
@@ -8,10 +8,10 @@
#ifndef INCLUDED_UHD_UTILS_MATH_HPP
#define INCLUDED_UHD_UTILS_MATH_HPP
-#include <cmath>
#include <uhd/config.hpp>
#include <stdint.h>
#include <boost/numeric/conversion/bounds.hpp>
+#include <cmath>
namespace uhd {
@@ -21,213 +21,221 @@ namespace uhd {
*/
namespace math {
- /*!
- * Define epsilon values for floating point comparisons.
- *
- * There are a lot of different sources for epsilon values that we could use
- * for this. For single-precision (f32), most machines will report an
- * epsilon of 1.192e-7, and for double-precision (f64) most machines will
- * report an epsilon of 2.220e-16. The issue is that these are not always
- * appropriate, depending on the scale of the operands and how they have
- * been rounded in previous calculations. The values defined here are
- * defaults, but should be overridden for calculations depending on the
- * application.
- *
- * If a particular comparison is operating using very small or very large
- * values, a custom epsilon should be defined for those computations. This
- * use-case is provided for in the `fp_compare_epsilon` class constructor.
- */
- static const float SINGLE_PRECISION_EPSILON = 1.19e-7f;
- static const double DOUBLE_PRECISION_EPSILON = 2.22e-16;
+/*!
+ * Define epsilon values for floating point comparisons.
+ *
+ * There are a lot of different sources for epsilon values that we could use
+ * for this. For single-precision (f32), most machines will report an
+ * epsilon of 1.192e-7, and for double-precision (f64) most machines will
+ * report an epsilon of 2.220e-16. The issue is that these are not always
+ * appropriate, depending on the scale of the operands and how they have
+ * been rounded in previous calculations. The values defined here are
+ * defaults, but should be overridden for calculations depending on the
+ * application.
+ *
+ * If a particular comparison is operating using very small or very large
+ * values, a custom epsilon should be defined for those computations. This
+ * use-case is provided for in the `fp_compare_epsilon` class constructor.
+ */
+static const float SINGLE_PRECISION_EPSILON = 1.19e-7f;
+static const double DOUBLE_PRECISION_EPSILON = 2.22e-16;
namespace fp_compare {
- /*!
- * Class for floating-point comparisons using an epsilon.
- *
- * At construction, you can specify the epsilon to use for the comparisons.
- * This class, combined with the operators under it, allow for
- * epsilon-comparisons of floats. An example is:
- *
- * // Compare floats 'x' and 'y'.
- * bool x_equals_y = (fp_compare_epsilon<float>(x) == y);
- *
- * // Compare doubles 'x' and 'y'.
- * bool x_equals_y = (fp_compare_epsilon<double>(x) == y);
- */
- template<typename float_t> class fp_compare_epsilon {
- public:
- UHD_INLINE fp_compare_epsilon(float_t value);
- UHD_INLINE fp_compare_epsilon(float_t value, float_t epsilon);
- UHD_INLINE fp_compare_epsilon(const fp_compare_epsilon<float_t>& copy);
- UHD_INLINE ~fp_compare_epsilon();
- UHD_INLINE void operator=(const fp_compare_epsilon& copy);
-
- float_t _value;
- float_t _epsilon;
- };
-
- /* A Note on Floating Point Equality with Epsilons
- *
- * There are obviously a lot of strategies for defining floating point
- * equality, and in the end it all comes down to the domain at hand. UHD's
- * floating-point-with-epsilon comparison algorithm is based on the method
- * presented in Knuth's "The Art of Computer Science" called "very close
- * with tolerance epsilon".
- *
- * [(|u - v| / |u|) <= e] && [(|u - v| / |v|) <= e]
- *
- * UHD's modification to this algorithm is using the denominator's epsilon
- * value (since each float_t object has its own epsilon) for each
- * comparison.
- */
-
- template<typename float_t> UHD_INLINE
- bool operator==(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
-
- /* If these operators are used with floats, we rely on type promotion to
- * double. */
- template<typename float_t> UHD_INLINE
- bool operator==(fp_compare_epsilon<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(fp_compare_epsilon<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(fp_compare_epsilon<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(fp_compare_epsilon<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(fp_compare_epsilon<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(fp_compare_epsilon<float_t> lhs, double rhs);
-
- template<typename float_t> UHD_INLINE
- bool operator==(double lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(double lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(double lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(double lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(double lhs, fp_compare_epsilon<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(double lhs, fp_compare_epsilon<float_t> rhs);
+/*!
+ * Class for floating-point comparisons using an epsilon.
+ *
+ * At construction, you can specify the epsilon to use for the comparisons.
+ * This class, combined with the operators under it, allow for
+ * epsilon-comparisons of floats. An example is:
+ *
+ * // Compare floats 'x' and 'y'.
+ * bool x_equals_y = (fp_compare_epsilon<float>(x) == y);
+ *
+ * // Compare doubles 'x' and 'y'.
+ * bool x_equals_y = (fp_compare_epsilon<double>(x) == y);
+ */
+template <typename float_t> class fp_compare_epsilon
+{
+public:
+ UHD_INLINE fp_compare_epsilon(float_t value);
+ UHD_INLINE fp_compare_epsilon(float_t value, float_t epsilon);
+ UHD_INLINE fp_compare_epsilon(const fp_compare_epsilon<float_t>& copy);
+ UHD_INLINE ~fp_compare_epsilon();
+ UHD_INLINE void operator=(const fp_compare_epsilon& copy);
+
+ float_t _value;
+ float_t _epsilon;
+};
+
+/* A Note on Floating Point Equality with Epsilons
+ *
+ * There are obviously a lot of strategies for defining floating point
+ * equality, and in the end it all comes down to the domain at hand. UHD's
+ * floating-point-with-epsilon comparison algorithm is based on the method
+ * presented in Knuth's "The Art of Computer Science" called "very close
+ * with tolerance epsilon".
+ *
+ * [(|u - v| / |u|) <= e] && [(|u - v| / |v|) <= e]
+ *
+ * UHD's modification to this algorithm is using the denominator's epsilon
+ * value (since each float_t object has its own epsilon) for each
+ * comparison.
+ */
+
+template <typename float_t>
+UHD_INLINE bool operator==(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(
+ fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs);
+
+/* If these operators are used with floats, we rely on type promotion to
+ * double. */
+template <typename float_t>
+UHD_INLINE bool operator==(fp_compare_epsilon<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(fp_compare_epsilon<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(fp_compare_epsilon<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(fp_compare_epsilon<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(fp_compare_epsilon<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(fp_compare_epsilon<float_t> lhs, double rhs);
+
+template <typename float_t>
+UHD_INLINE bool operator==(double lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(double lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(double lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(double lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(double lhs, fp_compare_epsilon<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(double lhs, fp_compare_epsilon<float_t> rhs);
} // namespace fp_compare
- /*!
- * Define delta values for floating point comparisons.
- *
- * These are the default deltas used by the 'fp_compare_delta' class for
- * single and double-precision floating point comparisons.
- */
- static const float SINGLE_PRECISION_DELTA = 1e-3f;
- static const double DOUBLE_PRECISION_DELTA = 1e-5;
+/*!
+ * Define delta values for floating point comparisons.
+ *
+ * These are the default deltas used by the 'fp_compare_delta' class for
+ * single and double-precision floating point comparisons.
+ */
+static const float SINGLE_PRECISION_DELTA = 1e-3f;
+static const double DOUBLE_PRECISION_DELTA = 1e-5;
- /*! Floating-point delta to use for frequency comparisons. */
- static const double FREQ_COMPARISON_DELTA_HZ = 0.1;
+/*! Floating-point delta to use for frequency comparisons. */
+static const double FREQ_COMPARISON_DELTA_HZ = 0.1;
namespace fp_compare {
/*!
- * Class for floating-point comparisons using a delta.
- *
- * At construction, you can specify the delta to use for the comparisons.
- * This class, combined with the operators under it, allow for
- * delta-comparisons of floats. An example is:
- *
- * // Compare floats 'x' and 'y'.
- * bool x_equals_y = (fp_compare_delta<float>(x) == y);
- *
- * // Compare doubles 'x' and 'y'.
- * bool x_equals_y = (fp_compare_delta<double>(x) == y);
- */
- template<typename float_t> class fp_compare_delta {
- public:
- UHD_INLINE fp_compare_delta(float_t value);
- UHD_INLINE fp_compare_delta(float_t value, float_t delta);
- UHD_INLINE fp_compare_delta(const fp_compare_delta<float_t>& copy);
- UHD_INLINE ~fp_compare_delta();
- UHD_INLINE void operator=(const fp_compare_delta& copy);
-
- float_t _value;
- float_t _delta;
- };
-
- template<typename float_t> UHD_INLINE
- bool operator==(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
-
- /* If these operators are used with floats, we rely on type promotion to
- * double. */
- template<typename float_t> UHD_INLINE
- bool operator==(fp_compare_delta<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(fp_compare_delta<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(fp_compare_delta<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(fp_compare_delta<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(fp_compare_delta<float_t> lhs, double rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(fp_compare_delta<float_t> lhs, double rhs);
-
- template<typename float_t> UHD_INLINE
- bool operator==(double lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator!=(double lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<(double lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator<=(double lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>(double lhs, fp_compare_delta<float_t> rhs);
- template<typename float_t> UHD_INLINE
- bool operator>=(double lhs, fp_compare_delta<float_t> rhs);
+ * Class for floating-point comparisons using a delta.
+ *
+ * At construction, you can specify the delta to use for the comparisons.
+ * This class, combined with the operators under it, allow for
+ * delta-comparisons of floats. An example is:
+ *
+ * // Compare floats 'x' and 'y'.
+ * bool x_equals_y = (fp_compare_delta<float>(x) == y);
+ *
+ * // Compare doubles 'x' and 'y'.
+ * bool x_equals_y = (fp_compare_delta<double>(x) == y);
+ */
+template <typename float_t> class fp_compare_delta
+{
+public:
+ UHD_INLINE fp_compare_delta(float_t value);
+ UHD_INLINE fp_compare_delta(float_t value, float_t delta);
+ UHD_INLINE fp_compare_delta(const fp_compare_delta<float_t>& copy);
+ UHD_INLINE ~fp_compare_delta();
+ UHD_INLINE void operator=(const fp_compare_delta& copy);
+
+ float_t _value;
+ float_t _delta;
+};
+
+template <typename float_t>
+UHD_INLINE bool operator==(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs);
+
+/* If these operators are used with floats, we rely on type promotion to
+ * double. */
+template <typename float_t>
+UHD_INLINE bool operator==(fp_compare_delta<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(fp_compare_delta<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(fp_compare_delta<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(fp_compare_delta<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(fp_compare_delta<float_t> lhs, double rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(fp_compare_delta<float_t> lhs, double rhs);
+
+template <typename float_t>
+UHD_INLINE bool operator==(double lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator!=(double lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<(double lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator<=(double lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>(double lhs, fp_compare_delta<float_t> rhs);
+template <typename float_t>
+UHD_INLINE bool operator>=(double lhs, fp_compare_delta<float_t> rhs);
} // namespace fp_compare
- UHD_INLINE bool frequencies_are_equal(double lhs, double rhs) {
- return(fp_compare::fp_compare_delta<double>(lhs, FREQ_COMPARISON_DELTA_HZ)
- == fp_compare::fp_compare_delta<double>(rhs, FREQ_COMPARISON_DELTA_HZ));
- }
+UHD_INLINE bool frequencies_are_equal(double lhs, double rhs)
+{
+ return (fp_compare::fp_compare_delta<double>(lhs, FREQ_COMPARISON_DELTA_HZ)
+ == fp_compare::fp_compare_delta<double>(rhs, FREQ_COMPARISON_DELTA_HZ));
+}
- //! Portable log2()
- template <typename float_t> UHD_INLINE
- float_t log2(float_t x)
- {
- // C++11 defines std::log2(), when that's universally supported
- // we can switch over.
- return std::log(x) / std::log(float_t(2));
- }
+//! Portable log2()
+template <typename float_t> UHD_INLINE float_t log2(float_t x)
+{
+ // C++11 defines std::log2(), when that's universally supported
+ // we can switch over.
+ return std::log(x) / std::log(float_t(2));
+}
} // namespace math
} // namespace uhd
-#include <uhd/utils/fp_compare_epsilon.ipp>
#include <uhd/utils/fp_compare_delta.ipp>
+#include <uhd/utils/fp_compare_epsilon.ipp>
#endif /* INCLUDED_UHD_UTILS_MATH_HPP */
diff --git a/host/include/uhd/utils/msg_task.hpp b/host/include/uhd/utils/msg_task.hpp
index 18490c363..f19f8010d 100644
--- a/host/include/uhd/utils/msg_task.hpp
+++ b/host/include/uhd/utils/msg_task.hpp
@@ -10,58 +10,59 @@
#include <uhd/config.hpp>
#include <uhd/transport/zero_copy.hpp>
-#include <boost/shared_ptr.hpp>
+#include <stdint.h>
#include <boost/function.hpp>
-#include <boost/utility.hpp>
#include <boost/optional/optional.hpp>
-#include <stdint.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
#include <vector>
-namespace uhd{
- class UHD_API msg_task : boost::noncopyable{
- public:
- typedef boost::shared_ptr<msg_task> sptr;
- typedef std::vector<uint8_t> msg_payload_t;
- typedef std::pair<uint32_t, msg_payload_t > msg_type_t;
- typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type;
+namespace uhd {
+class UHD_API msg_task : boost::noncopyable
+{
+public:
+ typedef boost::shared_ptr<msg_task> sptr;
+ typedef std::vector<uint8_t> msg_payload_t;
+ typedef std::pair<uint32_t, msg_payload_t> msg_type_t;
+ typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type;
- /*
- * During shutdown message queues for radio control cores might not be available anymore.
- * Such stranded messages get pushed into a dump queue.
- * With this function radio_ctrl_core can check if one of the messages meant for it got stranded.
- */
- virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid) = 0;
+ /*
+ * During shutdown message queues for radio control cores might not be available
+ * anymore. Such stranded messages get pushed into a dump queue. With this function
+ * radio_ctrl_core can check if one of the messages meant for it got stranded.
+ */
+ virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid) = 0;
- UHD_INLINE static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n) {
- if(p and n > 0){
- std::vector<uint8_t> v(n);
- memcpy(&v.front(), p, n);
- return v;
- }
- return std::vector<uint8_t>();
- }
+ UHD_INLINE static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n)
+ {
+ if (p and n > 0) {
+ std::vector<uint8_t> v(n);
+ memcpy(&v.front(), p, n);
+ return v;
+ }
+ return std::vector<uint8_t>();
+ }
- virtual ~msg_task(void) = 0;
+ virtual ~msg_task(void) = 0;
- /*!
- * Create a new task object with function callback.
- * The task function callback will be run in a loop.
- * until the thread is interrupted by the deconstructor.
- *
- * A function may return payload which is then pushed to
- * a synchronized message queue.
- *
- * A task should return in a reasonable amount of time
- * or may block forever under the following conditions:
- * - The blocking call is interruptible.
- * - The task polls the interrupt condition.
- *
- * \param task_fcn the task callback function
- * \return a new task object
- */
- static sptr make(const task_fcn_type &task_fcn);
- };
-} //namespace uhd
+ /*!
+ * Create a new task object with function callback.
+ * The task function callback will be run in a loop.
+ * until the thread is interrupted by the deconstructor.
+ *
+ * A function may return payload which is then pushed to
+ * a synchronized message queue.
+ *
+ * A task should return in a reasonable amount of time
+ * or may block forever under the following conditions:
+ * - The blocking call is interruptible.
+ * - The task polls the interrupt condition.
+ *
+ * \param task_fcn the task callback function
+ * \return a new task object
+ */
+ static sptr make(const task_fcn_type& task_fcn);
+};
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_MSG_TASK_HPP */
-
diff --git a/host/include/uhd/utils/paths.hpp b/host/include/uhd/utils/paths.hpp
index 341e0fa6c..035a4943d 100644
--- a/host/include/uhd/utils/paths.hpp
+++ b/host/include/uhd/utils/paths.hpp
@@ -9,9 +9,7 @@
#define INCLUDED_UHD_UTILS_PATHS_HPP
#include <uhd/config.hpp>
-
#include <boost/filesystem.hpp>
-
#include <string>
#include <vector>
@@ -19,65 +17,67 @@ namespace fs = boost::filesystem;
namespace uhd {
- //! Get a string representing the system's temporary directory
- UHD_API std::string get_tmp_path(void);
+//! Get a string representing the system's temporary directory
+UHD_API std::string get_tmp_path(void);
- //! Get a string representing the system's appdata directory
- UHD_API std::string get_app_path(void);
+//! Get a string representing the system's appdata directory
+UHD_API std::string get_app_path(void);
- //! Get a string representing the system's pkg directory
- UHD_API std::string get_pkg_path(void);
+//! Get a string representing the system's pkg directory
+UHD_API std::string get_pkg_path(void);
- //! Get UHD library paths
- UHD_API std::vector<fs::path> get_module_paths(void);
+//! Get UHD library paths
+UHD_API std::vector<fs::path> get_module_paths(void);
- /*! 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.
- *
- * \param search_paths A comma-separated list of hints for paths to include.
- * \returns A path string if one is found, or an empty string on failure.
- */
- UHD_API std::string 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.
+ *
+ * \param search_paths A comma-separated list of hints for paths to include.
+ * \returns A path string if one is found, or an empty string on failure.
+ */
+UHD_API std::string get_images_dir(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.
- *
- * \param image_name The name of the file to search for, or the full path.
- * \param search_paths Hints / paths to use when calling `get_images_dir`
- * \return the full system path to the file
- * \throw exception uhd::io_error if the file was not found.
- */
- UHD_API std::string 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.
+ *
+ * \param image_name The name of the file to search for, or the full path.
+ * \param search_paths Hints / paths to use when calling `get_images_dir`
+ * \return the full system path to the file
+ * \throw exception uhd::io_error if the file was not found.
+ */
+UHD_API std::string find_image_path(
+ const std::string& image_name, const std::string& search_paths = "");
- /*!
- * Search for the location of a particular UHD utility.
- * The utility must be installed in the `uhd/utils` directory.
- * \param name the name of the utility to search for
- * \return the full system path to the given utility
- */
- UHD_API std::string find_utility(const std::string &name);
+/*!
+ * Search for the location of a particular UHD utility.
+ * The utility must be installed in the `uhd/utils` directory.
+ * \param name the name of the utility to search for
+ * \return the full system path to the given utility
+ */
+UHD_API std::string find_utility(const 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.
- * \return the message suggesting the use of the named utility.
- */
- UHD_API std::string print_utility_error(const std::string &name, const std::string &args = "");
-} //namespace uhd
+/*!
+ * Return an error string recommending the user run the utility.
+ * The error string will include the full path to the utility to run.
+ * \return the message suggesting the use of the named utility.
+ */
+UHD_API std::string print_utility_error(
+ const std::string& name, const std::string& args = "");
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_PATHS_HPP */
diff --git a/host/include/uhd/utils/pimpl.hpp b/host/include/uhd/utils/pimpl.hpp
index e536c3d0d..a19f4ddc2 100644
--- a/host/include/uhd/utils/pimpl.hpp
+++ b/host/include/uhd/utils/pimpl.hpp
@@ -30,7 +30,8 @@
* \param _name the name of the pimpl class
*/
#define UHD_PIMPL_DECL(_name) \
- struct _name; boost::shared_ptr<_name>
+ struct _name; \
+ boost::shared_ptr<_name>
/*!
* Make an instance of a pimpl in a source file.
@@ -39,7 +40,6 @@
* \param _name the name of the pimpl class
* \param _args the constructor args for the pimpl
*/
-#define UHD_PIMPL_MAKE(_name, _args) \
- boost::shared_ptr<_name>(new _name _args)
+#define UHD_PIMPL_MAKE(_name, _args) boost::shared_ptr<_name>(new _name _args)
#endif /* INCLUDED_UHD_UTILS_PIMPL_HPP */
diff --git a/host/include/uhd/utils/platform.hpp b/host/include/uhd/utils/platform.hpp
index bd5d19264..1d8d58b26 100644
--- a/host/include/uhd/utils/platform.hpp
+++ b/host/include/uhd/utils/platform.hpp
@@ -12,15 +12,15 @@
namespace uhd {
- /* Returns the process ID of the current process */
- int32_t get_process_id();
+/* Returns the process ID of the current process */
+int32_t get_process_id();
- /* Returns a unique identifier for the current machine */
- uint32_t get_host_id();
+/* Returns a unique identifier for the current machine */
+uint32_t get_host_id();
- /* Get a unique identifier for the current machine and process */
- uint32_t get_process_hash();
+/* Get a unique identifier for the current machine and process */
+uint32_t get_process_hash();
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_PLATFORM_HPP */
diff --git a/host/include/uhd/utils/safe_call.hpp b/host/include/uhd/utils/safe_call.hpp
index e37014b71..2688c5d68 100644
--- a/host/include/uhd/utils/safe_call.hpp
+++ b/host/include/uhd/utils/safe_call.hpp
@@ -13,9 +13,9 @@
#include <uhd/utils/log.hpp>
//! helper macro for safe call to produce warnings
-#define _UHD_SAFE_CALL_WARNING(code, what) UHD_LOGGER_ERROR("UHD") << \
- UHD_THROW_SITE_INFO("Exception caught in safe-call.") + #code + " -> " + what \
-;
+#define _UHD_SAFE_CALL_WARNING(code, what) \
+ UHD_LOGGER_ERROR("UHD") << UHD_THROW_SITE_INFO("Exception caught in safe-call.") \
+ + #code + " -> " + what;
/*!
* A safe-call catches all exceptions thrown by code,
@@ -23,12 +23,12 @@
* Usage: UHD_SAFE_CALL(some_code_to_call();)
* \param code the block of code to call safely
*/
-#define UHD_SAFE_CALL(code) \
- try{code} \
- catch(const std::exception &e){ \
- _UHD_SAFE_CALL_WARNING(code, e.what()); \
- } \
- catch(...){ \
+#define UHD_SAFE_CALL(code) \
+ try { \
+ code \
+ } catch (const std::exception& e) { \
+ _UHD_SAFE_CALL_WARNING(code, e.what()); \
+ } catch (...) { \
_UHD_SAFE_CALL_WARNING(code, "unknown exception"); \
}
diff --git a/host/include/uhd/utils/safe_main.hpp b/host/include/uhd/utils/safe_main.hpp
index 8261ad7d2..ca00a97dd 100644
--- a/host/include/uhd/utils/safe_main.hpp
+++ b/host/include/uhd/utils/safe_main.hpp
@@ -19,16 +19,19 @@
* \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)
+#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/soft_register.hpp b/host/include/uhd/utils/soft_register.hpp
index fea4c0791..5a1d175e0 100644
--- a/host/include/uhd/utils/soft_register.hpp
+++ b/host/include/uhd/utils/soft_register.hpp
@@ -8,16 +8,16 @@
#ifndef INCLUDED_UHD_UTILS_SOFT_REGISTER_HPP
#define INCLUDED_UHD_UTILS_SOFT_REGISTER_HPP
-#include <stdint.h>
-#include <boost/noncopyable.hpp>
-#include <uhd/types/wb_iface.hpp>
#include <uhd/exception.hpp>
+#include <uhd/types/wb_iface.hpp>
#include <uhd/utils/dirty_tracked.hpp>
-#include <boost/thread/mutex.hpp>
+#include <stdint.h>
+#include <boost/foreach.hpp>
+#include <boost/noncopyable.hpp>
#include <boost/thread/locks.hpp>
-#include <boost/unordered_map.hpp>
+#include <boost/thread/mutex.hpp>
#include <boost/tokenizer.hpp>
-#include <boost/foreach.hpp>
+#include <boost/unordered_map.hpp>
#include <list>
/*! \file soft_register.hpp
@@ -43,7 +43,7 @@
namespace uhd {
-//TODO: These hints were added to boost 1.53.
+// TODO: These hints were added to boost 1.53.
/** \brief hint for the branch prediction */
UHD_INLINE bool likely(bool expr)
@@ -53,7 +53,7 @@ UHD_INLINE bool likely(bool expr)
#else
return expr;
#endif
- }
+}
/** \brief hint for the branch prediction */
UHD_INLINE bool unlikely(bool expr)
@@ -75,45 +75,49 @@ UHD_INLINE bool unlikely(bool expr)
typedef uint32_t soft_reg_field_t;
namespace soft_reg_field {
- UHD_INLINE size_t width(const soft_reg_field_t field) {
- return (field & 0xFF);
- }
+UHD_INLINE size_t width(const soft_reg_field_t field)
+{
+ return (field & 0xFF);
+}
- UHD_INLINE size_t shift(const soft_reg_field_t field) {
- return ((field >> 8) & 0xFF);
- }
+UHD_INLINE size_t shift(const soft_reg_field_t field)
+{
+ return ((field >> 8) & 0xFF);
+}
- template<typename data_t>
- UHD_INLINE data_t mask(const soft_reg_field_t field) {
- constexpr data_t ONE = static_cast<data_t>(1);
- constexpr data_t ALL_ONES = ~static_cast<data_t>(0);
- //Behavior for the left shift operation is undefined in C++
- //if the shift amount is >= bitwidth of the datatype
- //So we treat that as a special case with a branch predicition hint
- if (likely((sizeof(data_t)*8) != width(field))) {
- return ((ONE<<width(field))-ONE)<<shift(field);
- } else {
- return ALL_ONES<<shift(field);
- }
+template <typename data_t> UHD_INLINE data_t mask(const soft_reg_field_t field)
+{
+ constexpr data_t ONE = static_cast<data_t>(1);
+ constexpr data_t ALL_ONES = ~static_cast<data_t>(0);
+ // Behavior for the left shift operation is undefined in C++
+ // if the shift amount is >= bitwidth of the datatype
+ // So we treat that as a special case with a branch predicition hint
+ if (likely((sizeof(data_t) * 8) != width(field))) {
+ return ((ONE << width(field)) - ONE) << shift(field);
+ } else {
+ return ALL_ONES << shift(field);
}
}
+} // namespace soft_reg_field
-class soft_register_base : public boost::noncopyable {
+class soft_register_base : public boost::noncopyable
+{
public:
virtual ~soft_register_base() {}
virtual void initialize(wb_iface& iface, bool sync = false) = 0;
- virtual void flush() = 0;
- virtual void refresh() = 0;
- virtual size_t get_bitwidth() = 0;
- virtual bool is_readable() = 0;
- virtual bool is_writable() = 0;
+ virtual void flush() = 0;
+ virtual void refresh() = 0;
+ virtual size_t get_bitwidth() = 0;
+ virtual bool is_readable() = 0;
+ virtual bool is_writable() = 0;
/*!
* Cast the soft_register generic reference to a more specific type
*/
template <typename soft_reg_t>
- UHD_INLINE static soft_reg_t& cast(soft_register_base& reg) {
+ UHD_INLINE static soft_reg_t& cast(soft_register_base& reg)
+ {
soft_reg_t* ptr = dynamic_cast<soft_reg_t*>(&reg);
if (ptr) {
return *ptr;
@@ -130,33 +134,38 @@ enum soft_reg_flush_mode_t { OPTIMIZED_FLUSH, ALWAYS_FLUSH };
* Methods give convenient field-level access to soft-copy and the ability
* to do read-modify-write operations.
*/
-template<typename reg_data_t, bool readable, bool writable>
-class UHD_API soft_register_t : public soft_register_base {
+template <typename reg_data_t, bool readable, bool writable>
+class UHD_API soft_register_t : public soft_register_base
+{
public:
- typedef boost::shared_ptr< soft_register_t<reg_data_t, readable, writable> > sptr;
+ typedef boost::shared_ptr<soft_register_t<reg_data_t, readable, writable> > sptr;
- //Reserved field. Represents all bits in the register.
- UHD_DEFINE_SOFT_REG_FIELD(REGISTER, sizeof(reg_data_t)*8, 0); //[WIDTH-1:0]
+ // Reserved field. Represents all bits in the register.
+ UHD_DEFINE_SOFT_REG_FIELD(REGISTER, sizeof(reg_data_t) * 8, 0); //[WIDTH-1:0]
/*!
* Generic constructor for all soft_register types
*/
- soft_register_t(
- wb_iface::wb_addr_type wr_addr,
- wb_iface::wb_addr_type rd_addr,
- soft_reg_flush_mode_t mode = ALWAYS_FLUSH):
- _iface(NULL), _wr_addr(wr_addr), _rd_addr(rd_addr), _soft_copy(0), _flush_mode(mode)
- {}
+ soft_register_t(wb_iface::wb_addr_type wr_addr,
+ wb_iface::wb_addr_type rd_addr,
+ soft_reg_flush_mode_t mode = ALWAYS_FLUSH)
+ : _iface(NULL)
+ , _wr_addr(wr_addr)
+ , _rd_addr(rd_addr)
+ , _soft_copy(0)
+ , _flush_mode(mode)
+ {
+ }
/*!
* Constructor for read-only, write-only registers and read-write registers
* with rd_addr == wr_addr
*/
explicit soft_register_t(
- wb_iface::wb_addr_type addr,
- soft_reg_flush_mode_t mode = ALWAYS_FLUSH):
- _iface(NULL), _wr_addr(addr), _rd_addr(addr), _soft_copy(0), _flush_mode(mode)
- {}
+ wb_iface::wb_addr_type addr, soft_reg_flush_mode_t mode = ALWAYS_FLUSH)
+ : _iface(NULL), _wr_addr(addr), _rd_addr(addr), _soft_copy(0), _flush_mode(mode)
+ {
+ }
/*!
* Initialize the register when the underlying bus is usable.
@@ -167,9 +176,11 @@ public:
{
_iface = &iface;
- //Synchronize with hardware. For RW register, flush THEN refresh.
- if (sync && writable) flush();
- if (sync && readable) refresh();
+ // Synchronize with hardware. For RW register, flush THEN refresh.
+ if (sync && writable)
+ flush();
+ if (sync && readable)
+ refresh();
}
/*!
@@ -179,8 +190,9 @@ public:
*/
UHD_INLINE void set(const soft_reg_field_t field, const reg_data_t value)
{
- _soft_copy = (_soft_copy & ~soft_reg_field::mask<reg_data_t>(field)) |
- ((value << soft_reg_field::shift(field)) & soft_reg_field::mask<reg_data_t>(field));
+ _soft_copy = (_soft_copy & ~soft_reg_field::mask<reg_data_t>(field))
+ | ((value << soft_reg_field::shift(field))
+ & soft_reg_field::mask<reg_data_t>(field));
}
/*!
@@ -189,7 +201,8 @@ public:
*/
UHD_INLINE reg_data_t get(const soft_reg_field_t field)
{
- return (_soft_copy & soft_reg_field::mask<reg_data_t>(field)) >> soft_reg_field::shift(field);
+ return (_soft_copy & soft_reg_field::mask<reg_data_t>(field))
+ >> soft_reg_field::shift(field);
}
/*!
@@ -198,9 +211,9 @@ public:
UHD_INLINE void flush()
{
if (writable && _iface) {
- //If optimized flush then poke only if soft copy is dirty
- //If flush mode is ALWAYS, the dirty flag should get optimized
- //out by the compiler because it is never read
+ // If optimized flush then poke only if soft copy is dirty
+ // If flush mode is ALWAYS, the dirty flag should get optimized
+ // out by the compiler because it is never read
if (_flush_mode == ALWAYS_FLUSH || _soft_copy.is_dirty()) {
if (get_bitwidth() <= 16) {
_iface->poke16(_wr_addr, static_cast<uint16_t>(_soft_copy));
@@ -209,12 +222,14 @@ public:
} else if (get_bitwidth() <= 64) {
_iface->poke64(_wr_addr, static_cast<uint64_t>(_soft_copy));
} else {
- throw uhd::not_implemented_error("soft_register only supports up to 64 bits.");
+ throw uhd::not_implemented_error(
+ "soft_register only supports up to 64 bits.");
}
_soft_copy.mark_clean();
}
} else {
- throw uhd::not_implemented_error("soft_register is not writable or uninitialized.");
+ throw uhd::not_implemented_error(
+ "soft_register is not writable or uninitialized.");
}
}
@@ -231,11 +246,13 @@ public:
} else if (get_bitwidth() <= 64) {
_soft_copy = static_cast<reg_data_t>(_iface->peek64(_rd_addr));
} else {
- throw uhd::not_implemented_error("soft_register only supports up to 64 bits.");
+ throw uhd::not_implemented_error(
+ "soft_register only supports up to 64 bits.");
}
_soft_copy.mark_clean();
} else {
- throw uhd::not_implemented_error("soft_register is not readable or uninitialized.");
+ throw uhd::not_implemented_error(
+ "soft_register is not readable or uninitialized.");
}
}
@@ -283,34 +300,37 @@ public:
}
private:
- wb_iface* _iface;
- const wb_iface::wb_addr_type _wr_addr;
- const wb_iface::wb_addr_type _rd_addr;
- dirty_tracked<reg_data_t> _soft_copy;
- const soft_reg_flush_mode_t _flush_mode;
+ wb_iface* _iface;
+ const wb_iface::wb_addr_type _wr_addr;
+ const wb_iface::wb_addr_type _rd_addr;
+ dirty_tracked<reg_data_t> _soft_copy;
+ const soft_reg_flush_mode_t _flush_mode;
};
/*!
* A synchronized soft register object.
* All operations in the synchronized register are serialized.
*/
-template<typename reg_data_t, bool readable, bool writable>
-class UHD_API soft_register_sync_t : public soft_register_t<reg_data_t, readable, writable> {
+template <typename reg_data_t, bool readable, bool writable>
+class UHD_API soft_register_sync_t
+ : public soft_register_t<reg_data_t, readable, writable>
+{
public:
- typedef boost::shared_ptr< soft_register_sync_t<reg_data_t, readable, writable> > sptr;
+ typedef boost::shared_ptr<soft_register_sync_t<reg_data_t, readable, writable> > sptr;
- soft_register_sync_t(
- wb_iface::wb_addr_type wr_addr,
- wb_iface::wb_addr_type rd_addr,
- soft_reg_flush_mode_t mode = ALWAYS_FLUSH):
- soft_register_t<reg_data_t, readable, writable>(wr_addr, rd_addr, mode), _mutex()
- {}
+ soft_register_sync_t(wb_iface::wb_addr_type wr_addr,
+ wb_iface::wb_addr_type rd_addr,
+ soft_reg_flush_mode_t mode = ALWAYS_FLUSH)
+ : soft_register_t<reg_data_t, readable, writable>(wr_addr, rd_addr, mode)
+ , _mutex()
+ {
+ }
explicit soft_register_sync_t(
- wb_iface::wb_addr_type addr,
- soft_reg_flush_mode_t mode = ALWAYS_FLUSH):
- soft_register_t<reg_data_t, readable, writable>(addr, mode), _mutex()
- {}
+ wb_iface::wb_addr_type addr, soft_reg_flush_mode_t mode = ALWAYS_FLUSH)
+ : soft_register_t<reg_data_t, readable, writable>(addr, mode), _mutex()
+ {
+ }
UHD_INLINE void initialize(wb_iface& iface, bool sync = false)
{
@@ -370,27 +390,27 @@ private:
*
*/
-//16-bit shortcuts
-typedef soft_register_t<uint16_t, false, true> soft_reg16_wo_t;
-typedef soft_register_t<uint16_t, true, false> soft_reg16_ro_t;
-typedef soft_register_t<uint16_t, true, true> soft_reg16_rw_t;
-typedef soft_register_sync_t<uint16_t, false, true> soft_reg16_wo_sync_t;
-typedef soft_register_sync_t<uint16_t, true, false> soft_reg16_ro_sync_t;
-typedef soft_register_sync_t<uint16_t, true, true> soft_reg16_rw_sync_t;
-//32-bit shortcuts
-typedef soft_register_t<uint32_t, false, true> soft_reg32_wo_t;
-typedef soft_register_t<uint32_t, true, false> soft_reg32_ro_t;
-typedef soft_register_t<uint32_t, true, true> soft_reg32_rw_t;
-typedef soft_register_sync_t<uint32_t, false, true> soft_reg32_wo_sync_t;
-typedef soft_register_sync_t<uint32_t, true, false> soft_reg32_ro_sync_t;
-typedef soft_register_sync_t<uint32_t, true, true> soft_reg32_rw_sync_t;
-//64-bit shortcuts
-typedef soft_register_t<uint64_t, false, true> soft_reg64_wo_t;
-typedef soft_register_t<uint64_t, true, false> soft_reg64_ro_t;
-typedef soft_register_t<uint64_t, true, true> soft_reg64_rw_t;
-typedef soft_register_sync_t<uint64_t, false, true> soft_reg64_wo_sync_t;
-typedef soft_register_sync_t<uint64_t, true, false> soft_reg64_ro_sync_t;
-typedef soft_register_sync_t<uint64_t, true, true> soft_reg64_rw_sync_t;
+// 16-bit shortcuts
+typedef soft_register_t<uint16_t, false, true> soft_reg16_wo_t;
+typedef soft_register_t<uint16_t, true, false> soft_reg16_ro_t;
+typedef soft_register_t<uint16_t, true, true> soft_reg16_rw_t;
+typedef soft_register_sync_t<uint16_t, false, true> soft_reg16_wo_sync_t;
+typedef soft_register_sync_t<uint16_t, true, false> soft_reg16_ro_sync_t;
+typedef soft_register_sync_t<uint16_t, true, true> soft_reg16_rw_sync_t;
+// 32-bit shortcuts
+typedef soft_register_t<uint32_t, false, true> soft_reg32_wo_t;
+typedef soft_register_t<uint32_t, true, false> soft_reg32_ro_t;
+typedef soft_register_t<uint32_t, true, true> soft_reg32_rw_t;
+typedef soft_register_sync_t<uint32_t, false, true> soft_reg32_wo_sync_t;
+typedef soft_register_sync_t<uint32_t, true, false> soft_reg32_ro_sync_t;
+typedef soft_register_sync_t<uint32_t, true, true> soft_reg32_rw_sync_t;
+// 64-bit shortcuts
+typedef soft_register_t<uint64_t, false, true> soft_reg64_wo_t;
+typedef soft_register_t<uint64_t, true, false> soft_reg64_ro_t;
+typedef soft_register_t<uint64_t, true, true> soft_reg64_rw_t;
+typedef soft_register_sync_t<uint64_t, false, true> soft_reg64_wo_sync_t;
+typedef soft_register_sync_t<uint64_t, true, false> soft_reg64_ro_sync_t;
+typedef soft_register_sync_t<uint64_t, true, true> soft_reg64_rw_sync_t;
/*
@@ -424,7 +444,7 @@ typedef soft_register_sync_t<uint64_t, true, true> soft_reg64_rw_sync_t;
reg_obj->write(example_reg_t::FIELD2, 0x1234);
}
*/
-}
+} // namespace uhd
//==================================================================
// Soft Register Map and Database Definition
@@ -432,14 +452,15 @@ typedef soft_register_sync_t<uint64_t, true, true> soft_reg64_rw_sync_t;
namespace uhd {
-class UHD_API soft_regmap_accessor_t {
+class UHD_API soft_regmap_accessor_t
+{
public:
typedef boost::shared_ptr<soft_regmap_accessor_t> sptr;
- virtual ~soft_regmap_accessor_t() {};
+ virtual ~soft_regmap_accessor_t(){};
virtual soft_register_base& lookup(const std::string& path) const = 0;
- virtual std::vector<std::string> enumerate() const = 0;
- virtual const std::string& get_name() const = 0;
+ virtual std::vector<std::string> enumerate() const = 0;
+ virtual const std::string& get_name() const = 0;
};
/*!
@@ -452,15 +473,19 @@ public:
* Methods give convenient field-level access to soft-copy and the ability
* to do read-modify-write operations.
*/
-class UHD_API soft_regmap_t : public soft_regmap_accessor_t, public boost::noncopyable {
+class UHD_API soft_regmap_t : public soft_regmap_accessor_t, public boost::noncopyable
+{
public:
soft_regmap_t(const std::string& name) : _name(name) {}
- virtual ~soft_regmap_t() {};
+ virtual ~soft_regmap_t(){};
/*!
* Get the name of this register map
*/
- virtual UHD_INLINE const std::string& get_name() const { return _name; }
+ virtual UHD_INLINE const std::string& get_name() const
+ {
+ return _name;
+ }
/*!
* Initialize all registers in this register map using a bus.
@@ -468,9 +493,10 @@ public:
* The order of initialization is the same as the order in
* which registers were added to the map.
*/
- void initialize(wb_iface& iface, bool sync = false) {
+ void initialize(wb_iface& iface, bool sync = false)
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
- BOOST_FOREACH(soft_register_base* reg, _reglist) {
+ BOOST_FOREACH (soft_register_base* reg, _reglist) {
reg->initialize(iface, sync);
}
}
@@ -480,9 +506,10 @@ public:
* The order of writing is the same as the order in
* which registers were added to the map.
*/
- void flush() {
+ void flush()
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
- BOOST_FOREACH(soft_register_base* reg, _reglist) {
+ BOOST_FOREACH (soft_register_base* reg, _reglist) {
reg->flush();
}
}
@@ -492,9 +519,10 @@ public:
* The order of reading is the same as the order in
* which registers were added to the map.
*/
- void refresh() {
+ void refresh()
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
- BOOST_FOREACH(soft_register_base* reg, _reglist) {
+ BOOST_FOREACH (soft_register_base* reg, _reglist) {
reg->refresh();
}
}
@@ -503,7 +531,8 @@ public:
* Lookup a register object by name.
* If a register with "name" is not found, runtime_error is thrown
*/
- virtual soft_register_base& lookup(const std::string& name) const {
+ virtual soft_register_base& lookup(const std::string& name) const
+ {
regmap_t::const_iterator iter = _regmap.find(name);
if (iter != _regmap.end()) {
return *(iter->second);
@@ -516,9 +545,10 @@ public:
* Enumerate all the registers in this map.
* Return fully qualified paths.
*/
- virtual std::vector<std::string> enumerate() const {
+ virtual std::vector<std::string> enumerate() const
+ {
std::vector<std::string> temp;
- BOOST_FOREACH(const regmap_t::value_type& reg, _regmap) {
+ BOOST_FOREACH (const regmap_t::value_type& reg, _regmap) {
temp.push_back(_name + "/" + reg.first);
}
return temp;
@@ -526,19 +556,23 @@ public:
protected:
enum visibility_t {
- PUBLIC, //Is accessible through the soft_regmap_accessor_t interface
- PRIVATE //Is NOT accessible through the soft_regmap_accessor_t interface
+ PUBLIC, // Is accessible through the soft_regmap_accessor_t interface
+ PRIVATE // Is NOT accessible through the soft_regmap_accessor_t interface
};
/*!
* Add a register to this map with an identifier "name" and visibility
*/
- UHD_INLINE void add_to_map(soft_register_base& reg, const std::string& name, const visibility_t visible = PRIVATE) {
+ UHD_INLINE void add_to_map(soft_register_base& reg,
+ const std::string& name,
+ const visibility_t visible = PRIVATE)
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
if (visible == PUBLIC) {
- //Only add to the map if this register is publicly visible
+ // Only add to the map if this register is publicly visible
if (not _regmap.insert(regmap_t::value_type(name, &reg)).second) {
- throw uhd::assertion_error("cannot add two registers with the same name to regmap: " + name);
+ throw uhd::assertion_error(
+ "cannot add two registers with the same name to regmap: " + name);
}
}
_reglist.push_back(&reg);
@@ -546,12 +580,12 @@ protected:
private:
typedef boost::unordered_map<std::string, soft_register_base*> regmap_t;
- typedef std::list<soft_register_base*> reglist_t;
+ typedef std::list<soft_register_base*> reglist_t;
- const std::string _name;
- regmap_t _regmap; //For lookups
- reglist_t _reglist; //To maintain order
- boost::mutex _mutex;
+ const std::string _name;
+ regmap_t _regmap; // For lookups
+ reglist_t _reglist; // To maintain order
+ boost::mutex _mutex;
};
@@ -561,7 +595,8 @@ private:
* fashion.
* A regmap_db *does not* manage storage for regmaps. It is simply a wrapper.
*/
-class UHD_API soft_regmap_db_t : public soft_regmap_accessor_t, public boost::noncopyable {
+class UHD_API soft_regmap_db_t : public soft_regmap_accessor_t, public boost::noncopyable
+{
public:
typedef boost::shared_ptr<soft_regmap_db_t> sptr;
@@ -578,12 +613,16 @@ public:
/*!
* Get the name of this register map
*/
- const std::string& get_name() const { return _name; }
+ const std::string& get_name() const
+ {
+ return _name;
+ }
/*!
* Add a regmap to this map with an identifier "name" and visibility
*/
- void add(soft_regmap_t& regmap) {
+ void add(soft_regmap_t& regmap)
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
_regmaps.push_back(&regmap);
}
@@ -591,7 +630,8 @@ public:
/*!
* Add a level of regmap_db to this map with an identifier "name" and visibility
*/
- void add(soft_regmap_db_t& db) {
+ void add(soft_regmap_db_t& db)
+ {
boost::lock_guard<boost::mutex> lock(_mutex);
if (&db == this) {
throw uhd::assertion_error("cannot add regmap db to itself" + _name);
@@ -612,32 +652,33 @@ public:
*/
soft_register_base& lookup(const std::string& path) const
{
- //Turn the slash separated path string into tokens
+ // Turn the slash separated path string into tokens
std::list<std::string> tokens;
- BOOST_FOREACH(
- const std::string& node,
- boost::tokenizer< boost::char_separator<char> >(path, boost::char_separator<char>("/")))
- {
+ BOOST_FOREACH (const std::string& node,
+ boost::tokenizer<boost::char_separator<char> >(
+ path, boost::char_separator<char>("/"))) {
tokens.push_back(node);
}
- if ((tokens.size() > 2 && tokens.front() == _name) || //If this is a nested DB
- (tokens.size() > 1 && _name == "")) { //If this is a top-level DB
- if (_name != "") tokens.pop_front();
- if (tokens.size() == 2) { //2 tokens => regmap/register path
- BOOST_FOREACH(const soft_regmap_accessor_t* regmap, _regmaps) {
+ if ((tokens.size() > 2 && tokens.front() == _name) || // If this is a nested DB
+ (tokens.size() > 1 && _name == "")) { // If this is a top-level DB
+ if (_name != "")
+ tokens.pop_front();
+ if (tokens.size() == 2) { // 2 tokens => regmap/register path
+ BOOST_FOREACH (const soft_regmap_accessor_t* regmap, _regmaps) {
if (regmap->get_name() == tokens.front()) {
return regmap->lookup(tokens.back());
}
}
throw uhd::runtime_error("could not find register map: " + path);
- } else if (not _regmap_dbs.empty()) { //>2 tokens => <1 or more dbs>/regmap/register
- //Reconstruct path from tokens
+ } else if (not _regmap_dbs
+ .empty()) { //>2 tokens => <1 or more dbs>/regmap/register
+ // Reconstruct path from tokens
std::string newpath;
- BOOST_FOREACH(const std::string& node, tokens) {
+ BOOST_FOREACH (const std::string& node, tokens) {
newpath += ("/" + node);
}
- //Dispatch path to hierarchical DB
- BOOST_FOREACH(const soft_regmap_accessor_t* db, _regmap_dbs) {
+ // Dispatch path to hierarchical DB
+ BOOST_FOREACH (const soft_regmap_accessor_t* db, _regmap_dbs) {
try {
return db->lookup(newpath.substr(1));
} catch (std::exception&) {
@@ -652,13 +693,14 @@ public:
/*!
* Enumerate the paths of all registers that this DB can access
*/
- virtual std::vector<std::string> enumerate() const {
+ virtual std::vector<std::string> enumerate() const
+ {
std::vector<std::string> paths;
- BOOST_FOREACH(const soft_regmap_accessor_t* regmap, _regmaps) {
+ BOOST_FOREACH (const soft_regmap_accessor_t* regmap, _regmaps) {
const std::vector<std::string>& regs = regmap->enumerate();
paths.insert(paths.end(), regs.begin(), regs.end());
}
- BOOST_FOREACH(const soft_regmap_accessor_t* db, _regmap_dbs) {
+ BOOST_FOREACH (const soft_regmap_accessor_t* db, _regmap_dbs) {
const std::vector<std::string>& regs = db->enumerate();
paths.insert(paths.end(), regs.begin(), regs.end());
}
@@ -668,12 +710,12 @@ public:
private:
typedef std::list<soft_regmap_accessor_t*> db_t;
- const std::string _name;
- db_t _regmaps;
- db_t _regmap_dbs;
- boost::mutex _mutex;
+ const std::string _name;
+ db_t _regmaps;
+ db_t _regmap_dbs;
+ boost::mutex _mutex;
};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_SOFT_REGISTER_HPP */
diff --git a/host/include/uhd/utils/static.hpp b/host/include/uhd/utils/static.hpp
index 3cde74b96..6a6f24721 100644
--- a/host/include/uhd/utils/static.hpp
+++ b/host/include/uhd/utils/static.hpp
@@ -16,21 +16,27 @@
* \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;}
+#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()
* The static block will catch and print exceptions to std error.
* \param _x the unique name of the fixture (unique per source)
*/
-#define UHD_STATIC_BLOCK(_x) \
- void _x(void); \
+#define UHD_STATIC_BLOCK(_x) \
+ void _x(void); \
static _uhd_static_fixture _x##_fixture(&_x, #_x); \
void _x(void)
//! Helper for static block, constructor calls function
-struct UHD_API _uhd_static_fixture{
- _uhd_static_fixture(void (*)(void), const char *);
+struct UHD_API _uhd_static_fixture
+{
+ _uhd_static_fixture(void (*)(void), const char*);
};
#endif /* INCLUDED_UHD_UTILS_STATIC_HPP */
diff --git a/host/include/uhd/utils/tasks.hpp b/host/include/uhd/utils/tasks.hpp
index d1245616c..5131fa028 100644
--- a/host/include/uhd/utils/tasks.hpp
+++ b/host/include/uhd/utils/tasks.hpp
@@ -10,35 +10,32 @@
#define INCLUDED_UHD_UTILS_TASKS_HPP
#include <uhd/config.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-namespace uhd{
+namespace uhd {
- class UHD_API task : boost::noncopyable{
- public:
- typedef boost::shared_ptr<task> sptr;
- typedef boost::function<void(void)> task_fcn_type;
+class UHD_API task : boost::noncopyable
+{
+public:
+ typedef boost::shared_ptr<task> sptr;
+ typedef boost::function<void(void)> task_fcn_type;
- /*!
- * Create a new task object with function callback.
- * The task function callback will be run in a loop.
- * until the thread is interrupted by the destructor.
- *
- * A task should return in a reasonable amount of time.
- * It may not block, or the destructor will also block.
- *
- * \param task_fcn the task callback function
- * \param name Task name. Will be used as a thread name.
- * \return a new task object
- */
- static sptr make(
- const task_fcn_type &task_fcn,
- const std::string &name=""
- );
- };
-} //namespace uhd
+ /*!
+ * Create a new task object with function callback.
+ * The task function callback will be run in a loop.
+ * until the thread is interrupted by the destructor.
+ *
+ * A task should return in a reasonable amount of time.
+ * It may not block, or the destructor will also block.
+ *
+ * \param task_fcn the task callback function
+ * \param name Task name. Will be used as a thread name.
+ * \return a new task object
+ */
+ static sptr make(const task_fcn_type& task_fcn, const std::string& name = "");
+};
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_TASKS_HPP */
-
diff --git a/host/include/uhd/utils/thread.hpp b/host/include/uhd/utils/thread.hpp
index 5251d341e..c7358040e 100644
--- a/host/include/uhd/utils/thread.hpp
+++ b/host/include/uhd/utils/thread.hpp
@@ -12,49 +12,42 @@
#include <boost/thread/thread.hpp>
#include <string>
-namespace uhd{
-
- static const float default_thread_priority = float(0.5);
-
- /*!
- * Set the scheduling priority on the current thread.
- *
- * A new thread or calling process should make this call
- * with the defaults 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.
- *
- * \param priority a value between -1 and 1
- * \param realtime true to use realtime mode
- * \throw exception on set priority failure
- */
- UHD_API void set_thread_priority(
- 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.
- * \return true on success, false on failure
- */
- UHD_API bool set_thread_priority_safe(
- float priority = default_thread_priority,
- bool realtime = true
- );
-
- /*!
- * Set the thread name on the given boost thread.
- * \param thread pointer to a boost thread
- * \param name thread name with maximum length of 16 characters
- */
- UHD_API void set_thread_name(
- boost::thread *thread,
- const std::string &name
- );
-
-} //namespace uhd
+namespace uhd {
+
+static const float default_thread_priority = float(0.5);
+
+/*!
+ * Set the scheduling priority on the current thread.
+ *
+ * A new thread or calling process should make this call
+ * with the defaults 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.
+ *
+ * \param priority a value between -1 and 1
+ * \param realtime true to use realtime mode
+ * \throw exception on set priority failure
+ */
+UHD_API void set_thread_priority(
+ 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.
+ * \return true on success, false on failure
+ */
+UHD_API bool set_thread_priority_safe(
+ float priority = default_thread_priority, bool realtime = true);
+
+/*!
+ * Set the thread name on the given boost thread.
+ * \param thread pointer to a boost thread
+ * \param name thread name with maximum length of 16 characters
+ */
+UHD_API void set_thread_name(boost::thread* thread, const std::string& name);
+
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_THREAD_HPP */