diff options
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/CMakeLists.txt | 4 | ||||
-rw-r--r-- | host/include/uhd/convert.hpp | 61 | ||||
-rw-r--r-- | host/include/uhd/deprecated.hpp | 76 | ||||
-rw-r--r-- | host/include/uhd/device.hpp | 123 | ||||
-rw-r--r-- | host/include/uhd/device_deprecated.ipp | 185 | ||||
-rw-r--r-- | host/include/uhd/stream.hpp | 198 | ||||
-rw-r--r-- | host/include/uhd/transport/vrt_if_packet.hpp | 1 | ||||
-rw-r--r-- | host/include/uhd/types/clock_config.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/types/io_type.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/types/otw_type.hpp | 71 | ||||
-rw-r--r-- | host/include/uhd/usrp/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_base.hpp | 62 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_manager.hpp | 24 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard_iface.hpp | 71 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 247 | ||||
-rw-r--r-- | host/include/uhd/usrp/single_usrp.hpp | 30 | ||||
-rw-r--r-- | host/include/uhd/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/utils/props.hpp | 81 | ||||
-rw-r--r-- | host/include/uhd/wax.hpp | 169 |
19 files changed, 729 insertions, 687 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 49562a7a0..1df04d577 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -24,12 +24,14 @@ ADD_SUBDIRECTORY(utils) INSTALL(FILES config.hpp convert.hpp + deprecated.hpp device.hpp + device_deprecated.ipp exception.hpp property_tree.ipp property_tree.hpp + stream.hpp version.hpp - wax.hpp DESTINATION ${INCLUDE_DIR}/uhd COMPONENT headers ) diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index 99f1860ae..c42edfdec 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -19,17 +19,18 @@ #define INCLUDED_UHD_CONVERT_HPP #include <uhd/config.hpp> -#include <uhd/types/io_type.hpp> -#include <uhd/types/otw_type.hpp> #include <uhd/types/ref_vector.hpp> #include <boost/function.hpp> +#include <boost/operators.hpp> #include <string> namespace uhd{ namespace convert{ typedef uhd::ref_vector<void *> output_type; typedef uhd::ref_vector<const void *> input_type; - typedef boost::function<void(const input_type&, const output_type&, size_t, double)> function_type; + + //! input vectors, output vectors, num samples, scale factor + typedef boost::function<void(const input_type&, const output_type&, const size_t, const double)> function_type; /*! * Describe the priority of a converter function. @@ -41,50 +42,54 @@ namespace uhd{ namespace convert{ enum priority_type{ PRIORITY_GENERAL = 0, PRIORITY_LIBORC = 1, - PRIORITY_CUSTOM = 2, + PRIORITY_SIMD = 2, + PRIORITY_CUSTOM = 3, PRIORITY_EMPTY = -1, }; + //! Identify a conversion routine in the registry + struct 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; + }; + + //! Implement equality_comparable interface + UHD_API bool operator==(const id_type &, const id_type &); + /*! - * Register a converter function that converts cpu type to/from otw type. - * \param markup representing the signature + * Register a converter function. + * \param id identify the conversion * \param fcn a pointer to the converter * \param prio the function priority */ UHD_API void register_converter( - const std::string &markup, + const id_type &id, function_type fcn, priority_type prio ); /*! - * Get a converter function that converts cpu to otw. - * \param io_type the type of the input samples - * \param otw_type the type of the output samples - * \param num_input_buffs the number of inputs - * \param num_output_buffs the number of outputs + * Get a converter function. + * \param id identify the conversion + * \return the converter function */ - UHD_API const function_type &get_converter_cpu_to_otw( - const io_type_t &io_type, - const otw_type_t &otw_type, - size_t num_input_buffs, - size_t num_output_buffs - ); + UHD_API function_type get_converter(const id_type &id); /*! - * Get a converter function that converts otw to cpu. - * \param io_type the type of the input samples - * \param otw_type the type of the output samples - * \param num_input_buffs the number of inputs - * \param num_output_buffs the number of outputs + * Register the size of a particular item. + * \param format the item format + * \param size the size in bytes */ - UHD_API const function_type &get_converter_otw_to_cpu( - const io_type_t &io_type, - const otw_type_t &otw_type, - size_t num_input_buffs, - size_t num_output_buffs + 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 #endif /* INCLUDED_UHD_CONVERT_HPP */ diff --git a/host/include/uhd/deprecated.hpp b/host/include/uhd/deprecated.hpp new file mode 100644 index 000000000..95cce58e9 --- /dev/null +++ b/host/include/uhd/deprecated.hpp @@ -0,0 +1,76 @@ +//---------------------------------------------------------------------- +//-- deprecated interfaces below, to be removed when the API is changed +//---------------------------------------------------------------------- + +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_TYPES_OTW_TYPE_HPP +#define INCLUDED_UHD_TYPES_OTW_TYPE_HPP + +#include <uhd/config.hpp> + +namespace uhd{ + + /*! + * Description for over-the-wire integers: + * The DSP units in the FPGA deal with signed 16-bit integers. + * The width and shift define the translation between OTW and DSP, + * defined by the following relation: otw_int = dsp_int >> shift + * + * Note: possible combinations of width, shift, and byteorder + * depend on the internals of the FPGA. Not all are supported! + */ + struct UHD_API otw_type_t{ + + /*! + * Width of an over-the-wire integer in bits. + */ + size_t width; //in bits + + /*! + * Shift of an over-the-wire integer in bits. + * otw_int = dsp_int >> shift + * dsp_int = otw_int << shift + */ + size_t shift; //in bits + + /*! + * Constants for byte order (borrowed from numpy's dtype) + */ + enum /*bo_t*/ { + BO_NATIVE = 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; + + otw_type_t(void); + }; + +} //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 diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index a6571d027..89c6332da 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -19,11 +19,9 @@ #define INCLUDED_UHD_DEVICE_HPP #include <uhd/config.hpp> +#include <uhd/stream.hpp> +#include <uhd/deprecated.hpp> #include <uhd/types/device_addr.hpp> -#include <uhd/types/metadata.hpp> -#include <uhd/types/io_type.hpp> -#include <uhd/types/ref_vector.hpp> -#include <uhd/wax.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> #include <boost/function.hpp> @@ -36,7 +34,7 @@ class property_tree; //forward declaration * The usrp device interface represents the usrp hardware. * The api allows for discovery, configuration, and streaming. */ -class UHD_API device : boost::noncopyable, public wax::obj{ +class UHD_API device : boost::noncopyable{ public: typedef boost::shared_ptr<device> sptr; @@ -78,116 +76,11 @@ public: */ static sptr make(const device_addr_t &hint, size_t which = 0); - /*! - * Send modes for the device send routine. - */ - enum send_mode_t{ - //! Tells the send routine to send the entire buffer - SEND_MODE_FULL_BUFF = 0, - //! Tells the send routine to return after one packet - SEND_MODE_ONE_PACKET = 1 - }; - - /*! - * Recv modes for the device recv routine. - */ - enum recv_mode_t{ - //! Tells the recv routine to recv the entire buffer - RECV_MODE_FULL_BUFF = 0, - //! Tells the recv routine to return after one packet - RECV_MODE_ONE_PACKET = 1 - }; - - //! Typedef for a pointer to a single, or a collection of send buffers - typedef ref_vector<const void *> send_buffs_type; - - //! Typedef for a pointer to a single, or a collection of recv buffers - typedef ref_vector<void *> recv_buffs_type; - - /*! - * Send buffers containing IF data described by the metadata. - * - * Send handles fragmentation as follows: - * If the buffer has more samples than the maximum per packet, - * the send method will fragment the samples across several packets. - * Send will respect the burst flags when fragmenting to ensure - * that start of burst can only be set on the first fragment and - * that end of burst can only be set on the final fragment. - * Fragmentation only applies in the full buffer send mode. - * - * This is a blocking call and will not return until the number - * of samples returned have been read out of each buffer. - * Under a timeout condition, the number of samples returned - * may be less than the number of samples specified. - * - * \param buffs a vector of read-only memory containing IF data - * \param nsamps_per_buff the number of samples to send, per buffer - * \param metadata data describing the buffer's contents - * \param io_type the type of data loaded in the buffer - * \param send_mode tells send how to unload the buffer - * \param timeout the timeout in seconds to wait on a packet - * \return the number of samples sent - */ - virtual size_t send( - const send_buffs_type &buffs, - size_t nsamps_per_buff, - const tx_metadata_t &metadata, - const io_type_t &io_type, - send_mode_t send_mode, - double timeout = 0.1 - ) = 0; + //! Make a new receive streamer from the streamer arguments + virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0; - /*! - * Receive buffers containing IF data described by the metadata. - * - * Receive handles fragmentation as follows: - * If the buffer has insufficient space to hold all samples - * that were received in a single packet over-the-wire, - * then the buffer will be completely filled and the implementation - * will hold a pointer into the remaining portion of the packet. - * Subsequent calls will load from the remainder of the packet, - * and will flag the metadata to show that this is a fragment. - * The next call to receive, after the remainder becomes exahausted, - * will perform an over-the-wire receive as usual. - * See the rx metadata fragment flags and offset fields for details. - * - * This is a blocking call and will not return until the number - * of samples returned have been written into each buffer. - * Under a timeout condition, the number of samples returned - * may be less than the number of samples specified. - * - * When using the full buffer recv mode, the metadata only applies - * to the first packet received and written into the recv buffers. - * Use the one packet recv mode to get per packet metadata. - * - * \param buffs a vector of writable memory to fill with IF data - * \param nsamps_per_buff the size of each buffer in number of samples - * \param metadata data to fill describing the buffer - * \param io_type the type of data to fill into the buffer - * \param recv_mode tells recv how to load the buffer - * \param timeout the timeout in seconds to wait for a packet - * \return the number of samples received or 0 on error - */ - virtual size_t recv( - const recv_buffs_type &buffs, - size_t nsamps_per_buff, - rx_metadata_t &metadata, - const io_type_t &io_type, - recv_mode_t recv_mode, - double timeout = 0.1 - ) = 0; - - /*! - * Get the maximum number of samples per packet on send. - * \return the number of samples - */ - virtual size_t get_max_send_samps_per_packet(void) const = 0; - - /*! - * Get the maximum number of samples per packet on recv. - * \return the number of samples - */ - virtual size_t get_max_recv_samps_per_packet(void) const = 0; + //! Make a new transmit streamer from the streamer arguments + virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0; /*! * Receive and asynchronous message from the device. @@ -202,6 +95,8 @@ public: //! Get access to the underlying property structure virtual boost::shared_ptr<property_tree> get_tree(void) const = 0; + #include <uhd/device_deprecated.ipp> + }; } //namespace uhd diff --git a/host/include/uhd/device_deprecated.ipp b/host/include/uhd/device_deprecated.ipp new file mode 100644 index 000000000..8e61c389f --- /dev/null +++ b/host/include/uhd/device_deprecated.ipp @@ -0,0 +1,185 @@ +// +// Copyright 2010-2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +//this file is included inside device class +//it supports the old send/recv functions +//this was replaced by the streamer API + +/*! + * Send modes for the device send routine. + */ +enum send_mode_t{ + //! Tells the send routine to send the entire buffer + SEND_MODE_FULL_BUFF = 0, + //! Tells the send routine to return after one packet + SEND_MODE_ONE_PACKET = 1 +}; + +/*! + * Recv modes for the device recv routine. + */ +enum recv_mode_t{ + //! Tells the recv routine to recv the entire buffer + RECV_MODE_FULL_BUFF = 0, + //! Tells the recv routine to return after one packet + RECV_MODE_ONE_PACKET = 1 +}; + +//! Typedef for a pointer to a single, or a collection of send buffers +typedef ref_vector<const void *> send_buffs_type; + +//! Typedef for a pointer to a single, or a collection of recv buffers +typedef ref_vector<void *> recv_buffs_type; + +/*! + * Send buffers containing IF data described by the metadata. + * + * Send handles fragmentation as follows: + * If the buffer has more samples than the maximum per packet, + * the send method will fragment the samples across several packets. + * Send will respect the burst flags when fragmenting to ensure + * that start of burst can only be set on the first fragment and + * that end of burst can only be set on the final fragment. + * Fragmentation only applies in the full buffer send mode. + * + * This is a blocking call and will not return until the number + * of samples returned have been read out of each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * \param buffs a vector of read-only memory containing IF data + * \param nsamps_per_buff the number of samples to send, per buffer + * \param metadata data describing the buffer's contents + * \param io_type the type of data loaded in the buffer + * \param send_mode tells send how to unload the buffer + * \param timeout the timeout in seconds to wait on a packet + * \return the number of samples sent + */ +size_t send( + const send_buffs_type &buffs, + size_t nsamps_per_buff, + const tx_metadata_t &metadata, + const io_type_t &io_type, + send_mode_t send_mode, + double timeout = 0.1 +){ + if (_tx_streamer.get() == NULL or _tx_streamer->get_num_channels() != buffs.size() or _send_tid != io_type.tid){ + _send_tid = io_type.tid; + _tx_streamer.reset(); //cleanup possible old one + stream_args_t args; + args.cpu_format = (_send_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; + args.otw_format = "sc16"; + for (size_t ch = 0; ch < buffs.size(); ch++) + args.channels.push_back(ch); //linear mapping + _tx_streamer = get_tx_stream(args); + } + const size_t nsamps = (send_mode == SEND_MODE_ONE_PACKET)? + std::min(nsamps_per_buff, get_max_send_samps_per_packet()) : + nsamps_per_buff; + return _tx_streamer->send(buffs, nsamps, metadata, timeout); +} + +/*! + * Receive buffers containing IF data described by the metadata. + * + * Receive handles fragmentation as follows: + * If the buffer has insufficient space to hold all samples + * that were received in a single packet over-the-wire, + * then the buffer will be completely filled and the implementation + * will hold a pointer into the remaining portion of the packet. + * Subsequent calls will load from the remainder of the packet, + * and will flag the metadata to show that this is a fragment. + * The next call to receive, after the remainder becomes exahausted, + * will perform an over-the-wire receive as usual. + * See the rx metadata fragment flags and offset fields for details. + * + * This is a blocking call and will not return until the number + * of samples returned have been written into each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * When using the full buffer recv mode, the metadata only applies + * to the first packet received and written into the recv buffers. + * Use the one packet recv mode to get per packet metadata. + * + * \param buffs a vector of writable memory to fill with IF data + * \param nsamps_per_buff the size of each buffer in number of samples + * \param metadata data to fill describing the buffer + * \param io_type the type of data to fill into the buffer + * \param recv_mode tells recv how to load the buffer + * \param timeout the timeout in seconds to wait for a packet + * \return the number of samples received or 0 on error + */ +size_t recv( + const recv_buffs_type &buffs, + size_t nsamps_per_buff, + rx_metadata_t &metadata, + const io_type_t &io_type, + recv_mode_t recv_mode, + double timeout = 0.1 +){ + if (_rx_streamer.get() == NULL or _rx_streamer->get_num_channels() != buffs.size() or _recv_tid != io_type.tid){ + _recv_tid = io_type.tid; + _rx_streamer.reset(); //cleanup possible old one + stream_args_t args; + args.cpu_format = (_recv_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; + args.otw_format = "sc16"; + for (size_t ch = 0; ch < buffs.size(); ch++) + args.channels.push_back(ch); //linear mapping + _rx_streamer = get_rx_stream(args); + } + const size_t nsamps = (recv_mode == RECV_MODE_ONE_PACKET)? + std::min(nsamps_per_buff, get_max_recv_samps_per_packet()) : + nsamps_per_buff; + return _rx_streamer->recv(buffs, nsamps, metadata, timeout); +} + +/*! + * Get the maximum number of samples per packet on send. + * \return the number of samples + */ +size_t get_max_send_samps_per_packet(void){ + if (_tx_streamer.get() == NULL){ + stream_args_t args; + args.cpu_format = "fc32"; + args.otw_format = "sc16"; + _tx_streamer = get_tx_stream(args); + _send_tid = io_type_t::COMPLEX_FLOAT32; + } + return _tx_streamer->get_max_num_samps(); +} + +/*! + * Get the maximum number of samples per packet on recv. + * \return the number of samples + */ +size_t get_max_recv_samps_per_packet(void){ + if (_rx_streamer.get() == NULL){ + stream_args_t args; + args.cpu_format = "fc32"; + args.otw_format = "sc16"; + _rx_streamer = get_rx_stream(args); + _recv_tid = io_type_t::COMPLEX_FLOAT32; + } + return _rx_streamer->get_max_num_samps(); +} + +private: + rx_streamer::sptr _rx_streamer; + io_type_t::tid_t _recv_tid; + tx_streamer::sptr _tx_streamer; + io_type_t::tid_t _send_tid; diff --git a/host/include/uhd/stream.hpp b/host/include/uhd/stream.hpp new file mode 100644 index 000000000..1f0332088 --- /dev/null +++ b/host/include/uhd/stream.hpp @@ -0,0 +1,198 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_STREAM_HPP +#define INCLUDED_UHD_STREAM_HPP + +#include <uhd/config.hpp> +#include <uhd/types/metadata.hpp> +#include <uhd/types/device_addr.hpp> +#include <uhd/types/ref_vector.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> +#include <vector> +#include <string> + +namespace uhd{ + +/*! + * A struct of parameters to construct a streamer. + * + * Note: + * Not all combinations of CPU and OTW format have conversion support. + * You may however write and register your own conversion routines. + */ +struct UHD_API stream_args_t{ + + //! Convenience constructor for streamer args + stream_args_t( + const std::string &cpu = "", + const std::string &otw = "" + ){ + cpu_format = cpu; + otw_format = otw; + } + + /*! + * The CPU format is a string that describes the format of host memory. + * Common CPU formats are: + * - fc32 - complex<float> + * - fc64 - complex<double> + * - sc16 - complex<int16_t> + * - sc8 - complex<int8_t> + * - f32 - float + * - f64 - double + * - s16 - int16_t + * - s8 - int8_t + */ + std::string cpu_format; + + /*! + * The OTW format is a string that describes the format over-the-wire. + * Common OTW format are: + * - sc16 - Q16 I16 + * - sc8 - Q8_1 I8_1 Q8_0 I8_0 + * - s16 - R16_1 R16_0 + * - s8 - R8_3 R8_2 R8_1 R8_0 + */ + std::string otw_format; + + /*! + * The args parameter is used to pass arbitrary key/value pairs. + * Possible keys used by args (depends on implementation): + * - scaler: 8sc converter scaling factor + * - function: magnitude or phase/magnitude + * - units: numeric units like counts or dBm + */ + device_addr_t args; + + /*! + * The channels is a list of channel numbers. + * Leave this blank to default to channel 0. + * Set channels for a multi-channel application. + * Channel mapping depends on the front-end selection. + */ + std::vector<size_t> channels; +}; + +/*! + * The RX streamer is the host interface to receiving samples. + * 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{ +public: + typedef boost::shared_ptr<rx_streamer> sptr; + + //! Get the number of channels associated with this streamer + virtual size_t get_num_channels(void) const = 0; + + //! Get the max number of samples per buffer per packet + 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; + + /*! + * Receive buffers containing samples described by the metadata. + * + * Receive handles fragmentation as follows: + * If the buffer has insufficient space to hold all samples + * that were received in a single packet over-the-wire, + * then the buffer will be completely filled and the implementation + * will hold a pointer into the remaining portion of the packet. + * Subsequent calls will load from the remainder of the packet, + * and will flag the metadata to show that this is a fragment. + * The next call to receive, after the remainder becomes exahausted, + * will perform an over-the-wire receive as usual. + * See the rx metadata fragment flags and offset fields for details. + * + * This is a blocking call and will not return until the number + * of samples returned have been written into each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * The one_packet option allows the user to guarantee that + * the call will return after a single packet has been processed. + * This may be useful to maintain packet boundaries in some cases. + * + * \param buffs a vector of writable memory to fill with samples + * \param nsamps_per_buff the size of each buffer in number of samples + * \param metadata data to fill describing the buffer + * \param timeout the timeout in seconds to wait for a packet + * \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, + const size_t nsamps_per_buff, + rx_metadata_t &metadata, + const double timeout = 0.1, + const bool one_packet = false + ) = 0; +}; + +/*! + * The TX streamer is the host interface to transmitting samples. + * 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{ +public: + typedef boost::shared_ptr<tx_streamer> sptr; + + //! Get the number of channels associated with this streamer + virtual size_t get_num_channels(void) const = 0; + + //! Get the max number of samples per buffer per packet + 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; + + /*! + * Send buffers containing samples described by the metadata. + * + * Send handles fragmentation as follows: + * If the buffer has more items than the maximum per packet, + * the send method will fragment the samples across several packets. + * Send will respect the burst flags when fragmenting to ensure + * that start of burst can only be set on the first fragment and + * that end of burst can only be set on the final fragment. + * + * This is a blocking call and will not return until the number + * of samples returned have been read out of each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * \param buffs a vector of read-only memory containing samples + * \param nsamps_per_buff the number of samples to send, per buffer + * \param metadata data describing the buffer's contents + * \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, + const size_t nsamps_per_buff, + const tx_metadata_t &metadata, + const double timeout = 0.1 + ) = 0; +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_STREAM_HPP */ diff --git a/host/include/uhd/transport/vrt_if_packet.hpp b/host/include/uhd/transport/vrt_if_packet.hpp index 51bd81bb1..1be480874 100644 --- a/host/include/uhd/transport/vrt_if_packet.hpp +++ b/host/include/uhd/transport/vrt_if_packet.hpp @@ -44,6 +44,7 @@ namespace vrt{ //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 diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp index 24bd96d14..27b312245 100644 --- a/host/include/uhd/types/clock_config.hpp +++ b/host/include/uhd/types/clock_config.hpp @@ -23,10 +23,13 @@ namespace uhd{ /*! - * Clock configuration settings: + * 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. */ diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp index ace643abc..967ad7908 100644 --- a/host/include/uhd/types/io_type.hpp +++ b/host/include/uhd/types/io_type.hpp @@ -23,8 +23,11 @@ namespace uhd{ /*! - * The Input/Output configuration struct: + * 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: diff --git a/host/include/uhd/types/otw_type.hpp b/host/include/uhd/types/otw_type.hpp index 11a6af38e..6dc634fc8 100644 --- a/host/include/uhd/types/otw_type.hpp +++ b/host/include/uhd/types/otw_type.hpp @@ -1,69 +1,2 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_TYPES_OTW_TYPE_HPP -#define INCLUDED_UHD_TYPES_OTW_TYPE_HPP - -#include <uhd/config.hpp> - -namespace uhd{ - - /*! - * Description for over-the-wire integers: - * The DSP units in the FPGA deal with signed 16-bit integers. - * The width and shift define the translation between OTW and DSP, - * defined by the following relation: otw_int = dsp_int >> shift - * - * Note: possible combinations of width, shift, and byteorder - * depend on the internals of the FPGA. Not all are supported! - */ - struct UHD_API otw_type_t{ - - /*! - * Width of an over-the-wire integer in bits. - */ - size_t width; //in bits - - /*! - * Shift of an over-the-wire integer in bits. - * otw_int = dsp_int >> shift - * dsp_int = otw_int << shift - */ - size_t shift; //in bits - - /*! - * Constants for byte order (borrowed from numpy's dtype) - */ - enum /*bo_t*/ { - BO_NATIVE = 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; - - otw_type_t(void); - }; - -} //namespace uhd - -#endif /* INCLUDED_UHD_TYPES_OTW_TYPE_HPP */ +//The OTW type API has been deprecated in favor of the streamer interface +#include <uhd/deprecated.hpp> diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index ba38a67ea..d7b936fc2 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -31,9 +31,7 @@ INSTALL(FILES subdev_spec.hpp ### interfaces ### - single_usrp.hpp multi_usrp.hpp - mboard_iface.hpp DESTINATION ${INCLUDE_DIR}/uhd/usrp COMPONENT headers diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp index 7e9557a95..31b3643c7 100644 --- a/host/include/uhd/usrp/dboard_base.hpp +++ b/host/include/uhd/usrp/dboard_base.hpp @@ -19,7 +19,7 @@ #define INCLUDED_UHD_USRP_DBOARD_BASE_HPP #include <uhd/config.hpp> -#include <uhd/wax.hpp> +#include <uhd/property_tree.hpp> #include <uhd/utils/pimpl.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> @@ -28,43 +28,6 @@ namespace uhd{ namespace usrp{ - /*! - * Possible subdev connection types: - * - * A complex subdevice is physically connected to both channels, - * which may be connected in one of two ways: IQ or QI (swapped). - * - * A real subdevice is only physically connected one channel, - * either only the I channel or only the Q channel. - */ - enum subdev_conn_t{ - SUBDEV_CONN_COMPLEX_IQ = 'C', - SUBDEV_CONN_COMPLEX_QI = 'c', - SUBDEV_CONN_REAL_I = 'R', - SUBDEV_CONN_REAL_Q = 'r' - }; - - /*! - * Possible device subdev properties - */ - enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_SENSOR, //ro, sensor_value_t - SUBDEV_PROP_SENSOR_NAMES, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, double - SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, double - SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_USE_LO_OFFSET, //ro, bool - SUBDEV_PROP_BANDWIDTH //rw, double - }; - /*! * A daughter board dboard_base class for all dboards. * Only other dboard dboard_base classes should inherit this. @@ -81,19 +44,14 @@ public: //structors dboard_base(ctor_args_t); - virtual ~dboard_base(void); - - //interface - virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; - virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; protected: std::string get_subdev_name(void); dboard_iface::sptr get_iface(void); dboard_id_t get_rx_id(void); dboard_id_t get_tx_id(void); + property_tree::sptr get_rx_subtree(void); + property_tree::sptr get_tx_subtree(void); private: UHD_PIMPL_DECL(impl) _impl; @@ -109,8 +67,6 @@ public: * Create a new xcvr dboard object, override in subclasses. */ xcvr_dboard_base(ctor_args_t); - - virtual ~xcvr_dboard_base(void); }; /*! @@ -123,12 +79,6 @@ public: * Create a new rx dboard object, override in subclasses. */ rx_dboard_base(ctor_args_t); - - virtual ~rx_dboard_base(void); - - //override here so the derived classes cannot - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); }; /*! @@ -141,12 +91,6 @@ public: * Create a new rx dboard object, override in subclasses. */ tx_dboard_base(ctor_args_t); - - virtual ~tx_dboard_base(void); - - //override here so the derived classes cannot - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); }; }} //namespace diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index 091769a5c..d3a3ffb5c 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -20,11 +20,12 @@ #include <uhd/config.hpp> #include <uhd/property_tree.hpp> -#include <uhd/utils/props.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_id.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> +#include <string> +#include <vector> namespace uhd{ namespace usrp{ @@ -37,11 +38,6 @@ class UHD_API dboard_manager : boost::noncopyable{ public: typedef boost::shared_ptr<dboard_manager> sptr; - //! It does what it says... - static void populate_prop_tree_from_subdev( - property_tree::sptr subtree, wax::obj subdev - ); - //dboard constructor (each dboard should have a ::make with this signature) typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t); @@ -57,7 +53,7 @@ public: const dboard_id_t &dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names = prop_names_t(1, "0") + const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0") ); /*! @@ -74,27 +70,25 @@ public: const dboard_id_t &tx_dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names = prop_names_t(1, "0") + const std::vector<std::string> &subdev_names = std::vector<std::string>(1, "0") ); /*! * Make a new dboard manager. * \param rx_dboard_id the id of the rx dboard * \param tx_dboard_id the id of the tx dboard + * \param gdboard_id the id of the grand-dboard * \param iface the custom dboard interface + * \param subtree the subtree to load with props * \return an sptr to the new dboard manager */ static sptr make( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, - dboard_iface::sptr iface + dboard_id_t gdboard_id, + dboard_iface::sptr iface, + property_tree::sptr subtree ); - - //dboard manager interface - virtual prop_names_t get_rx_subdev_names(void) = 0; - virtual prop_names_t get_tx_subdev_names(void) = 0; - virtual wax::obj get_rx_subdev(const std::string &subdev_name) = 0; - virtual wax::obj get_tx_subdev(const std::string &subdev_name) = 0; }; }} //namespace diff --git a/host/include/uhd/usrp/mboard_iface.hpp b/host/include/uhd/usrp/mboard_iface.hpp deleted file mode 100644 index bbee8f2de..000000000 --- a/host/include/uhd/usrp/mboard_iface.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_USRP_MBOARD_IFACE_HPP -#define INCLUDED_UHD_USRP_MBOARD_IFACE_HPP - -#include <uhd/types/serial.hpp> -#include <uhd/usrp/mboard_eeprom.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/utility.hpp> -#include <boost/cstdint.hpp> -#include <utility> -#include <string> - -namespace uhd{ namespace usrp{ - -/*! - * The mboard interface class: - * Provides a set of functions to implementation layer. - * Including spi, peek, poke, control... - */ -class mboard_iface : public uhd::i2c_iface, public uhd::spi_iface, public uhd::uart_iface { -public: - typedef boost::shared_ptr<mboard_iface> sptr; - /*! - * Write a register (32 bits) - * \param addr the address - * \param data the 32bit data - */ - virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0; - - /*! - * Read a register (32 bits) - * \param addr the address - * \return the 32bit data - */ - virtual boost::uint32_t peek32(boost::uint32_t addr) = 0; - - /*! - * Write a register (16 bits) - * \param addr the address - * \param data the 16bit data - */ - virtual void poke16(boost::uint32_t addr, boost::uint16_t data) = 0; - - /*! - * Read a register (16 bits) - * \param addr the address - * \return the 16bit data - */ - virtual boost::uint16_t peek16(boost::uint32_t addr) = 0; - -}; - -}} - -#endif //INCLUDED_UHD_USRP_DBOARD_IFACE_HPP diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 00d5dfe7c..5ea00565a 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -18,19 +18,27 @@ #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 UHD_USRP_MULTI_USRP_REF_SOURCES_API +#define UHD_USRP_MULTI_USRP_GET_RATES_API +#define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API +#define UHD_USRP_MULTI_USRP_COMMAND_TIME_API +#define UHD_USRP_MULTI_USRP_BW_RANGE_API + #include <uhd/config.hpp> #include <uhd/device.hpp> +#include <uhd/deprecated.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/stream_cmd.hpp> -#include <uhd/types/clock_config.hpp> #include <uhd/types/tune_request.hpp> #include <uhd/types/tune_result.hpp> #include <uhd/types/sensors.hpp> #include <uhd/usrp/subdev_spec.hpp> #include <uhd/usrp/dboard_iface.hpp> -#include <uhd/usrp/mboard_iface.hpp> #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> +#include <complex> +#include <string> #include <vector> namespace uhd{ namespace usrp{ @@ -47,7 +55,7 @@ namespace uhd{ namespace usrp{ * In the single device, single channel case, these parameters can be unspecified. * * When using a single device with multiple channels: - * - Channel mapping is determined by the subdevice specifications + * - Channel mapping is determined by the frontend specifications * - All channels share a common RX sample rate * - All channels share a common TX sample rate * @@ -55,8 +63,8 @@ namespace uhd{ namespace usrp{ * - Channel mapping is determined by the device address arguments * - All boards share a common RX sample rate * - All boards share a common TX sample rate - * - All boards share a common RX subdevice specification size - * - All boards share a common TX subdevice specification size + * - All boards share a common RX frontend specification size + * - All boards share a common TX frontend specification size * - All boards must have synchronized times (see the set_time_*() calls) * * Example to setup channel mapping for multiple devices: @@ -68,13 +76,13 @@ namespace uhd{ namespace usrp{ * dev_addr["addr1"] = "192.168.10.3"; * multi_usrp::sptr dev = multi_usrp::make(dev_addr); * - * //set the board on 10.2 to use the A RX subdevice (RX channel 0) + * //set the board on 10.2 to use the A RX frontend (RX channel 0) * dev->set_rx_subdev_spec("A:A", 0); * - * //set the board on 10.3 to use the B RX subdevice (RX channel 1) + * //set the board on 10.3 to use the B RX frontend (RX channel 1) * dev->set_rx_subdev_spec("A:B", 1); * - * //set both boards to use the AB TX subdevice (TX channels 0 and 1) + * //set both boards to use the AB TX frontend (TX channels 0 and 1) * dev->set_tx_subdev_spec("A:AB", multi_usrp::ALL_MBOARDS); * * //now that all the channels are mapped, continue with configuration... @@ -108,6 +116,16 @@ public: */ virtual device::sptr get_device(void) = 0; + //! Convenience method to get a RX streamer + rx_streamer::sptr get_rx_stream(const stream_args_t &args){ + return this->get_device()->get_rx_stream(args); + } + + //! Convenience method to get a TX streamer + tx_streamer::sptr get_tx_stream(const stream_args_t &args){ + return this->get_device()->get_tx_stream(args); + } + /******************************************************************* * Mboard methods ******************************************************************/ @@ -210,6 +228,25 @@ public: virtual bool get_time_synchronized(void) = 0; /*! + * Set the time at which the control commands will take effect. + * + * A timed command will back-pressure all subsequent timed commands, + * assuming that the subsequent commands occur within the time-window. + * If the time spec is late, the command will be activated upon arrival. + * + * \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; + + /*! + * Clear the command time so future commands are sent ASAP. + * + * \param mboard which motherboard to set the config + */ + virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0; + + /*! * Issue a stream command to the usrp device. * This tells the usrp to send samples into the host. * See the documentation for stream_cmd_t for more info. @@ -225,6 +262,7 @@ public: /*! * Set the clock configuration for the usrp device. + * DEPRECATED in favor of set time and clock source calls. * This tells the usrp how to get a 10Mhz reference and PPS clock. * See the documentation for clock_config_t for more info. * \param clock_config the clock configuration to set @@ -233,6 +271,53 @@ public: 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. + * This sets the method of time synchronization, + * typically a pulse per second or an encoded time. + * Typical options for source: external, MIMO. + * \param source a string representing the time source + * \param mboard which motherboard to set the config + */ + virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0; + + /*! + * Get the currently set time source. + * \param mboard which motherboard to get the config + * \return the string representing the time source + */ + virtual std::string get_time_source(const size_t mboard) = 0; + + /*! + * Get a list of possible time sources. + * \param mboard which motherboard to get the list + * \return a vector of strings for possible settings + */ + virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0; + + /*! + * Set the clock source for the usrp device. + * This sets the source for a 10 Mhz reference clock. + * Typical options for source: internal, external, MIMO. + * \param source a string representing the clock source + * \param mboard which motherboard to set the config + */ + virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0; + + /*! + * Get the currently set clock source. + * \param mboard which motherboard to get the config + * \return the string representing the clock source + */ + virtual std::string get_clock_source(const size_t mboard) = 0; + + /*! + * Get a list of possible clock sources. + * \param mboard which motherboard to get the list + * \return a vector of strings for possible settings + */ + virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0; + + /*! * Get the number of USRP motherboards in this configuration. */ virtual size_t get_num_mboards(void) = 0; @@ -251,30 +336,24 @@ public: * \return a vector of sensor names */ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; - - /*! - * Get a handle to the mboard_iface object which controls peripheral access. - * \return a mboard_iface::sptr object - */ - virtual mboard_iface::sptr get_mboard_iface(size_t mboard) = 0; /******************************************************************* * RX methods ******************************************************************/ /*! - * Set the RX subdevice specification: + * Set the RX frontend specification: * The subdev spec maps a physical part of a daughter-board to a channel number. * Set the subdev spec before calling into any methods with a channel number. * The subdev spec must be the same size across all motherboards. - * \param spec the new subdevice specification + * \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; /*! - * Get the RX subdevice specification. + * Get the RX frontend specification. * \param mboard the motherboard index 0 to M-1 - * \return the subdevice specification in use + * \return the frontend specification in use */ virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0; @@ -286,9 +365,9 @@ public: virtual size_t get_rx_num_channels(void) = 0; /*! - * Get the name of the RX subdevice. + * Get the name of the RX frontend. * \param chan the channel index 0 to N-1 - * \return the subdevice name + * \return the frontend name */ virtual std::string get_rx_subdev_name(size_t chan = 0) = 0; @@ -307,6 +386,13 @@ public: virtual double get_rx_rate(size_t chan = 0) = 0; /*! + * Get a range of possible RX rates. + * \param chan the channel index 0 to N-1 + * \return the meta range of rates + */ + virtual meta_range_t get_rx_rates(size_t chan = 0) = 0; + + /*! * Set the RX center frequency. * \param tune_request tune request instructions * \param chan the channel index 0 to N-1 @@ -381,28 +467,28 @@ public: virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0; /*! - * Select the RX antenna on the subdevice. + * Select the RX antenna on the frontend. * \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; /*! - * Get the selected RX antenna on the subdevice. + * Get the selected RX antenna on the frontend. * \param chan the channel index 0 to N-1 * \return the antenna name */ virtual std::string get_rx_antenna(size_t chan = 0) = 0; /*! - * Get a list of possible RX antennas on the subdevice. + * Get a list of possible RX antennas on the frontend. * \param chan the channel index 0 to N-1 * \return a vector of antenna names */ virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0; /*! - * Get the locked status of the LO on the subdevice. + * Get the locked status of the LO on the frontend. * \param chan the channel index 0 to N-1 * \return true for locked */ @@ -411,21 +497,28 @@ public: } /*! - * Set the RX bandwidth on the subdevice. + * Set the RX bandwidth on the frontend. * \param bandwidth the bandwidth in Hz * \param chan the channel index 0 to N-1 */ virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! - * Get the RX bandwidth on the subdevice. + * Get the RX bandwidth on the frontend. * \param chan the channel index 0 to N-1 * \return the bandwidth in Hz */ virtual double get_rx_bandwidth(size_t chan = 0) = 0; /*! - * Read the RSSI value on the RX subdevice. + * Get the range of the possible RX bandwidth settings. + * \param chan the channel index 0 to N-1 + * \return a range of bandwidths in Hz + */ + virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0; + + /*! + * Read the RSSI value on the RX frontend. * \param chan the channel index 0 to N-1 * \return the rssi in dB * \throw exception if RSSI readback not supported @@ -435,7 +528,7 @@ public: } /*! - * Get the dboard interface object for the RX subdevice. + * Get the dboard interface object for the RX frontend. * The dboard interface gives access to GPIOs, SPI, I2C, low-speed ADC and DAC. * Use at your own risk! * \param chan the channel index 0 to N-1 @@ -444,7 +537,7 @@ public: virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0; /*! - * Get an RX subdevice sensor value. + * Get an RX frontend sensor value. * \param name the name of the sensor * \param chan the channel index 0 to N-1 * \return a sensor value object @@ -452,29 +545,61 @@ public: virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0; /*! - * Get a list of possible RX subdevice sensor names. + * Get a list of possible RX frontend sensor names. * \param chan the channel index 0 to N-1 * \return a vector of sensor names */ virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0; + /*! + * Enable/disable the automatic RX DC offset correction. + * The automatic correction subtracts out the long-run average. + * + * When disabled, the averaging option operation is halted. + * Once halted, the average value will be held constant + * until the user re-enables the automatic correction + * or overrides the value by manually setting the offset. + * + * \param enb true to enable automatic DC offset correction + * \param chan the channel index 0 to N-1 + */ + virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0; + + /*! + * Set a constant RX DC offset value. + * The value is complex to control both I and Q. + * Only set this when automatic correction is disabled. + * \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; + + /*! + * Set the RX frontend IQ imbalance correction. + * Use this to adjust the magnitude and phase of I and Q. + * + * \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; + /******************************************************************* * TX methods ******************************************************************/ /*! - * Set the TX subdevice specification: + * Set the TX frontend specification: * The subdev spec maps a physical part of a daughter-board to a channel number. * Set the subdev spec before calling into any methods with a channel number. * The subdev spec must be the same size across all motherboards. - * \param spec the new subdevice specification + * \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; /*! - * Get the TX subdevice specification. + * Get the TX frontend specification. * \param mboard the motherboard index 0 to M-1 - * \return the subdevice specification in use + * \return the frontend specification in use */ virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0; @@ -486,9 +611,9 @@ public: virtual size_t get_tx_num_channels(void) = 0; /*! - * Get the name of the TX subdevice. + * Get the name of the TX frontend. * \param chan the channel index 0 to N-1 - * \return the subdevice name + * \return the frontend name */ virtual std::string get_tx_subdev_name(size_t chan = 0) = 0; @@ -507,6 +632,13 @@ public: virtual double get_tx_rate(size_t chan = 0) = 0; /*! + * Get a range of possible TX rates. + * \param chan the channel index 0 to N-1 + * \return the meta range of rates + */ + virtual meta_range_t get_tx_rates(size_t chan = 0) = 0; + + /*! * Set the TX center frequency. * \param tune_request tune request instructions * \param chan the channel index 0 to N-1 @@ -581,28 +713,28 @@ public: virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0; /*! - * Select the TX antenna on the subdevice. + * Select the TX antenna on the frontend. * \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; /*! - * Get the selected TX antenna on the subdevice. + * Get the selected TX antenna on the frontend. * \param chan the channel index 0 to N-1 * \return the antenna name */ virtual std::string get_tx_antenna(size_t chan = 0) = 0; /*! - * Get a list of possible TX antennas on the subdevice. + * Get a list of possible TX antennas on the frontend. * \param chan the channel index 0 to N-1 * \return a vector of antenna names */ virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0; /*! - * Get the locked status of the LO on the subdevice. + * Get the locked status of the LO on the frontend. * \param chan the channel index 0 to N-1 * \return true for locked */ @@ -611,21 +743,28 @@ public: } /*! - * Set the TX bandwidth on the subdevice. + * Set the TX bandwidth on the frontend. * \param bandwidth the bandwidth in Hz * \param chan the channel index 0 to N-1 */ virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! - * Get the TX bandwidth on the subdevice. + * Get the TX bandwidth on the frontend. * \param chan the channel index 0 to N-1 * \return the bandwidth in Hz */ virtual double get_tx_bandwidth(size_t chan = 0) = 0; /*! - * Get the dboard interface object for the TX subdevice. + * Get the range of the possible TX bandwidth settings. + * \param chan the channel index 0 to N-1 + * \return a range of bandwidths in Hz + */ + virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0; + + /*! + * Get the dboard interface object for the TX frontend. * The dboard interface gives access to GPIOs, SPI, I2C, low-speed ADC and DAC. * Use at your own risk! * \param chan the channel index 0 to N-1 @@ -634,7 +773,7 @@ public: virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0; /*! - * Get an TX subdevice sensor value. + * Get an TX frontend sensor value. * \param name the name of the sensor * \param chan the channel index 0 to N-1 * \return a sensor value object @@ -642,11 +781,29 @@ public: virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0; /*! - * Get a list of possible TX subdevice sensor names. + * Get a list of possible TX frontend sensor names. * \param chan the channel index 0 to N-1 * \return a vector of sensor names */ virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0; + + /*! + * Set a constant TX DC offset value. + * The value is complex to control both I and Q. + * \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; + + /*! + * Set the TX frontend IQ imbalance correction. + * Use this to adjust the magnitude and phase of I and Q. + * + * \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; + }; }} diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp deleted file mode 100644 index 0520db162..000000000 --- a/host/include/uhd/usrp/single_usrp.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_USRP_SINGLE_USRP_HPP -#define INCLUDED_UHD_USRP_SINGLE_USRP_HPP - -#include <uhd/usrp/multi_usrp.hpp> - -namespace uhd{ namespace usrp{ - - //! Multi-USRP is a superset of Single-USRP - typedef multi_usrp single_usrp; - -}} - -#endif /* INCLUDED_UHD_USRP_SINGLE_USRP_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 0bf98fb67..48b8db885 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -26,7 +26,6 @@ INSTALL(FILES log.hpp msg.hpp pimpl.hpp - props.hpp safe_call.hpp safe_main.hpp static.hpp diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp deleted file mode 100644 index 81737423a..000000000 --- a/host/include/uhd/utils/props.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_UTILS_PROPS_HPP -#define INCLUDED_UHD_UTILS_PROPS_HPP - -#include <uhd/config.hpp> -#include <uhd/wax.hpp> -#include <uhd/exception.hpp> -#include <vector> -#include <string> - -namespace uhd{ - - //! The type for a vector of property names - typedef std::vector<std::string> prop_names_t; - - /*! - * A named prop struct holds a key and a name. - * Allows properties to be sub-sectioned by name. - */ - struct UHD_API named_prop_t{ - const wax::obj key; - const std::string name; - - //! Convert the key to the specified type - template<typename T> inline T as(void){ - return key.as<T>(); - } - - /*! - * Utility function to convert generic key into a named prop. - * If the key was already a named prop, the prop will be split. - * Otherwise, the key will be the key, and the name will be used. - * \param key a reference to the prop object - * \param name a reference to the name object - * \return a named property struct with key and name - */ - static named_prop_t extract( - const wax::obj &key, const std::string &name = "" - ); - - /*! - * Create a new named prop from key and name. - * \param key the property key - * \param name the string name - */ - named_prop_t(const wax::obj &key, const std::string &name); - }; - - /*! - * Throw when getting a not-implemented or write-only property. - * Throw-site information will be included with this error. - */ - #define UHD_THROW_PROP_GET_ERROR() \ - throw uhd::key_error(UHD_THROW_SITE_INFO("cannot get this property")) - - /*! - * Throw when setting a not-implemented or read-only property. - * Throw-site information will be included with this error. - */ - #define UHD_THROW_PROP_SET_ERROR() \ - throw uhd::key_error(UHD_THROW_SITE_INFO("cannot set this property")) - -} //namespace uhd - -#endif /* INCLUDED_UHD_UTILS_PROPS_HPP */ diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp deleted file mode 100644 index 6fd2b8652..000000000 --- a/host/include/uhd/wax.hpp +++ /dev/null @@ -1,169 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_WAX_HPP -#define INCLUDED_WAX_HPP - -#include <uhd/config.hpp> -#include <uhd/exception.hpp> -#include <boost/any.hpp> -#include <typeinfo> -#include <string> - -/*! - * WAX - it's a metaphor! - * - * The WAX framework allows an object to have generic/anyobj properties. - * These properties can be addressed through generic/anyobj identifiers. - * - * The WAX object itself is an anytype container much like boost::any. - * To retrieve the value of the appropriate type, use my_obj.as<type>(). - * - * Proprties may be referenced though the [] overloaded operator. - * The [] operator returns a special proxy that allows for assigment. - * Also, the [] operators may be chained as in the folowing examples: - * my_obj[prop1][prop2][prop3] = value; - * value = my_obj[prop1][prop2][prop3].as<type>(); - * - * Property nesting occurs when a WAX object gets another object's link. - * This special link is obtained through a call to my_obj.get_link(). - * - * Note: Do not put a class derived from wax::obj into an stl container. - * MSVC will compile the code, but the binaries will crash at runtime. - * Rather, use pointers or smart pointers to instances of the derived class. - */ - -namespace wax{ - - /*! - * WAX object base class: - * - * A wax obj has two major purposes: - * 1) to act as a polymorphic container, just like boost any - * 2) to provide a nested set/get properties interface - * - * Internally, the polymorphic container is handled by a boost any. - * For properties, a subclass should override the set and get methods. - * For property nesting, wax obj subclasses return special links - * to other wax obj subclasses, and the api handles the magic. - */ - class UHD_API obj{ - public: - - /*! - * Default constructor: - * The contents will be empty. - */ - obj(void); - - /*! - * Copy constructor: - * The contents will be cloned. - * \param o another wax::obj - */ - obj(const obj &o); - - /*! - * Templated any type constructor: - * The contents can be anything. - * Uses the boost::any to handle the magic. - * \param o an object of any type - */ - template<class T> obj(const T &o){ - _contents = o; - } - - /*! - * Destructor. - */ - virtual ~obj(void); - - /*! - * The chaining operator: - * This operator allows access objs with properties. - * A call to the [] operator will return a new proxy obj. - * The proxy object is an obj with special proxy contents. - * Assignment and casting can be used on this special object - * to access the property referenced by the obj key. - * \param key a key to identify a property within this obj - * \return a special wax obj that proxies the obj and key - */ - obj operator[](const obj &key); - - /*! - * The assignment operator: - * This operator allows for assignment of new contents. - * In the special case where this obj contains a proxy, - * the value will be set to the proxy's property reference. - * \param val the new value to assign to the wax obj - * \return a reference to this obj (*this) - */ - obj & operator=(const obj &val); - - /*! - * Get a link in the chain: - * When a wax obj returns another wax obj as part of a get call, - * the return value should be set to the result of this method. - * Doing so will ensure chain-ability of the returned object. - * \return an obj containing a valid link to a wax obj - */ - obj get_link(void) const; - - /*! - * Get the type of the contents of this obj. - * \return a reference to the type_info - */ - const std::type_info & type(void) const; - - /*! - * Cast this obj into the desired type. - * Usage: myobj.as<type>() - * - * \return an object of the desired type - * \throw wax::bad_cast when the cast fails - */ - template<class T> T as(void) const{ - try{ - return boost::any_cast<T>(resolve()); - } - catch(const boost::bad_any_cast &e){ - throw uhd::type_error(std::string("") + "Cannot wax cast " + type().name() + " to " + typeid(T).name() + " " + e.what()); - } - } - - private: - //private interface (override in subclasses) - virtual void get(const obj &, obj &); - virtual void set(const obj &, const obj &); - - /*! - * Resolve the contents of this obj. - * In the case where this obj is a proxy, - * the referenced property will be resolved. - * Otherwise, just get the private contents. - * \return a boost any type with contents - */ - boost::any resolve(void) const; - - //private contents of this obj - boost::any _contents; - - }; - -} //namespace wax - -#endif /* INCLUDED_WAX_HPP */ |