summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/CMakeLists.txt2
-rw-r--r--host/include/uhd/types/dict.hpp86
-rw-r--r--host/include/uhd/types/dict.ipp128
-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/mimo_usrp.hpp20
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp39
-rw-r--r--host/include/uhd/usrp/simple_usrp.hpp18
-rw-r--r--host/include/uhd/usrp/single_usrp.hpp31
-rw-r--r--host/include/uhd/usrp/subdev_spec.hpp11
-rw-r--r--host/include/uhd/usrp/tune_helper.hpp31
-rw-r--r--host/include/uhd/utils/warning.hpp36
12 files changed, 373 insertions, 200 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..6166140a0 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,42 @@ 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 in the dict or default.
+ * \param key the key to look for
+ * \param def use if key not found
+ * \return the value or default
+ */
+ const Val &get(const Key &key, const Val &def) const;
/*!
* Get a value for the given key if it exists.
@@ -116,15 +85,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 +93,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 +101,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..ba05d5272
--- /dev/null
+++ b/host/include/uhd/types/dict.ipp
@@ -0,0 +1,128 @@
+//
+// 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 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>::get(const Key &key, const Val &def) const{
+ BOOST_FOREACH(const pair_t &p, _map){
+ if (p.first == key) return p.second;
+ }
+ return def;
+ }
+
+ 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/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/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 2f71f80b1..98ba07fc0 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>
@@ -144,6 +145,14 @@ public:
virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
/*!
+ * Are the times across all motherboards in this configuration synchronized?
+ * Checks that all time registers are approximately close but not exact,
+ * given that the RTT may varying for a control packet transaction.
+ * \return true when all motherboards time registers are in sync
+ */
+ virtual bool get_time_synchronized(void) = 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.
@@ -213,20 +222,13 @@ public:
/*!
* Set the RX 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_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 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.
@@ -399,20 +401,13 @@ public:
/*!
* Set the TX 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_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 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, 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.
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 a068fbed8..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>
@@ -154,20 +155,13 @@ public:
/*!
* Set the RX 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_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 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.
@@ -330,20 +324,13 @@ public:
/*!
* Set the TX 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_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 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, 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.
diff --git a/host/include/uhd/usrp/subdev_spec.hpp b/host/include/uhd/usrp/subdev_spec.hpp
index 5de3bb3b8..b189724c9 100644
--- a/host/include/uhd/usrp/subdev_spec.hpp
+++ b/host/include/uhd/usrp/subdev_spec.hpp
@@ -26,10 +26,10 @@
namespace uhd{ namespace usrp{
/*!
- * A subdevice specification (daughterboard, subdevice) name pairing.
+ * A subdevice specification (daughterboard slot, subdevice) name pairing.
*/
struct UHD_API subdev_spec_pair_t : boost::equality_comparable<subdev_spec_pair_t>{
- //! The daughterboard name
+ //! The daughterboard slot name
std::string db_name;
//! The subdevice name
@@ -50,7 +50,7 @@ namespace uhd{ namespace usrp{
UHD_API bool operator==(const subdev_spec_pair_t &, const subdev_spec_pair_t &);
/*!
- * A list of (daughterboard name, subdevice name) pairs:
+ * A list of (daughterboard slot name, subdevice name) pairs:
*
* A subdevice specification represents a list of subdevices on a motherboard.
* The subdevices specified may span across multiple daughterboards;
@@ -62,6 +62,11 @@ namespace uhd{ namespace usrp{
* The markup-string is a whitespace separated list of dboard:subdev pairs.
* The first pair represents the subdevice for channel zero,
* the second pair represents the subdevice for channel one, and so on.
+ *
+ * Special handling for empty conditions:
+ * - An empty subdevice specification means: select the first subdevice found in the configuration
+ * - An empty daughterboard name means: select the only daughterboard slot or error if multiple exist
+ * - An empty subdevice name means: select the only subdevice on that board or error if multiple exist
*/
class UHD_API subdev_spec_t : public std::vector<subdev_spec_pair_t>{
public:
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/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 */