diff options
author | Josh Blum <josh@joshknows.com> | 2011-05-04 18:36:10 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-05-04 18:36:10 -0700 |
commit | 7f01386f63850d9e13afb4033d1fae39f6a03764 (patch) | |
tree | fb68a49ac4d5a41c0af5e4135786c5f169211673 /host/lib | |
parent | e71d2833fbc2d9b87a8367b6ddc4388c3f182d93 (diff) | |
download | uhd-7f01386f63850d9e13afb4033d1fae39f6a03764.tar.gz uhd-7f01386f63850d9e13afb4033d1fae39f6a03764.tar.bz2 uhd-7f01386f63850d9e13afb4033d1fae39f6a03764.zip |
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.
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/transport/udp_zero_copy.cpp | 6 | ||||
-rw-r--r-- | host/lib/types/device_addr.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_basic_and_lf.cpp | 18 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_dbsrx.cpp | 26 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_rfx.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_sbx.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_tvrx.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_unknown.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_wbx_common.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 19 | ||||
-rw-r--r-- | host/lib/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/utils/log.cpp | 2 | ||||
-rw-r--r-- | host/lib/utils/msg.cpp | 109 | ||||
-rw-r--r-- | host/lib/utils/thread_priority.cpp | 6 | ||||
-rw-r--r-- | host/lib/utils/warning.cpp | 8 |
21 files changed, 179 insertions, 104 deletions
diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index 15d882676..c3ba085bf 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -20,7 +20,7 @@ #include <uhd/transport/udp_simple.hpp> //mtu #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/utils/log.hpp> #include <boost/format.hpp> #include <list> @@ -279,12 +279,12 @@ template<typename Opt> static void resize_buff_helper( "Target %s sock buff size: %d bytes\n" "Actual %s sock buff size: %d bytes" ) % name % target_size % name % actual_size << std::endl; - if (actual_size < target_size) uhd::warning::post(str(boost::format( + if (actual_size < target_size) UHD_MSG(warning) << boost::format( "The %s buffer could not be resized sufficiently.\n" "Target sock buff size: %d bytes.\n" "Actual sock buff size: %d bytes.\n" "See the transport application notes on buffer resizing.\n%s" - ) % name % target_size % actual_size % help_message)); + ) % name % target_size % actual_size % help_message; } } diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 193f76f8c..45d885adc 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -73,7 +73,7 @@ std::string device_addr_t::to_string(void) const{ return args_str; } -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ //------------ support old deprecated way and print warning -------- @@ -85,13 +85,13 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ for (size_t i = 0; i < addrs.size(); i++){ fixed_dev_addr[str(boost::format("addr%d") % i)] = addrs[i]; } - uhd::warning::post( + UHD_MSG(warning) << "addr = <space separated list of ip addresses> is deprecated.\n" "To address a multi-device, use multiple <key><index> = <val>.\n" "See the USRP-NXXX application notes. Two device example:\n" " addr0 = 192.168.10.2\n" " addr1 = 192.168.10.3\n" - ); + ; return separate_device_addr(fixed_dev_addr); } } 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 <uhd/types/ranges.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> @@ -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 <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> @@ -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 <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/usrp/dboard_id.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> @@ -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 <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> @@ -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 <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> @@ -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 <uhd/types/ranges.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> @@ -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 <uhd/types/sensors.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/usrp/dboard_base.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -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 <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> 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 <uhd/usrp/dboard_manager.hpp> #include <uhd/usrp/subdev_props.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/exception.hpp> @@ -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 <uhd/usrp/tune_helper.hpp> #include <uhd/usrp/mboard_iface.hpp> #include <uhd/exception.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/utils/gain_group.hpp> #include <uhd/usrp/subdev_props.hpp> #include <uhd/usrp/mboard_props.hpp> @@ -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_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::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 <uhd/usrp/mboard_props.hpp> #include <uhd/usrp/dboard_props.hpp> #include <uhd/usrp/subdev_props.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/images.hpp> #include <boost/assign/list_of.hpp> @@ -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 <uhd/transport/usb_control.hpp> #include <uhd/usrp/device_props.hpp> #include <uhd/usrp/mboard_props.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/images.hpp> @@ -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 <uhd/usrp/device_props.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/warning.hpp> #include <uhd/utils/byteswap.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> 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 <uhd/exception.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/images.hpp> -#include <uhd/utils/warning.hpp> #include <boost/format.hpp> #include <boost/filesystem.hpp> #include <boost/functional/hash.hpp> @@ -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); } } diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index ae18bde9d..0e0d51c78 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -132,6 +132,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/images.cpp ${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/msg.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp ${CMAKE_CURRENT_SOURCE_DIR}/props.cpp ${CMAKE_CURRENT_SOURCE_DIR}/static.cpp diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 0a2861cbd..d99ce01c4 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -167,7 +167,7 @@ private: UHD_SINGLETON_FCN(uhd_logger_stream_resource_class, uhd_logger_stream_resource); /*********************************************************************** - * The logger function implementation + * The logger object implementation **********************************************************************/ //! get the relative file path from the host directory static std::string get_rel_file_path(const fs::path &file){ diff --git a/host/lib/utils/msg.cpp b/host/lib/utils/msg.cpp new file mode 100644 index 000000000..de6d4c8fa --- /dev/null +++ b/host/lib/utils/msg.cpp @@ -0,0 +1,109 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> +#include <uhd/utils/static.hpp> +#include <boost/thread/mutex.hpp> +#include <boost/foreach.hpp> +#include <boost/tokenizer.hpp> +#include <sstream> +#include <iostream> + +/*********************************************************************** + * Helper functions + **********************************************************************/ +#define tokenizer(inp, sep) \ + boost::tokenizer<boost::char_separator<char> > \ + (inp, boost::char_separator<char>(sep)) + +static void msg_to_cout(const std::string &msg){ + std::stringstream ss; + + BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){ + ss << "-- " << line << std::endl; + } + + std::cout << ss.str(); +} + +static void msg_to_cerr(const std::string &title, const std::string &msg){ + std::stringstream ss; + + ss << std::endl << title << ":" << std::endl; + BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){ + ss << " " << line << std::endl; + } + + std::cerr << ss.str(); +} + +/*********************************************************************** + * Global settings for the messenger + **********************************************************************/ +static boost::mutex msg_mutex; +static std::ostringstream msg_ss; +static uhd::msg::type_t msg_type; +static uhd::msg::handler_t msg_handler; + +/*********************************************************************** + * Setup the message handlers + **********************************************************************/ +void uhd::msg::register_handler(const handler_t &handler){ + msg_mutex.lock(); + msg_handler = handler; + msg_mutex.unlock(); +} + +static void default_msg_handler(uhd::msg::type_t type, const std::string &msg){ + switch(type){ + case uhd::msg::status: + msg_to_cout(msg); + break; + + case uhd::msg::warning: + msg_to_cerr("UHD Warning", msg); + break; + + case uhd::msg::error: + msg_to_cerr("UHD Error", msg); + break; + } +} + +UHD_STATIC_BLOCK(msg_register_default_handler){ + uhd::msg::register_handler(&default_msg_handler); +} + +/*********************************************************************** + * The message object implementation + **********************************************************************/ +uhd::msg::_msg::_msg(const type_t type){ + msg_mutex.lock(); + msg_type = type; +} + +uhd::msg::_msg::~_msg(void){ + msg_handler(msg_type, msg_ss.str()); + UHD_LOG << "Message " << char(msg_type) << std::endl << msg_ss.str(); + msg_ss.str(""); //clear for next call + msg_mutex.unlock(); +} + +std::ostream & uhd::msg::_msg::get(void){ + return msg_ss; +} diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index a63bdf5ce..6d6ca5630 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -16,7 +16,7 @@ // #include <uhd/utils/thread_priority.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <iostream> @@ -26,11 +26,11 @@ bool uhd::set_thread_priority_safe(float priority, bool realtime){ set_thread_priority(priority, realtime); return true; }catch(const std::exception &e){ - uhd::warning::post(str(boost::format( + UHD_MSG(warning) << boost::format( "Unable to set the thread priority. Performance may be negatively affected.\n" "Please see the general application notes in the manual for instructions.\n" "%s\n" - ) % e.what())); + ) % e.what(); return false; } } diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp index 6a94a0a2c..87b6b24f5 100644 --- a/host/lib/utils/warning.cpp +++ b/host/lib/utils/warning.cpp @@ -39,13 +39,13 @@ 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; -} +//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); + //warning::register_handler("default", &stderr_warning); } /*********************************************************************** |