summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-28 18:23:27 -0700
committerJosh Blum <josh@joshknows.com>2010-10-28 18:23:27 -0700
commita8d2c2944b329218af1c0b171b92f775b679b409 (patch)
tree02e558d525055cb82e8d00a7a2d75fe324015ae6 /host/lib
parentef8ed898cbc6cb6cd1994d2a8b090112f4f3a664 (diff)
parent6a3e499f586513d48ef648aa910e252b7d8b046b (diff)
downloaduhd-a8d2c2944b329218af1c0b171b92f775b679b409.tar.gz
uhd-a8d2c2944b329218af1c0b171b92f775b679b409.tar.bz2
uhd-a8d2c2944b329218af1c0b171b92f775b679b409.zip
Merge branch 'next'
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/CMakeLists.txt19
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp2
-rw-r--r--host/lib/types.cpp21
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp39
-rw-r--r--host/lib/usrp/dboard/db_dbsrx.cpp12
-rw-r--r--host/lib/usrp/dboard/db_rfx.cpp21
-rw-r--r--host/lib/usrp/dboard/db_tvrx.cpp10
-rw-r--r--host/lib/usrp/dboard/db_unknown.cpp23
-rw-r--r--host/lib/usrp/dboard/db_wbx.cpp21
-rw-r--r--host/lib/usrp/dboard/db_xcvr2450.cpp8
-rw-r--r--host/lib/usrp/dboard_manager.cpp4
-rw-r--r--host/lib/usrp/multi_usrp.cpp35
-rw-r--r--host/lib/usrp/single_usrp.cpp24
-rw-r--r--host/lib/usrp/tune_helper.cpp141
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp2
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp2
-rw-r--r--host/lib/usrp/wrapper_utils.hpp4
-rw-r--r--host/lib/utils/thread_priority.cpp2
-rw-r--r--host/lib/utils/warning.cpp59
19 files changed, 327 insertions, 122 deletions
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 81845de21..e4de7bcc7 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -16,6 +16,25 @@
#
########################################################################
+# Check Python Modules
+########################################################################
+PYTHON_CHECK_MODULE(
+ "Python version 2.6 or greater"
+ "platform" "platform.python_version() >= '2.6'"
+ HAVE_PYTHON_PLAT_MIN_VERSION
+)
+
+PYTHON_CHECK_MODULE(
+ "Cheetah templates 2.0.0 or greater"
+ "Cheetah" "Cheetah.Version >= '2.0.0'"
+ HAVE_PYTHON_MODULE_CHEETAH
+)
+
+IF(NOT HAVE_PYTHON_PLAT_MIN_VERSION OR NOT HAVE_PYTHON_MODULE_CHEETAH)
+ MESSAGE(FATAL_ERROR "Error: python requirements not met for the build system.")
+ENDIF(NOT HAVE_PYTHON_PLAT_MIN_VERSION OR NOT HAVE_PYTHON_MODULE_CHEETAH)
+
+########################################################################
# Helpful Macros
########################################################################
MACRO(LIBUHD_APPEND_SOURCES)
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index d84aeefdd..ed29864e9 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -336,7 +336,7 @@ template<typename Opt> static void resize_buff_helper(
else std::cout << boost::format(
"Current %s sock buff size: %d bytes"
) % name % actual_size << std::endl;
- if (actual_size < target_size) uhd::print_warning(str(boost::format(
+ if (actual_size < target_size) uhd::warning::post(str(boost::format(
"The %s buffer is smaller than the requested size.\n"
"The minimum recommended buffer size is %d bytes.\n"
"See the transport application notes on buffer resizing.\n%s"
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index 6aa82b012..4188568aa 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -17,6 +17,7 @@
#include <uhd/utils/assert.hpp>
#include <uhd/types/ranges.hpp>
+#include <uhd/types/tune_request.hpp>
#include <uhd/types/tune_result.hpp>
#include <uhd/types/clock_config.hpp>
#include <uhd/types/stream_cmd.hpp>
@@ -58,6 +59,26 @@ freq_range_t::freq_range_t(double min, double max):
}
/***********************************************************************
+ * tune request
+ **********************************************************************/
+tune_request_t::tune_request_t(double target_freq):
+ target_freq(target_freq),
+ inter_freq_policy(POLICY_AUTO),
+ dsp_freq_policy(POLICY_AUTO)
+{
+ /* NOP */
+}
+
+tune_request_t::tune_request_t(double target_freq, double lo_off):
+ target_freq(target_freq),
+ inter_freq_policy(POLICY_MANUAL),
+ inter_freq(target_freq + lo_off),
+ dsp_freq_policy(POLICY_AUTO)
+{
+ /* NOP */
+}
+
+/***********************************************************************
* tune result
**********************************************************************/
std::string tune_result_t::to_pp_string(void) const{
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index 41f6f8002..f03dd43d1 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -20,6 +20,7 @@
#include <uhd/types/ranges.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
+#include <uhd/utils/warning.hpp>
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <boost/assign/list_of.hpp>
@@ -30,6 +31,16 @@ using namespace uhd::usrp;
using namespace boost::assign;
/***********************************************************************
+ * Constants
+ **********************************************************************/
+static const uhd::dict<std::string, double> subdev_bandwidth_scalar = map_list_of
+ ("A", 1.0)
+ ("B", 1.0)
+ ("AB", 2.0)
+ ("BA", 2.0)
+;
+
+/***********************************************************************
* The basic and lf boards:
* They share a common class because only the frequency bounds differ.
**********************************************************************/
@@ -68,11 +79,11 @@ static const uhd::dict<std::string, subdev_conn_t> sd_name_to_conn = map_list_of
* Register the basic and LF dboards
**********************************************************************/
static dboard_base::sptr make_basic_rx(dboard_base::ctor_args_t args){
- return dboard_base::sptr(new basic_rx(args, 90e9));
+ return dboard_base::sptr(new basic_rx(args, 250e6));
}
static dboard_base::sptr make_basic_tx(dboard_base::ctor_args_t args){
- return dboard_base::sptr(new basic_tx(args, 90e9));
+ return dboard_base::sptr(new basic_tx(args, 250e6));
}
static dboard_base::sptr make_lf_rx(dboard_base::ctor_args_t args){
@@ -161,6 +172,10 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
val = true; //there is no LO, so it must be true!
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = subdev_bandwidth_scalar[get_subdev_name()]*_max_freq;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -185,6 +200,14 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("%s: No tunable bandwidth, fixed filtered to %0.2fMHz")
+ % get_rx_id().to_pp_string() % _max_freq
+ )
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
@@ -260,6 +283,10 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
val = true; //there is no LO, so it must be true!
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = subdev_bandwidth_scalar[get_subdev_name()]*_max_freq;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -284,6 +311,14 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("%s: No tunable bandwidth, fixed filtered to %0.2fMHz")
+ % get_tx_id().to_pp_string() % _max_freq
+ )
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp
index aecd7249d..85251bdf9 100644
--- a/host/lib/usrp/dboard/db_dbsrx.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx.cpp
@@ -175,7 +175,7 @@ UHD_STATIC_BLOCK(reg_dbsrx_dboard){
dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){
//warn user about incorrect DBID on USRP1, requires R193 populated
if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D)
- uhd::print_warning(
+ uhd::warning::post(
str(boost::format(
"DBSRX: incorrect dbid\n"
"Expected dbid 0x0002 and R193\n"
@@ -186,7 +186,7 @@ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){
//warn user about incorrect DBID on non-USRP1, requires R194 populated
if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002)
- uhd::print_warning(
+ uhd::warning::post(
str(boost::format(
"DBSRX: incorrect dbid\n"
"Expected dbid 0x000D and R194\n"
@@ -342,7 +342,7 @@ void dbsrx::set_lo_freq(double target_freq){
//vtune is too low, try lower frequency vco
if (_max2118_read_regs.adc == 0){
if (_max2118_write_regs.osc_band == 0){
- uhd::print_warning(
+ uhd::warning::post(
str(boost::format(
"DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n"
) % int(_max2118_write_regs.osc_band))
@@ -356,7 +356,7 @@ void dbsrx::set_lo_freq(double target_freq){
//vtune is too high, try higher frequency vco
if (_max2118_read_regs.adc == 7){
if (_max2118_write_regs.osc_band == 7){
- uhd::print_warning(
+ uhd::warning::post(
str(boost::format(
"DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n"
) % int(_max2118_write_regs.osc_band))
@@ -563,7 +563,7 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_BANDWIDTH:
- val = _bandwidth;
+ val = 2*_bandwidth; //_bandwidth is low-pass, we want complex double-sided
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -588,7 +588,7 @@ void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){
return; //always enabled
case SUBDEV_PROP_BANDWIDTH:
- this->set_bandwidth(val.as<double>());
+ this->set_bandwidth(val.as<double>()/2.0); //complex double-sided, we want low-pass
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp
index 3c24d90db..152198c3a 100644
--- a/host/lib/usrp/dboard/db_rfx.cpp
+++ b/host/lib/usrp/dboard/db_rfx.cpp
@@ -43,6 +43,7 @@
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/utils/algorithm.hpp>
+#include <uhd/utils/warning.hpp>
#include <uhd/usrp/dboard_id.hpp>
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/usrp/dboard_manager.hpp>
@@ -456,6 +457,10 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
val = this->get_locked(dboard_iface::UNIT_RX);
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 2*20.0e6; //20MHz low-pass, we want complex double-sided
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -481,6 +486,12 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("RFX: No tunable bandwidth, fixed filtered to 40MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
@@ -543,6 +554,10 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
val = this->get_locked(dboard_iface::UNIT_TX);
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 2*20.0e6; //20MHz low-pass, we want complex double-sided
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -568,6 +583,12 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("RFX: No tunable bandwidth, fixed filtered to 40MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp
index d39dc3bf8..2873e3d54 100644
--- a/host/lib/usrp/dboard/db_tvrx.cpp
+++ b/host/lib/usrp/dboard/db_tvrx.cpp
@@ -459,6 +459,10 @@ void tvrx::rx_get(const wax::obj &key_, wax::obj &val){
val = true;
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 6.0e6;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -479,6 +483,12 @@ void tvrx::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("TVRX: No tunable bandwidth, fixed filtered to 6MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp
index ec7ab440b..a342471c4 100644
--- a/host/lib/usrp/dboard/db_unknown.cpp
+++ b/host/lib/usrp/dboard/db_unknown.cpp
@@ -19,6 +19,7 @@
#include <uhd/types/ranges.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
+#include <uhd/utils/warning.hpp>
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <boost/assign/list_of.hpp>
@@ -134,6 +135,10 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){
val = true; //there is no LO, so it must be true!
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 0.0;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -158,12 +163,18 @@ void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("Unknown Daughterboard: No tunable bandwidth, fixed filtered to 0.0MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
/***********************************************************************
- * Basic and LF TX dboard
+ * Unknown TX dboard
**********************************************************************/
unknown_tx::unknown_tx(ctor_args_t args) : tx_dboard_base(args){
/* NOP */
@@ -230,6 +241,10 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){
val = true; //there is no LO, so it must be true!
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 0.0;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -254,6 +269,12 @@ void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("Unknown Daughterboard: No tunable bandwidth, fixed filtered to 0.0MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp
index 907268aac..572f5de97 100644
--- a/host/lib/usrp/dboard/db_wbx.cpp
+++ b/host/lib/usrp/dboard/db_wbx.cpp
@@ -71,6 +71,7 @@
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/utils/algorithm.hpp>
+#include <uhd/utils/warning.hpp>
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <boost/assign/list_of.hpp>
@@ -525,6 +526,10 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
val = this->get_locked(dboard_iface::UNIT_RX);
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 2*20.0e6; //20MHz low-pass, we want complex double-sided
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -550,6 +555,12 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("WBX: No tunable bandwidth, fixed filtered to 40MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
@@ -616,6 +627,10 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
val = this->get_locked(dboard_iface::UNIT_TX);
return;
+ case SUBDEV_PROP_BANDWIDTH:
+ val = 2*20.0e6; //20MHz low-pass, we want complex double-sided
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -641,6 +656,12 @@ void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_ENABLED:
return; //always enabled
+ case SUBDEV_PROP_BANDWIDTH:
+ uhd::warning::post(
+ str(boost::format("WBX: No tunable bandwidth, fixed filtered to 40MHz"))
+ );
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp
index fb1367113..be0e42b92 100644
--- a/host/lib/usrp/dboard/db_xcvr2450.cpp
+++ b/host/lib/usrp/dboard/db_xcvr2450.cpp
@@ -626,7 +626,7 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_BANDWIDTH:
- val = _rx_bandwidth;
+ val = 2*_rx_bandwidth; //_tx_bandwidth is low-pass, we want complex double-sided
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -652,7 +652,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_BANDWIDTH:
- this->set_rx_bandwidth(val.as<double>());
+ this->set_rx_bandwidth(val.as<double>()/2.0); //complex double-sided, we want low-pass
return;
case SUBDEV_PROP_ENABLED:
@@ -725,7 +725,7 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_BANDWIDTH:
- val = _tx_bandwidth;
+ val = 2*_tx_bandwidth; //_tx_bandwidth is low-pass, we want complex double-sided
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -747,7 +747,7 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_BANDWIDTH:
- this->set_tx_bandwidth(val.as<double>());
+ this->set_tx_bandwidth(val.as<double>()/2.0); //complex double-sided, we want low-pass
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index d73a698ae..5a98bb8eb 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -189,7 +189,7 @@ static args_t get_dboard_args(
//verify that there is a registered constructor for this id
if (not get_id_to_args_map().has_key(dboard_id)){
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"Unknown dboard ID: %s.\n"
) % dboard_id.to_pp_string()));
return get_dboard_args(unit, dboard_id, true);
@@ -217,7 +217,7 @@ dboard_manager_impl::dboard_manager_impl(
//warn for invalid dboard id xcvr combinations
if (rx_dboard_is_xcvr != this_dboard_is_xcvr or tx_dboard_is_xcvr != this_dboard_is_xcvr){
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"Unknown transceiver board ID combination...\n"
"RX dboard ID: %s\n"
"TX dboard ID: %s\n"
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 443b91594..876f1a3fc 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -145,7 +145,7 @@ public:
time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
time_spec_t time_i = _mboard(m)[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"
@@ -154,6 +154,15 @@ public:
}
}
+ bool get_time_synchronized(void){
+ for (size_t m = 1; m < get_num_mboards(); m++){
+ time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
+ time_spec_t time_i = _mboard(m)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
+ if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)) return false;
+ }
+ return true;
+ }
+
void issue_stream_cmd(const stream_cmd_t &stream_cmd){
for (size_t m = 0; m < get_num_mboards(); m++){
_mboard(m)[MBOARD_PROP_STREAM_CMD] = stream_cmd;
@@ -210,15 +219,9 @@ public:
return _rx_dsp(0)[DSP_PROP_HOST_RATE].as<double>();
}
- tune_result_t set_rx_freq(double target_freq, size_t chan){
- tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan/rx_cpm()), chan%rx_cpm(), target_freq);
- do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
- return r;
- }
-
- tune_result_t set_rx_freq(double target_freq, double lo_off, size_t chan){
- tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan/rx_cpm()), chan%rx_cpm(), target_freq, lo_off);
- do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
+ tune_result_t set_rx_freq(const tune_request_t &tune_request, size_t chan){
+ tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan/rx_cpm()), chan%rx_cpm(), tune_request);
+ do_tune_freq_warning_message(tune_request.target_freq, get_rx_freq(chan), "RX");
return r;
}
@@ -314,15 +317,9 @@ public:
return _tx_dsp(0)[DSP_PROP_HOST_RATE].as<double>();
}
- tune_result_t set_tx_freq(double target_freq, size_t chan){
- tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan/tx_cpm()), chan%tx_cpm(), target_freq);
- do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
- return r;
- }
-
- tune_result_t set_tx_freq(double target_freq, double lo_off, size_t chan){
- tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan/tx_cpm()), chan%tx_cpm(), target_freq, lo_off);
- do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
+ tune_result_t set_tx_freq(const tune_request_t &tune_request, size_t chan){
+ tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan/tx_cpm()), chan%tx_cpm(), tune_request);
+ do_tune_freq_warning_message(tune_request.target_freq, get_tx_freq(chan), "TX");
return r;
}
diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp
index 5e57849b8..a0456d1f0 100644
--- a/host/lib/usrp/single_usrp.cpp
+++ b/host/lib/usrp/single_usrp.cpp
@@ -146,15 +146,9 @@ public:
return _rx_dsp()[DSP_PROP_HOST_RATE].as<double>();
}
- tune_result_t set_rx_freq(double target_freq, size_t chan){
- tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq);
- do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
- return r;
- }
-
- tune_result_t set_rx_freq(double target_freq, double lo_off, size_t chan){
- tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, target_freq, lo_off);
- do_tune_freq_warning_message(target_freq, get_rx_freq(chan), "RX");
+ tune_result_t set_rx_freq(const tune_request_t &tune_request, size_t chan){
+ tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(), chan, tune_request);
+ do_tune_freq_warning_message(tune_request.target_freq, get_rx_freq(chan), "RX");
return r;
}
@@ -238,15 +232,9 @@ public:
return _tx_dsp()[DSP_PROP_HOST_RATE].as<double>();
}
- tune_result_t set_tx_freq(double target_freq, size_t chan){
- tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq);
- do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
- return r;
- }
-
- tune_result_t set_tx_freq(double target_freq, double lo_off, size_t chan){
- tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, target_freq, lo_off);
- do_tune_freq_warning_message(target_freq, get_tx_freq(chan), "TX");
+ tune_result_t set_tx_freq(const tune_request_t &tune_request, size_t chan){
+ tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(), chan, tune_request);
+ do_tune_freq_warning_message(tune_request.target_freq, get_tx_freq(chan), "TX");
return r;
}
diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp
index 7633c67f2..fa40a8a26 100644
--- a/host/lib/usrp/tune_helper.cpp
+++ b/host/lib/usrp/tune_helper.cpp
@@ -19,6 +19,7 @@
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dsp_props.hpp>
#include <uhd/usrp/dboard_iface.hpp> //unit_t
+#include <uhd/utils/algorithm.hpp>
#include <boost/math/special_functions/sign.hpp>
#include <cmath>
@@ -28,55 +29,99 @@ using namespace uhd::usrp;
/***********************************************************************
* Tune Helper Functions
**********************************************************************/
-static tune_result_t tune_xx_subdev_and_dxc(
+static tune_result_t tune_xx_subdev_and_dsp(
dboard_iface::unit_t unit,
- wax::obj subdev, wax::obj dxc, size_t chan,
- double target_freq, double lo_offset
+ wax::obj subdev, wax::obj dsp, size_t chan,
+ const tune_request_t &tune_request
){
wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ];
- std::string freq_name = dxc[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
- wax::obj dxc_freq_proxy = dxc[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)];
- double dxc_sample_rate = dxc[DSP_PROP_CODEC_RATE].as<double>();
+ std::string freq_name = dsp[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
+ wax::obj dsp_freq_proxy = dsp[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)];
+ double dsp_sample_rate = dsp[DSP_PROP_CODEC_RATE].as<double>();
- // Ask the d'board to tune as closely as it can to target_freq+lo_offset
- double target_inter_freq = target_freq + lo_offset;
- subdev_freq_proxy = target_inter_freq;
- double actual_inter_freq = subdev_freq_proxy.as<double>();
-
- //perform the correction correction for dxc rates outside of nyquist
- double delta_freq = std::fmod(target_freq - actual_inter_freq, dxc_sample_rate);
- bool outside_of_nyquist = std::abs(delta_freq) > dxc_sample_rate/2.0;
- double target_dxc_freq = (outside_of_nyquist)?
- boost::math::sign(delta_freq)*dxc_sample_rate - delta_freq : -delta_freq;
+ //------------------------------------------------------------------
+ //-- calculate the LO offset, only used with automatic policy
+ //------------------------------------------------------------------
+ double lo_offset = 0.0;
+ if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
+ //If the local oscillator will be in the passband, use an offset.
+ //But constrain the LO offset by the width of the filter bandwidth.
+ double rate = dsp[DSP_PROP_HOST_RATE].as<double>();
+ double bw = subdev[SUBDEV_PROP_BANDWIDTH].as<double>();
+ if (bw > rate) lo_offset = std::min((bw - rate)/2, rate/2);
+ }
- //invert the sign on the dxc freq given the following conditions
- if (unit == dboard_iface::UNIT_TX) target_dxc_freq *= -1.0;
+ //------------------------------------------------------------------
+ //-- set the intermediate frequency depending upon the IF policy
+ //------------------------------------------------------------------
+ double target_inter_freq = 0.0;
+ switch (tune_request.inter_freq_policy){
+ case tune_request_t::POLICY_AUTO:
+ target_inter_freq = tune_request.target_freq + lo_offset;
+ subdev_freq_proxy = target_inter_freq;
+ break;
+
+ case tune_request_t::POLICY_MANUAL:
+ target_inter_freq = tune_request.inter_freq;
+ subdev_freq_proxy = target_inter_freq;
+ break;
+
+ case tune_request_t::POLICY_NONE: break; //does not set
+ }
+ double actual_inter_freq = subdev_freq_proxy.as<double>();
- dxc_freq_proxy = target_dxc_freq;
- double actual_dxc_freq = dxc_freq_proxy.as<double>();
+ //------------------------------------------------------------------
+ //-- calculate the dsp freq, only used with automatic policy
+ //------------------------------------------------------------------
+ double delta_freq = std::fmod(tune_request.target_freq - actual_inter_freq, dsp_sample_rate);
+ bool outside_of_nyquist = std::abs(delta_freq) > dsp_sample_rate/2.0;
+ double target_dsp_freq = (outside_of_nyquist)?
+ boost::math::sign(delta_freq)*dsp_sample_rate - delta_freq : -delta_freq;
+
+ //invert the sign on the dsp freq given the following conditions
+ if (unit == dboard_iface::UNIT_TX) target_dsp_freq *= -1.0;
+
+ //------------------------------------------------------------------
+ //-- set the dsp frequency depending upon the dsp frequency policy
+ //------------------------------------------------------------------
+ switch (tune_request.dsp_freq_policy){
+ case tune_request_t::POLICY_AUTO:
+ dsp_freq_proxy = target_dsp_freq;
+ break;
+
+ case tune_request_t::POLICY_MANUAL:
+ target_dsp_freq = tune_request.dsp_freq;
+ dsp_freq_proxy = target_dsp_freq;
+ break;
+
+ case tune_request_t::POLICY_NONE: break; //does not set
+ }
+ double actual_dsp_freq = dsp_freq_proxy.as<double>();
- //load and return the tune result
+ //------------------------------------------------------------------
+ //-- load and return the tune result
+ //------------------------------------------------------------------
tune_result_t tune_result;
tune_result.target_inter_freq = target_inter_freq;
tune_result.actual_inter_freq = actual_inter_freq;
- tune_result.target_dsp_freq = target_dxc_freq;
- tune_result.actual_dsp_freq = actual_dxc_freq;
+ tune_result.target_dsp_freq = target_dsp_freq;
+ tune_result.actual_dsp_freq = actual_dsp_freq;
return tune_result;
}
-static double derive_freq_from_xx_subdev_and_dxc(
+static double derive_freq_from_xx_subdev_and_dsp(
dboard_iface::unit_t unit,
- wax::obj subdev, wax::obj dxc, size_t chan
+ wax::obj subdev, wax::obj dsp, size_t chan
){
//extract actual dsp and IF frequencies
double actual_inter_freq = subdev[SUBDEV_PROP_FREQ].as<double>();
- std::string freq_name = dxc[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
- double actual_dxc_freq = dxc[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)].as<double>();
+ std::string freq_name = dsp[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
+ double actual_dsp_freq = dsp[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)].as<double>();
- //invert the sign on the dxc freq given the following conditions
- if (unit == dboard_iface::UNIT_TX) actual_dxc_freq *= -1.0;
+ //invert the sign on the dsp freq given the following conditions
+ if (unit == dboard_iface::UNIT_TX) actual_dsp_freq *= -1.0;
- return actual_inter_freq - actual_dxc_freq;
+ return actual_inter_freq - actual_dsp_freq;
}
/***********************************************************************
@@ -84,27 +129,15 @@ static double derive_freq_from_xx_subdev_and_dxc(
**********************************************************************/
tune_result_t usrp::tune_rx_subdev_and_dsp(
wax::obj subdev, wax::obj ddc, size_t chan,
- double target_freq, double lo_offset
-){
- return tune_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, chan, target_freq, lo_offset);
-}
-
-tune_result_t usrp::tune_rx_subdev_and_dsp(
- wax::obj subdev, wax::obj ddc,
- size_t chan, double target_freq
+ const tune_request_t &tune_request
){
- double lo_offset = 0.0;
- //if the local oscillator will be in the passband, use an offset
- if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
- lo_offset = 2.0*ddc[DSP_PROP_HOST_RATE].as<double>();
- }
- return tune_rx_subdev_and_dsp(subdev, ddc, chan, target_freq, lo_offset);
+ return tune_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc, chan, tune_request);
}
double usrp::derive_freq_from_rx_subdev_and_dsp(
wax::obj subdev, wax::obj ddc, size_t chan
){
- return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, chan);
+ return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc, chan);
}
/***********************************************************************
@@ -112,25 +145,13 @@ double usrp::derive_freq_from_rx_subdev_and_dsp(
**********************************************************************/
tune_result_t usrp::tune_tx_subdev_and_dsp(
wax::obj subdev, wax::obj duc, size_t chan,
- double target_freq, double lo_offset
+ const tune_request_t &tune_request
){
- return tune_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, chan, target_freq, lo_offset);
-}
-
-tune_result_t usrp::tune_tx_subdev_and_dsp(
- wax::obj subdev, wax::obj duc,
- size_t chan, double target_freq
-){
- double lo_offset = 0.0;
- //if the local oscillator will be in the passband, use an offset
- if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
- lo_offset = 2.0*duc[DSP_PROP_HOST_RATE].as<double>();
- }
- return tune_tx_subdev_and_dsp(subdev, duc, chan, target_freq, lo_offset);
+ return tune_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc, chan, tune_request);
}
double usrp::derive_freq_from_tx_subdev_and_dsp(
wax::obj subdev, wax::obj duc, size_t chan
){
- return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, chan);
+ return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc, chan);
}
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index fe3774eb4..669b20efa 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -98,7 +98,7 @@ static boost::uint32_t calc_rx_mux(
// for all quadrature sources: Z = 0
// for mixed sources: warning + Z = 0
int Z = (num_quads > 0)? 0 : 1;
- if (num_quads != 0 and num_reals != 0) uhd::print_warning(
+ if (num_quads != 0 and num_reals != 0) uhd::warning::post(
"Mixing real and quadrature rx subdevices is not supported.\n"
"The Q input to the real source(s) will be non-zero.\n"
);
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 276ca86f6..314384e72 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -64,7 +64,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
);
}
catch(...){
- uhd::print_warning(
+ uhd::warning::post(
"Could not locate USRP1 firmware.\n"
"Please install the images package.\n"
);
diff --git a/host/lib/usrp/wrapper_utils.hpp b/host/lib/usrp/wrapper_utils.hpp
index aee230fc0..6f9fdbfca 100644
--- a/host/lib/usrp/wrapper_utils.hpp
+++ b/host/lib/usrp/wrapper_utils.hpp
@@ -40,7 +40,7 @@ static inline void do_samp_rate_warning_message(
){
static const double max_allowed_error = 1.0; //Sps
if (std::abs(target_rate - actual_rate) > max_allowed_error){
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"The hardware does not support the requested %s sample rate:\n"
"Target sample rate: %f MSps\n"
"Actual sample rate: %f MSps\n"
@@ -55,7 +55,7 @@ static inline void do_tune_freq_warning_message(
){
static const double max_allowed_error = 1.0; //Hz
if (std::abs(target_freq - actual_freq) > max_allowed_error){
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"The hardware does not support the requested %s frequency:\n"
"Target frequency: %f MHz\n"
"Actual frequency: %f MHz\n"
diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp
index f09d1b1d6..40b74f655 100644
--- a/host/lib/utils/thread_priority.cpp
+++ b/host/lib/utils/thread_priority.cpp
@@ -26,7 +26,7 @@ bool uhd::set_thread_priority_safe(float priority, bool realtime){
set_thread_priority(priority, realtime);
return true;
}catch(const std::exception &e){
- uhd::print_warning(str(boost::format(
+ uhd::warning::post(str(boost::format(
"%s\n"
"Failed to set thread priority %d (%s):\n"
"Performance may be negatively affected.\n"
diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp
index 8a7d35a23..05be7ae4d 100644
--- a/host/lib/utils/warning.cpp
+++ b/host/lib/utils/warning.cpp
@@ -17,16 +17,67 @@
#include <uhd/utils/warning.hpp>
#include <uhd/utils/algorithm.hpp>
+#include <uhd/utils/static.hpp>
+#include <uhd/types/dict.hpp>
#include <boost/foreach.hpp>
+#include <sstream>
+#include <stdexcept>
#include <iostream>
#include <vector>
using namespace uhd;
-void uhd::print_warning(const std::string &msg){
- //print the warning message
- std::cerr << std::endl << "Warning:" << std::endl;
+/***********************************************************************
+ * Registry implementation
+ **********************************************************************/
+//create the registry for the handlers
+typedef uhd::dict<std::string, warning::handler_t> registry_t;
+UHD_SINGLETON_FCN(registry_t, get_registry)
+
+//the default warning handler
+static void stderr_warning(const std::string &msg){
+ std::cerr << msg;
+}
+
+//register a default handler
+UHD_STATIC_BLOCK(warning_register_default){
+ warning::register_handler("default", &stderr_warning);
+}
+
+/***********************************************************************
+ * Post + format
+ **********************************************************************/
+void warning::post(const std::string &msg){
+ std::stringstream ss;
+
+ //format the warning message
+ ss << std::endl << "Warning:" << std::endl;
BOOST_FOREACH(const std::string &line, std::split_string(msg, "\n")){
- std::cerr << " " << line << std::endl;
+ ss << " " << line << std::endl;
+ }
+
+ //post the formatted message
+ BOOST_FOREACH(const std::string &name, get_registry().keys()){
+ get_registry()[name](ss.str());
}
}
+
+/***********************************************************************
+ * Registry accessor functions
+ **********************************************************************/
+void warning::register_handler(
+ const std::string &name, const handler_t &handler
+){
+ get_registry()[name] = handler;
+}
+
+warning::handler_t warning::unregister_handler(const std::string &name){
+ if (not get_registry().has_key(name)) throw std::runtime_error(
+ "The warning registry does not have a handler registered to " + name
+ );
+ return get_registry().pop(name);
+}
+
+const std::vector<std::string> warning::registry_names(void){
+ return get_registry().keys();
+}