summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-27 08:07:45 -0700
committerJosh Blum <josh@joshknows.com>2010-10-27 08:07:45 -0700
commit4fb937339bbe95091b5a22276d9618dc8e178f68 (patch)
tree61a604de6ab352bfe3d90fdc77e0d92ea8501bfc /host/include
parentdb0e3e574e9058ad51cacea91ccc42f0baed95fa (diff)
parenta7840ebb3f7d7f807d05059e2809eb45cff04899 (diff)
downloaduhd-4fb937339bbe95091b5a22276d9618dc8e178f68.tar.gz
uhd-4fb937339bbe95091b5a22276d9618dc8e178f68.tar.bz2
uhd-4fb937339bbe95091b5a22276d9618dc8e178f68.zip
Merge branch 'next' into usrp_e
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/CMakeLists.txt2
-rw-r--r--host/include/uhd/types/dict.hpp78
-rw-r--r--host/include/uhd/types/dict.ipp120
-rw-r--r--host/include/uhd/types/metadata.hpp76
-rw-r--r--host/include/uhd/types/tune_request.hpp95
-rw-r--r--host/include/uhd/usrp/dboard_id.hpp6
-rw-r--r--host/include/uhd/usrp/mimo_usrp.hpp20
-rw-r--r--host/include/uhd/usrp/misc_utils.hpp3
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp120
-rw-r--r--host/include/uhd/usrp/simple_usrp.hpp18
-rw-r--r--host/include/uhd/usrp/single_usrp.hpp122
-rw-r--r--host/include/uhd/usrp/tune_helper.hpp31
-rw-r--r--host/include/uhd/utils/gain_group.hpp43
-rw-r--r--host/include/uhd/utils/warning.hpp36
14 files changed, 529 insertions, 241 deletions
diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt
index dbce21c98..a96976b5e 100644
--- a/host/include/uhd/types/CMakeLists.txt
+++ b/host/include/uhd/types/CMakeLists.txt
@@ -19,6 +19,7 @@
INSTALL(FILES
clock_config.hpp
device_addr.hpp
+ dict.ipp
dict.hpp
io_type.hpp
mac_addr.hpp
@@ -28,6 +29,7 @@ INSTALL(FILES
serial.hpp
stream_cmd.hpp
time_spec.hpp
+ tune_request.hpp
tune_result.hpp
DESTINATION ${INCLUDE_DIR}/uhd/types
)
diff --git a/host/include/uhd/types/dict.hpp b/host/include/uhd/types/dict.hpp
index de96ea768..b14fc5425 100644
--- a/host/include/uhd/types/dict.hpp
+++ b/host/include/uhd/types/dict.hpp
@@ -19,11 +19,6 @@
#define INCLUDED_UHD_TYPES_DICT_HPP
#include <uhd/config.hpp>
-#include <boost/foreach.hpp>
-#include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
-#include <stdexcept>
-#include <typeinfo>
#include <vector>
#include <list>
@@ -34,14 +29,10 @@ namespace uhd{
*/
template <typename Key, typename Val> class dict{
public:
- typedef std::pair<Key, Val> pair_t;
-
/*!
* Create a new empty dictionary.
*/
- dict(void){
- /* NOP */
- }
+ dict(void);
/*!
* Input iterator constructor:
@@ -50,64 +41,34 @@ namespace uhd{
* \param last the end iterator
*/
template <typename InputIterator>
- dict(InputIterator first, InputIterator last){
- for(InputIterator it = first; it != last; it++){
- _map.push_back(*it);
- }
- }
-
- /*!
- * Destroy this dict.
- */
- ~dict(void){
- /* NOP */
- }
+ dict(InputIterator first, InputIterator last);
/*!
* Get the number of elements in this dict.
* \return the number of elements
*/
- std::size_t size(void) const{
- return _map.size();
- }
+ 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
*/
- const std::vector<Key> keys(void) const{
- std::vector<Key> keys;
- BOOST_FOREACH(const pair_t &p, _map){
- keys.push_back(p.first);
- }
- return keys;
- }
+ const 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
*/
- const std::vector<Val> vals(void) const{
- std::vector<Val> vals;
- BOOST_FOREACH(const pair_t &p, _map){
- vals.push_back(p.second);
- }
- return vals;
- }
+ const 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{
- BOOST_FOREACH(const pair_t &p, _map){
- if (p.first == key) return true;
- }
- return false;
- }
+ bool has_key(const Key &key) const;
/*!
* Get a value for the given key if it exists.
@@ -116,15 +77,7 @@ namespace uhd{
* \return the value at the key
* \throw an exception when not found
*/
- const Val &operator[](const Key &key) const{
- BOOST_FOREACH(const pair_t &p, _map){
- if (p.first == key) return p.second;
- }
- throw std::invalid_argument(str(boost::format(
- "key \"%s\" not found in dict(%s, %s)"
- ) % boost::lexical_cast<std::string>(key)
- % typeid(Key).name() % typeid(Val).name()));
- }
+ const Val &operator[](const Key &key) const;
/*!
* Set a value for the given key, however, in reality
@@ -132,13 +85,7 @@ namespace uhd{
* \param key the key to set to
* \return a reference to the value
*/
- Val &operator[](const Key &key){
- BOOST_FOREACH(pair_t &p, _map){
- if (p.first == key) return p.second;
- }
- _map.push_back(std::make_pair(key, Val()));
- return _map.back().second;
- }
+ Val &operator[](const Key &key);
/*!
* Pop an item out of the dictionary.
@@ -146,16 +93,15 @@ namespace uhd{
* \return the value of the item
* \throw an exception when not found
*/
- Val pop(const Key &key){
- Val val = (*this)[key];
- _map.remove(pair_t(key, val));
- return val;
- }
+ Val pop(const Key &key);
private:
+ typedef std::pair<Key, Val> pair_t;
std::list<pair_t> _map; //private container
};
} //namespace uhd
+#include <uhd/types/dict.ipp>
+
#endif /* INCLUDED_UHD_TYPES_DICT_HPP */
diff --git a/host/include/uhd/types/dict.ipp b/host/include/uhd/types/dict.ipp
new file mode 100644
index 000000000..85071e6fd
--- /dev/null
+++ b/host/include/uhd/types/dict.ipp
@@ -0,0 +1,120 @@
+//
+// 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_DICT_IPP
+#define INCLUDED_UHD_TYPES_DICT_IPP
+
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
+#include <boost/lexical_cast.hpp>
+#include <stdexcept>
+#include <typeinfo>
+
+namespace uhd{
+
+ namespace /*anon*/{
+ template<typename Key, typename Val>
+ struct UHD_API key_not_found: std::out_of_range{
+ key_not_found(const Key &key): std::out_of_range(
+ str(boost::format(
+ "key \"%s\" not found in dict(%s, %s)"
+ ) % boost::lexical_cast<std::string>(key)
+ % typeid(Key).name() % typeid(Val).name()
+ )
+ ){
+ /* NOP */
+ }
+ };
+ } // namespace /*anon*/
+
+ template <typename Key, typename Val>
+ dict<Key, Val>::dict(void){
+ /* NOP */
+ }
+
+ template <typename Key, typename Val>
+ template <typename InputIterator>
+ dict<Key, Val>::dict(InputIterator first, InputIterator last){
+ for(InputIterator it = first; it != last; it++){
+ _map.push_back(*it);
+ }
+ }
+
+ template <typename Key, typename Val>
+ std::size_t dict<Key, Val>::size(void) const{
+ return _map.size();
+ }
+
+ template <typename Key, typename Val>
+ const std::vector<Key> dict<Key, Val>::keys(void) const{
+ std::vector<Key> keys;
+ BOOST_FOREACH(const pair_t &p, _map){
+ keys.push_back(p.first);
+ }
+ return keys;
+ }
+
+ template <typename Key, typename Val>
+ const std::vector<Val> dict<Key, Val>::vals(void) const{
+ std::vector<Val> vals;
+ BOOST_FOREACH(const pair_t &p, _map){
+ vals.push_back(p.second);
+ }
+ return vals;
+ }
+
+ template <typename Key, typename Val>
+ bool dict<Key, Val>::has_key(const Key &key) const{
+ BOOST_FOREACH(const pair_t &p, _map){
+ if (p.first == key) return true;
+ }
+ return false;
+ }
+
+ template <typename Key, typename Val>
+ const Val &dict<Key, Val>::operator[](const Key &key) const{
+ BOOST_FOREACH(const pair_t &p, _map){
+ if (p.first == key) return p.second;
+ }
+ throw key_not_found<Key, Val>(key);
+ }
+
+ template <typename Key, typename Val>
+ Val &dict<Key, Val>::operator[](const Key &key){
+ BOOST_FOREACH(pair_t &p, _map){
+ if (p.first == key) return p.second;
+ }
+ _map.push_back(std::make_pair(key, Val()));
+ return _map.back().second;
+ }
+
+ template <typename Key, typename Val>
+ Val dict<Key, Val>::pop(const Key &key){
+ typename std::list<pair_t>::iterator it;
+ for (it = _map.begin(); it != _map.end(); it++){
+ if (it->first == key){
+ Val val = it->second;
+ _map.erase(it);
+ return val;
+ }
+ }
+ throw key_not_found<Key, Val>(key);
+ }
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_DICT_IPP */
diff --git a/host/include/uhd/types/metadata.hpp b/host/include/uhd/types/metadata.hpp
index 65952941c..3f250d13e 100644
--- a/host/include/uhd/types/metadata.hpp
+++ b/host/include/uhd/types/metadata.hpp
@@ -19,7 +19,6 @@
#define INCLUDED_UHD_TYPES_METADATA_HPP
#include <uhd/config.hpp>
-#include <boost/cstdint.hpp>
#include <uhd/types/time_spec.hpp>
namespace uhd{
@@ -30,58 +29,59 @@ namespace uhd{
* The receive routines will convert IF data headers into metadata.
*/
struct UHD_API rx_metadata_t{
- /*!
- * Time specification:
- * Set from timestamps on incoming data when provided.
- */
+ //! Has time specification?
bool has_time_spec;
+
+ //! Time of the first sample.
time_spec_t time_spec;
/*!
- * Fragmentation flag and offset:
+ * 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.
- * 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.
*/
bool more_fragments;
- size_t fragment_offset;
/*!
- * Burst flags:
- * Start of burst will be true for the first packet in the chain.
- * End of burst will be true for the last packet in the chain.
+ * 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;
+
+ //! End of burst will be true for the last packet in the chain.
bool end_of_burst;
/*!
- * Error conditions:
- * - none: no error associated with this metadata
- * - timeout: no packet received, underlying code timed-out
- * - late command: a stream command was issued in the past
- * - broken chain: expected another stream command
- * - overflow: an internal receive buffer has filled
- * - bad packet: the buffer was unrecognizable as a vrt packet
+ * 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.
*
- * Note: The metadata fields have meaning for the following error codes:
+ * 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.
ERROR_CODE_OVERFLOW = 0x8,
+ //! The packet could not be parsed.
ERROR_CODE_BAD_PACKET = 0xf
} error_code;
};
@@ -93,19 +93,19 @@ namespace uhd{
*/
struct UHD_API tx_metadata_t{
/*!
- * Time specification:
- * Set has time spec to false to perform a send "now".
- * Or, set to true, and fill in time spec for a send "at".
+ * Has time specification?
+ * - Set false to send immediately.
+ * - Set true to send at the time specified by time spec.
*/
bool has_time_spec;
+
+ //! When to send the first sample.
time_spec_t time_spec;
- /*!
- * Burst flags:
- * Set start of burst to true for the first packet in the chain.
- * Set end of burst to true for the last packet in the chain.
- */
+ //! Set start of burst to true for the first packet in the chain.
bool start_of_burst;
+
+ //! Set end of burst to true for the last packet in the chain.
bool end_of_burst;
/*!
@@ -122,27 +122,27 @@ namespace uhd{
//! The channel number in a mimo configuration
size_t channel;
- /*!
- * Time specification: when the async event occurred.
- */
+ //! Has time specification?
bool has_time_spec;
+
+ //! When the async event occurred.
time_spec_t time_spec;
/*!
- * Event codes:
- * - success: a packet was successfully transmitted
- * - underflow: an internal send buffer has emptied
- * - sequence error: packet loss between host and device
- * - time error: packet had time that was late (or too early)
- * - underflow in packet: underflow occurred inside a packet
- * - sequence error in burst: packet loss within a burst
+ * The type of event for a receive async message call.
*/
enum event_code_t {
+ //! A packet was successfully transmitted.
EVENT_CODE_SUCCESS = 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 (or too early).
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
} event_code;
};
diff --git a/host/include/uhd/types/tune_request.hpp b/host/include/uhd/types/tune_request.hpp
new file mode 100644
index 000000000..942b93251
--- /dev/null
+++ b/host/include/uhd/types/tune_request.hpp
@@ -0,0 +1,95 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_TUNE_REQUEST_HPP
+#define INCLUDED_UHD_TYPES_TUNE_REQUEST_HPP
+
+#include <uhd/config.hpp>
+
+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.
+ */
+ struct UHD_API tune_request_t{
+ /*!
+ * Make a new tune request for a particular center frequency.
+ * Use an automatic policy for the intermediate 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 intermediate 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);
+
+ //! Policy options for tunable elements in the RF chain.
+ enum policy_t {
+ //! Do not set this argument, use current setting.
+ POLICY_NONE = 'N',
+ //! Automatically determine the argument's value.
+ POLICY_AUTO = 'A',
+ //! Use the argument's value for the setting.
+ POLICY_MANUAL = 'M'
+ };
+
+ /*!
+ * The target frequency of the overall chain in Hz.
+ * Set this even if all policies are set to manual.
+ */
+ double target_freq;
+
+ /*!
+ * The policy for the intermediate frequency.
+ * Automatic behavior: the target frequency + default LO offset.
+ */
+ policy_t inter_freq_policy;
+
+ /*!
+ * The intermediate frequency in Hz.
+ * Set when the policy is set to manual.
+ */
+ double inter_freq;
+
+ /*!
+ * The policy for the DSP frequency.
+ * Automatic behavior: the difference between the target and IF.
+ */
+ policy_t dsp_freq_policy;
+
+ /*!
+ * The DSP frequency in Hz.
+ * Set when the policy is set to manual.
+ */
+ double dsp_freq;
+
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_TUNE_REQUEST_HPP */
diff --git a/host/include/uhd/usrp/dboard_id.hpp b/host/include/uhd/usrp/dboard_id.hpp
index 4c45e4334..1fda8182e 100644
--- a/host/include/uhd/usrp/dboard_id.hpp
+++ b/host/include/uhd/usrp/dboard_id.hpp
@@ -67,6 +67,12 @@ namespace uhd{ namespace usrp{
std::string to_string(void) const;
/*!
+ * Get the dboard id represented as a canonical name.
+ * \return the canonical string representation
+ */
+ std::string to_cname(void) const;
+
+ /*!
* Get the pretty print representation of this dboard id.
* \return a string with the dboard name and id number
*/
diff --git a/host/include/uhd/usrp/mimo_usrp.hpp b/host/include/uhd/usrp/mimo_usrp.hpp
index 78833e24e..a2092f04f 100644
--- a/host/include/uhd/usrp/mimo_usrp.hpp
+++ b/host/include/uhd/usrp/mimo_usrp.hpp
@@ -127,7 +127,7 @@ public:
virtual double get_rx_rate_all(void) = 0;
virtual tune_result_t set_rx_freq(size_t chan, double freq) = 0;
- virtual tune_result_t set_rx_freq(size_t chan, double freq, double lo_off) = 0;
+ //virtual tune_result_t set_rx_freq(size_t chan, double freq, double lo_off) = 0;
virtual double get_rx_freq(size_t chan) = 0;
virtual freq_range_t get_rx_freq_range(size_t chan) = 0;
@@ -161,7 +161,7 @@ public:
virtual double get_tx_rate_all(void) = 0;
virtual tune_result_t set_tx_freq(size_t chan, double freq) = 0;
- virtual tune_result_t set_tx_freq(size_t chan, double freq, double lo_off) = 0;
+ //virtual tune_result_t set_tx_freq(size_t chan, double freq, double lo_off) = 0;
virtual double get_tx_freq(size_t chan) = 0;
virtual freq_range_t get_tx_freq_range(size_t chan) = 0;
@@ -298,7 +298,7 @@ public:
time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
time_spec_t time_i = _mboard(chan)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)){ //10 ms: greater than RTT but not too big
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"Detected time deviation between board %d and board 0.\n"
"Board 0 time is %f seconds.\n"
"Board %d time is %f seconds.\n"
@@ -345,9 +345,9 @@ public:
return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0, target_freq);
}
- tune_result_t set_rx_freq(size_t chan, double target_freq, double lo_off){
- return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0, target_freq, lo_off);
- }
+ //tune_result_t set_rx_freq(size_t chan, double target_freq, double lo_off){
+ // return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0, target_freq, lo_off);
+ //}
double get_rx_freq(size_t chan){
return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), 0);
@@ -425,9 +425,9 @@ public:
return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0, target_freq);
}
- tune_result_t set_tx_freq(size_t chan, double target_freq, double lo_off){
- return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0, target_freq, lo_off);
- }
+ //tune_result_t set_tx_freq(size_t chan, double target_freq, double lo_off){
+ // return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0, target_freq, lo_off);
+ //}
double get_tx_freq(size_t chan){
return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), 0);
@@ -512,7 +512,7 @@ namespace uhd{ namespace usrp{
* The Make Function
**********************************************************************/
inline mimo_usrp::sptr mimo_usrp::make(const device_addr_t &dev_addr){
- uhd::print_warning(
+ uhd::warning::post(
"The mimo USRP interface has been deprecated.\n"
"Please switch to the multi USRP interface.\n"
"#include <uhd/usrp/multi_usrp.hpp>\n"
diff --git a/host/include/uhd/usrp/misc_utils.hpp b/host/include/uhd/usrp/misc_utils.hpp
index 2af9f5b40..37860a1a5 100644
--- a/host/include/uhd/usrp/misc_utils.hpp
+++ b/host/include/uhd/usrp/misc_utils.hpp
@@ -20,6 +20,7 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
+#include <uhd/usrp/dboard_id.hpp>
#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/utils/gain_group.hpp>
@@ -35,11 +36,13 @@ namespace uhd{ namespace usrp{
/*!
* Create a gain group that represents the subdevice and its codec.
+ * \param dboard_id the dboard id for this subdevice
* \param subdev the object with subdevice properties
* \param codec the object with codec properties
* \param gain_group_policy the policy to use
*/
UHD_API gain_group::sptr make_gain_group(
+ const dboard_id_t &dboard_id,
wax::obj subdev, wax::obj codec,
gain_group_policy_t gain_group_policy
);
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 6adba85bd..5380d177d 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -23,6 +23,7 @@
#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/usrp/subdev_spec.hpp>
#include <uhd/usrp/dboard_iface.hpp>
@@ -73,6 +74,9 @@ public:
//! A wildcard motherboard index
static const size_t ALL_MBOARDS = size_t(~0);
+ //! A wildcard gain element name
+ static const std::string ALL_GAINS;
+
/*!
* Make a new multi usrp from the device address.
* \param dev_addr the device address
@@ -210,20 +214,13 @@ public:
/*!
* Set the RX center frequency.
- * \param freq the frequency in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result object
- */
- virtual tune_result_t set_rx_freq(double freq, size_t chan) = 0;
-
- /*!
- * Set the RX center frequency.
- * \param freq the frequency in Hz
- * \param lo_off an LO offset in Hz
+ * \param tune_request tune request instructions
* \param chan the channel index 0 to N-1
* \return a tune result object
*/
- virtual tune_result_t set_rx_freq(double freq, double lo_off, size_t chan) = 0;
+ virtual tune_result_t set_rx_freq(
+ const tune_request_t &tune_request, size_t chan = 0
+ ) = 0;
/*!
* Get the RX center frequency.
@@ -240,27 +237,54 @@ public:
virtual freq_range_t get_rx_freq_range(size_t chan) = 0;
/*!
- * Set the RX gain:
- * Distribute among gain elements in the RX path.
+ * Set the RX gain value for the specified gain element.
+ * For an empty name, distribute across all gain elements.
* \param gain the gain in dB
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain(float gain, size_t chan) = 0;
+ virtual void set_rx_gain(float gain, const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for setting overall RX gain
+ void set_rx_gain(float gain, size_t chan){
+ return this->set_rx_gain(gain, ALL_GAINS, chan);
+ }
/*!
- * Get the RX gain:
- * Summation of gain elements in the RX path.
+ * Get the RX gain value for the specified gain element.
+ * For an empty name, sum across all gain elements.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_rx_gain(size_t chan) = 0;
+ virtual float get_rx_gain(const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for getting overall RX gain
+ float get_rx_gain(size_t chan){
+ return this->get_rx_gain(ALL_GAINS, chan);
+ }
/*!
- * Get the RX gain range.
+ * Get the RX gain range for the specified gain element.
+ * For an empty name, calculate the overall gain range.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_rx_gain_range(size_t chan) = 0;
+ virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for getting overall RX gain range
+ gain_range_t get_rx_gain_range(size_t chan){
+ return this->get_rx_gain_range(ALL_GAINS, chan);
+ }
+
+ /*!
+ * Get the names of the gain elements in the RX chain.
+ * Gain elements are ordered from antenna to FPGA.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of gain element names
+ */
+ virtual std::vector<std::string> get_rx_gain_names(size_t chan) = 0;
/*!
* Select the RX antenna on the subdevice.
@@ -369,20 +393,13 @@ public:
/*!
* Set the TX center frequency.
- * \param freq the frequency in Hz
+ * \param tune_request tune request instructions
* \param chan the channel index 0 to N-1
* \return a tune result object
*/
- virtual tune_result_t set_tx_freq(double freq, size_t chan) = 0;
-
- /*!
- * Set the TX center frequency.
- * \param freq the frequency in Hz
- * \param lo_off an LO offset in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result object
- */
- virtual tune_result_t set_tx_freq(double freq, double lo_off, size_t chan) = 0;
+ virtual tune_result_t set_tx_freq(
+ const tune_request_t &tune_request, size_t chan = 0
+ ) = 0;
/*!
* Get the TX center frequency.
@@ -399,27 +416,54 @@ public:
virtual freq_range_t get_tx_freq_range(size_t chan) = 0;
/*!
- * Set the TX gain:
- * Distribute among gain elements in the TX path.
+ * Set the TX gain value for the specified gain element.
+ * For an empty name, distribute across all gain elements.
* \param gain the gain in dB
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain(float gain, size_t chan) = 0;
+ virtual void set_tx_gain(float gain, const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for setting overall TX gain
+ void set_tx_gain(float gain, size_t chan){
+ return this->set_tx_gain(gain, ALL_GAINS, chan);
+ }
/*!
- * Get the TX gain:
- * Summation of gain elements in the TX path.
+ * Get the TX gain value for the specified gain element.
+ * For an empty name, sum across all gain elements.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_tx_gain(size_t chan) = 0;
+ virtual float get_tx_gain(const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for getting overall TX gain
+ float get_tx_gain(size_t chan){
+ return this->get_tx_gain(ALL_GAINS, chan);
+ }
/*!
- * Get the TX gain range.
+ * Get the TX gain range for the specified gain element.
+ * For an empty name, calculate the overall gain range.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_tx_gain_range(size_t chan) = 0;
+ virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan) = 0;
+
+ //! A convenience wrapper for getting overall TX gain range
+ gain_range_t get_tx_gain_range(size_t chan){
+ return this->get_tx_gain_range(ALL_GAINS, chan);
+ }
+
+ /*!
+ * Get the names of the gain elements in the TX chain.
+ * Gain elements are ordered from antenna to FPGA.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of gain element names
+ */
+ virtual std::vector<std::string> get_tx_gain_names(size_t chan) = 0;
/*!
* Select the TX antenna on the subdevice.
diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp
index 22f4d64ba..77416dbbd 100644
--- a/host/include/uhd/usrp/simple_usrp.hpp
+++ b/host/include/uhd/usrp/simple_usrp.hpp
@@ -117,7 +117,7 @@ public:
virtual double get_rx_rate(void) = 0;
virtual tune_result_t set_rx_freq(double freq) = 0;
- virtual tune_result_t set_rx_freq(double freq, double lo_off) = 0;
+ //virtual tune_result_t set_rx_freq(double freq, double lo_off) = 0;
virtual double get_rx_freq(void) = 0;
virtual freq_range_t get_rx_freq_range(void) = 0;
@@ -152,7 +152,7 @@ public:
virtual double get_tx_rate(void) = 0;
virtual tune_result_t set_tx_freq(double freq) = 0;
- virtual tune_result_t set_tx_freq(double freq, double lo_off) = 0;
+ //virtual tune_result_t set_tx_freq(double freq, double lo_off) = 0;
virtual double get_tx_freq(void) = 0;
virtual freq_range_t get_tx_freq_range(void) = 0;
@@ -243,9 +243,9 @@ public:
return _sdev->set_rx_freq(target_freq);
}
- tune_result_t set_rx_freq(double target_freq, double lo_off){
- return _sdev->set_rx_freq(target_freq, lo_off);
- }
+ //tune_result_t set_rx_freq(double target_freq, double lo_off){
+ // return _sdev->set_rx_freq(target_freq, lo_off);
+ //}
double get_rx_freq(void){
return _sdev->get_rx_freq();
@@ -318,9 +318,9 @@ public:
return _sdev->set_tx_freq(target_freq);
}
- tune_result_t set_tx_freq(double target_freq, double lo_off){
- return _sdev->set_tx_freq(target_freq, lo_off);
- }
+ //tune_result_t set_tx_freq(double target_freq, double lo_off){
+ // return _sdev->set_tx_freq(target_freq, lo_off);
+ //}
double get_tx_freq(void){
return _sdev->get_tx_freq();
@@ -374,7 +374,7 @@ namespace uhd{ namespace usrp{
* The Make Function
**********************************************************************/
inline simple_usrp::sptr simple_usrp::make(const device_addr_t &dev_addr){
- uhd::print_warning(
+ uhd::warning::post(
"The simple USRP interface has been deprecated.\n"
"Please switch to the single USRP interface.\n"
"#include <uhd/usrp/single_usrp.hpp>\n"
diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp
index 74a978f05..26303fe10 100644
--- a/host/include/uhd/usrp/single_usrp.hpp
+++ b/host/include/uhd/usrp/single_usrp.hpp
@@ -23,6 +23,7 @@
#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/usrp/subdev_spec.hpp>
#include <uhd/usrp/dboard_iface.hpp>
@@ -43,6 +44,9 @@ class UHD_API single_usrp : boost::noncopyable{
public:
typedef boost::shared_ptr<single_usrp> sptr;
+ //! A wildcard gain element name
+ static const std::string ALL_GAINS;
+
/*!
* Make a new single usrp from the device address.
* \param dev_addr the device address
@@ -120,7 +124,6 @@ public:
* Set the RX subdevice 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
*/
virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0;
@@ -152,20 +155,13 @@ public:
/*!
* Set the RX center frequency.
- * \param freq the frequency in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result object
- */
- virtual tune_result_t set_rx_freq(double freq, size_t chan = 0) = 0;
-
- /*!
- * Set the RX center frequency.
- * \param freq the frequency in Hz
- * \param lo_off an LO offset in Hz
+ * \param tune_request tune request instructions
* \param chan the channel index 0 to N-1
* \return a tune result object
*/
- virtual tune_result_t set_rx_freq(double freq, double lo_off, size_t chan = 0) = 0;
+ virtual tune_result_t set_rx_freq(
+ const tune_request_t &tune_request, size_t chan = 0
+ ) = 0;
/*!
* Get the RX center frequency.
@@ -182,27 +178,54 @@ public:
virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
/*!
- * Set the RX gain:
- * Distribute among gain elements in the RX path.
+ * Set the RX gain value for the specified gain element.
+ * For an empty name, distribute across all gain elements.
* \param gain the gain in dB
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain(float gain, size_t chan = 0) = 0;
+ virtual void set_rx_gain(float gain, const std::string &name, size_t chan = 0) = 0;
+
+ //! A convenience wrapper for setting overall RX gain
+ void set_rx_gain(float gain, size_t chan = 0){
+ return this->set_rx_gain(gain, ALL_GAINS, chan);
+ }
/*!
- * Get the RX gain:
- * Summation of gain elements in the RX path.
+ * Get the RX gain value for the specified gain element.
+ * For an empty name, sum across all gain elements.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_rx_gain(size_t chan = 0) = 0;
+ virtual float get_rx_gain(const std::string &name, size_t chan = 0) = 0;
+
+ //! A convenience wrapper for getting overall RX gain
+ float get_rx_gain(size_t chan = 0){
+ return this->get_rx_gain(ALL_GAINS, chan);
+ }
/*!
- * Get the RX gain range.
+ * Get the RX gain range for the specified gain element.
+ * For an empty name, calculate the overall gain range.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_rx_gain_range(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){
+ return this->get_rx_gain_range(ALL_GAINS, chan);
+ }
+
+ /*!
+ * Get the names of the gain elements in the RX chain.
+ * Gain elements are ordered from antenna to FPGA.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of gain element names
+ */
+ virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
/*!
* Select the RX antenna on the subdevice.
@@ -270,7 +293,6 @@ public:
* Set the TX subdevice 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
*/
virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0;
@@ -302,20 +324,13 @@ public:
/*!
* Set the TX center frequency.
- * \param freq the frequency in Hz
+ * \param tune_request tune request instructions
* \param chan the channel index 0 to N-1
* \return a tune result object
*/
- virtual tune_result_t set_tx_freq(double freq, size_t chan = 0) = 0;
-
- /*!
- * Set the TX center frequency.
- * \param freq the frequency in Hz
- * \param lo_off an LO offset in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result object
- */
- virtual tune_result_t set_tx_freq(double freq, double lo_off, size_t chan = 0) = 0;
+ virtual tune_result_t set_tx_freq(
+ const tune_request_t &tune_request, size_t chan = 0
+ ) = 0;
/*!
* Get the TX center frequency.
@@ -332,27 +347,54 @@ public:
virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
/*!
- * Set the TX gain:
- * Distribute among gain elements in the TX path.
+ * Set the TX gain value for the specified gain element.
+ * For an empty name, distribute across all gain elements.
* \param gain the gain in dB
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain(float gain, size_t chan = 0) = 0;
+ virtual void set_tx_gain(float gain, const std::string &name, size_t chan = 0) = 0;
+
+ //! A convenience wrapper for setting overall TX gain
+ void set_tx_gain(float gain, size_t chan = 0){
+ return this->set_tx_gain(gain, ALL_GAINS, chan);
+ }
/*!
- * Get the TX gain:
- * Summation of gain elements in the TX path.
+ * Get the TX gain value for the specified gain element.
+ * For an empty name, sum across all gain elements.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_tx_gain(size_t chan = 0) = 0;
+ virtual float get_tx_gain(const std::string &name, size_t chan = 0) = 0;
+
+ //! A convenience wrapper for getting overall TX gain
+ float get_tx_gain(size_t chan = 0){
+ return this->get_tx_gain(ALL_GAINS, chan);
+ }
/*!
- * Get the TX gain range.
+ * Get the TX gain range for the specified gain element.
+ * For an empty name, calculate the overall gain range.
+ * \param name the name of the gain element
* \param chan the channel index 0 to N-1
* \return a gain range object
*/
- virtual gain_range_t get_tx_gain_range(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){
+ return this->get_tx_gain_range(ALL_GAINS, chan);
+ }
+
+ /*!
+ * Get the names of the gain elements in the TX chain.
+ * Gain elements are ordered from antenna to FPGA.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of gain element names
+ */
+ virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
/*!
* Select the TX antenna on the subdevice.
diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp
index ec133fa08..db12241c1 100644
--- a/host/include/uhd/usrp/tune_helper.hpp
+++ b/host/include/uhd/usrp/tune_helper.hpp
@@ -20,6 +20,7 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
+#include <uhd/types/tune_request.hpp>
#include <uhd/types/tune_result.hpp>
namespace uhd{ namespace usrp{
@@ -32,23 +33,12 @@ namespace uhd{ namespace usrp{
* \param subdev the dboard subdevice object with properties
* \param ddc the mboard dsp object with properties
* \param chan the channel of the dsp to tune
- * \param target_freq the desired center frequency
- * \param lo_offset an offset for the subdevice IF from center
+ * \param tune_request tune request instructions
* \return a tune result struct
*/
UHD_API tune_result_t tune_rx_subdev_and_dsp(
wax::obj subdev, wax::obj ddc, size_t chan,
- double target_freq, double lo_offset
- );
-
- /*!
- * Tune a rx chain to the desired frequency:
- * Same as the above, except the LO offset
- * is calculated based on the subdevice and BW.
- */
- UHD_API tune_result_t tune_rx_subdev_and_dsp(
- wax::obj subdev, wax::obj ddc,
- size_t chan, double target_freq
+ const tune_request_t &tune_request
);
/*!
@@ -70,23 +60,12 @@ namespace uhd{ namespace usrp{
* \param subdev the dboard subdevice object with properties
* \param duc the mboard dsp object with properties
* \param chan the channel of the dsp to tune
- * \param target_freq the desired center frequency
- * \param lo_offset an offset for the subdevice IF from center
+ * \param tune_request tune request instructions
* \return a tune result struct
*/
UHD_API tune_result_t tune_tx_subdev_and_dsp(
wax::obj subdev, wax::obj duc, size_t chan,
- double target_freq, double lo_offset
- );
-
- /*!
- * Tune a tx chain to the desired frequency:
- * Same as the above, except the LO offset
- * is calculated based on the subdevice and BW.
- */
- UHD_API tune_result_t tune_tx_subdev_and_dsp(
- wax::obj subdev, wax::obj duc,
- size_t chan, double target_freq
+ const tune_request_t &tune_request
);
/*!
diff --git a/host/include/uhd/utils/gain_group.hpp b/host/include/uhd/utils/gain_group.hpp
index 3955dfa9a..c863248ce 100644
--- a/host/include/uhd/utils/gain_group.hpp
+++ b/host/include/uhd/utils/gain_group.hpp
@@ -23,6 +23,8 @@
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/utility.hpp>
+#include <vector>
+#include <string>
namespace uhd{
@@ -40,36 +42,57 @@ public:
typedef boost::shared_ptr<gain_group> sptr;
/*!
- * Get the overall gain range for this group.
+ * Get the gain range for the gain element specified by name.
+ * For an empty name, get the overall gain range for this group.
* Overall step is defined as the minimum step size.
+ * \param name name of the gain element (optional)
* \return a gain range with overall min, max, step
*/
- virtual gain_range_t get_range(void) = 0;
+ virtual gain_range_t get_range(const std::string &name = "") = 0;
/*!
- * Get the overall gain value for this group.
- * \return a summation of all the gain values
+ * Get the gain value for the gain element specified by name.
+ * For an empty name, get the overall gain value for this group.
+ * \param name name of the gain element (optional)
+ * \return a gain value of the element or all elements
*/
- virtual float get_value(void) = 0;
+ virtual float get_value(const std::string &name = "") = 0;
/*!
- * Set the overall gain value for this group.
+ * Set the gain value for the gain element specified by name.
+ * For an empty name, set the overall gain value for this group.
* The power will be distributed across individual gain elements.
* The semantics of how to do this are determined by the priority.
- * \param gain the gain to set across the group
+ * \param gain the gain to set for the lement or across the group
+ * \param name name of the gain element (optional)
*/
- virtual void set_value(float gain) = 0;
+ virtual void set_value(float gain, const std::string &name = "") = 0;
/*!
- * Register a set of gain functions into this group.
+ * Get a list of names of registered gain elements.
+ * The names are in the order that they were registered.
+ * \return a vector of gain name strings
+ */
+ virtual const std::vector<std::string> get_names(void) = 0;
+
+ /*!
+ * Register a set of gain functions into this group:
+ *
+ * The name should be a unique and non-empty name.
+ * Othwerwise, the implementation will rename it.
+ *
* Priority determines how power will be distributed
* with higher priorities getting the power first,
* and lower priorities getting the remainder power.
+ *
+ * \param name the name of the gain element
* \param gain_fcns the set of gain functions
* \param priority the priority of the gain element
*/
virtual void register_fcns(
- const gain_fcns_t &gain_fcns, size_t priority = 0
+ const std::string &name,
+ const gain_fcns_t &gain_fcns,
+ size_t priority = 0
) = 0;
/*!
diff --git a/host/include/uhd/utils/warning.hpp b/host/include/uhd/utils/warning.hpp
index 91d8400ab..a1e3f0d1e 100644
--- a/host/include/uhd/utils/warning.hpp
+++ b/host/include/uhd/utils/warning.hpp
@@ -19,16 +19,44 @@
#define INCLUDED_UHD_UTILS_WARNING_HPP
#include <uhd/config.hpp>
+#include <boost/function.hpp>
+#include <vector>
#include <string>
-namespace uhd{
+namespace uhd{ namespace warning{
+
+ //! Callback function type for a message handler
+ typedef boost::function<void(std::string)> handler_t;
/*!
- * Print a formatted warning string to stderr.
+ * Post a warning message to all registered handlers.
* \param msg the multiline warning message
*/
- UHD_API void print_warning(const std::string &msg);
+ UHD_API void post(const std::string &msg);
+
+ /*!
+ * Register a new handler with this name.
+ * If the name was already registered for this name,
+ * the old registered handler will be replaced.
+ * \param name a unique name for this handler
+ * \param handler the callback handler function
+ */
+ UHD_API void register_handler(const std::string &name, const handler_t &handler);
+
+ /*!
+ * Unregister a handler for this name.
+ * \param name a unique name for a registered handler
+ * \return the handler that was registered
+ * \throw error when the name was not found in the registry
+ */
+ UHD_API handler_t unregister_handler(const std::string &name);
+
+ /*!
+ * Get a list of registered handler names.
+ * \return a vector of unique string names
+ */
+ UHD_API const std::vector<std::string> registry_names(void);
-} //namespace uhd
+}} //namespace uhd::warning
#endif /* INCLUDED_UHD_UTILS_WARNING_HPP */