From 7f01386f63850d9e13afb4033d1fae39f6a03764 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 4 May 2011 18:36:10 -0700 Subject: uhd: replaced warning post with calls to UHD_MSG(warning) The message api can support warnings, error, and status messages. The default handler is to stdio, but the user can change this. --- host/lib/usrp/dboard/db_basic_and_lf.cpp | 18 +++++++----------- host/lib/usrp/dboard/db_dbsrx.cpp | 26 +++++++++----------------- host/lib/usrp/dboard/db_rfx.cpp | 10 +++------- host/lib/usrp/dboard/db_sbx.cpp | 10 +++------- host/lib/usrp/dboard/db_tvrx.cpp | 6 ++---- host/lib/usrp/dboard/db_unknown.cpp | 14 +++++--------- host/lib/usrp/dboard/db_wbx_common.cpp | 10 +++------- host/lib/usrp/dboard/db_xcvr2450.cpp | 1 - host/lib/usrp/dboard_manager.cpp | 8 ++++---- host/lib/usrp/multi_usrp.cpp | 14 +++++++------- host/lib/usrp/usrp1/mboard_impl.cpp | 4 ++-- host/lib/usrp/usrp1/usrp1_impl.cpp | 4 ++-- host/lib/usrp/usrp2/usrp2_impl.cpp | 1 - host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 19 ++++++++----------- 14 files changed, 55 insertions(+), 90 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 3fffeab0c..6f8de9a7b 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -202,11 +202,9 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ 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 - ) - ); + UHD_MSG(warning) << 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(); @@ -309,11 +307,9 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ 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 - ) - ); + UHD_MSG(warning) << 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 dbe2f6370..cfe06db29 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -175,25 +175,21 @@ 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::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % this->get_rx_id().to_pp_string()) - ); + ) % this->get_rx_id().to_pp_string(); //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::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x000D and R194\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % this->get_rx_id().to_pp_string()) - ); + ) % this->get_rx_id().to_pp_string(); //enable only the clocks we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); @@ -342,11 +338,9 @@ 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::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" - ) % int(_max2118_write_regs.osc_band)) - ); + ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 0); //just to cause a throw } if (_max2118_write_regs.osc_band <= 0) break; @@ -356,11 +350,9 @@ 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::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" - ) % int(_max2118_write_regs.osc_band)) - ); + ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 7); //just to cause a throw } if (_max2118_write_regs.osc_band >= 7) break; diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 1f0290179..61f9130d4 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -514,9 +514,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("RFX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "RFX: No tunable bandwidth, fixed filtered to 40MHz"; return; default: UHD_THROW_PROP_SET_ERROR(); @@ -616,9 +614,7 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("RFX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "RFX: No tunable bandwidth, fixed filtered to 40MHz"; return; default: UHD_THROW_PROP_SET_ERROR(); diff --git a/host/lib/usrp/dboard/db_sbx.cpp b/host/lib/usrp/dboard/db_sbx.cpp index 4d8753fab..6ca89b81a 100644 --- a/host/lib/usrp/dboard/db_sbx.cpp +++ b/host/lib/usrp/dboard/db_sbx.cpp @@ -81,7 +81,7 @@ #include #include #include -#include +#include #include #include #include @@ -674,9 +674,7 @@ void sbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("SBX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "SBX: No tunable bandwidth, fixed filtered to 40MHz"; return; default: UHD_THROW_PROP_SET_ERROR(); @@ -780,9 +778,7 @@ void sbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("SBX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "SBX: 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 cd7216c22..1ff0fb785 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -485,9 +485,7 @@ void tvrx::rx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("TVRX: No tunable bandwidth, fixed filtered to 6MHz")) - ); + UHD_MSG(warning) << "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 cef4bee4a..6cacab231 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,11 +50,11 @@ static void warn_if_old_rfx(const dboard_id_t &dboard_id, const std::string &xx) if ( (xx == "RX" and rx_id == dboard_id) or (xx == "TX" and tx_id == dboard_id) - ) uhd::warning::post(str(boost::format( + ) UHD_MSG(warning) << boost::format( "Detected %s daughterboard %s\n" "This board requires modification to use.\n" "See the daughterboard application notes.\n" - ) % xx % name)); + ) % xx % name; } } @@ -183,9 +183,7 @@ void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("Unknown Daughterboard: No tunable bandwidth, fixed filtered to 0.0MHz")) - ); + UHD_MSG(warning) << "Unknown Daughterboard: No tunable bandwidth, fixed filtered to 0.0MHz"; return; default: UHD_THROW_PROP_SET_ERROR(); @@ -281,9 +279,7 @@ void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){ return; //always enabled case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("Unknown Daughterboard: No tunable bandwidth, fixed filtered to 0.0MHz")) - ); + UHD_MSG(warning) << "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_common.cpp b/host/lib/usrp/dboard/db_wbx_common.cpp index fdee14607..131729f42 100644 --- a/host/lib/usrp/dboard/db_wbx_common.cpp +++ b/host/lib/usrp/dboard/db_wbx_common.cpp @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include @@ -472,9 +472,7 @@ void wbx_base::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("WBX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "WBX: No tunable bandwidth, fixed filtered to 40MHz"; return; default: UHD_THROW_PROP_SET_ERROR(); @@ -572,9 +570,7 @@ void wbx_base::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_BANDWIDTH: - uhd::warning::post( - str(boost::format("WBX: No tunable bandwidth, fixed filtered to 40MHz")) - ); + UHD_MSG(warning) << "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 4bda43251..c775eae38 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index cd934dd0d..11b72b9fa 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -18,7 +18,7 @@ #include "dboard_ctor_args.hpp" #include #include -#include +#include #include #include #include @@ -240,7 +240,7 @@ dboard_manager_impl::dboard_manager_impl( this->init(rx_dboard_id, tx_dboard_id); } catch(const std::exception &e){ - uhd::warning::post(e.what()); + UHD_MSG(error) << "The daughterboard manager encountered a recoverable error in init" << std::endl << e.what(); this->init(dboard_id_t::none(), dboard_id_t::none()); } } @@ -264,12 +264,12 @@ void dboard_manager_impl::init( //warn for invalid dboard id xcvr combinations if (not xcvr_dboard_key.is_xcvr() and (rx_dboard_key.is_xcvr() or tx_dboard_key.is_xcvr())){ - uhd::warning::post(str(boost::format( + UHD_MSG(warning) << boost::format( "Unknown transceiver board ID combination.\n" "Is your daughter-board mounted properly?\n" "RX dboard ID: %s\n" "TX dboard ID: %s\n" - ) % rx_dboard_id.to_pp_string() % tx_dboard_id.to_pp_string())); + ) % rx_dboard_id.to_pp_string() % tx_dboard_id.to_pp_string(); } //initialize the gpio pins before creating subdevs diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 83cbf339b..2b32602da 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,11 +55,11 @@ 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::warning::post(str(boost::format( + UHD_MSG(warning) << 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" - ) % xx % (target_rate/1e6) % (actual_rate/1e6))); + ) % xx % (target_rate/1e6) % (actual_rate/1e6); } } @@ -70,11 +70,11 @@ 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::warning::post(str(boost::format( + UHD_MSG(warning) << boost::format( "The hardware does not support the requested %s frequency:\n" "Target frequency: %f MHz\n" "Actual frequency: %f MHz\n" - ) % xx % (target_freq/1e6) % (actual_freq/1e6))); + ) % xx % (target_freq/1e6) % (actual_freq/1e6); } } @@ -211,11 +211,11 @@ public: time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as(); time_spec_t time_i = _mboard(m)[MBOARD_PROP_TIME_NOW].as(); 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::warning::post(str(boost::format( + UHD_MSG(warning) << 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" - ) % m % time_0.get_real_secs() % m % time_i.get_real_secs())); + ) % m % time_0.get_real_secs() % m % time_i.get_real_secs(); } } } diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index eecae3fa7..aa9ce244b 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -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::warning::post( + if (num_quads != 0 and num_reals != 0) UHD_MSG(warning) << boost::format( "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 a99777775..b7cd95a82 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) usrp1_fw_image = find_image_path(hint.get("fw", "usrp1_fw.ihx")); } catch(...){ - uhd::warning::post( + UHD_MSG(warning) << boost::format( "Could not locate USRP1 firmware.\n" "Please install the images package.\n" ); diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 77370a7fd..558bcab2a 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp index fe839c409..3fa60232e 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -58,18 +57,16 @@ static device_addrs_t usrp_e100_find(const device_addr_t &hint){ usrp_e100_iface::sptr iface = usrp_e100_iface::make(new_addr["node"]); new_addr["name"] = iface->mb_eeprom["name"]; new_addr["serial"] = iface->mb_eeprom["serial"]; - if ( - (not hint.has_key("name") or hint["name"] == new_addr["name"]) and - (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]) - ){ - usrp_e100_addrs.push_back(new_addr); - } } catch(const std::exception &e){ - uhd::warning::post( - std::string("Ignoring discovered device\n") - + e.what() - ); + new_addr["name"] = ""; + new_addr["serial"] = ""; + } + if ( + (not hint.has_key("name") or hint["name"] == new_addr["name"]) and + (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]) + ){ + usrp_e100_addrs.push_back(new_addr); } } -- cgit v1.2.3