From 1898c37e433b36ccd1046137bc4c984b3307b4ec Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Fri, 7 Oct 2011 13:43:24 -0400 Subject: [PATCH] transceiver: reroute UHD messages to logging facility Pipe the following uhd message types to standard warning levels (INFO, WARN, ERROR) respectively. Ignore fastpath logging messages and, instead, catch them from the asynchronous device interface. enum type_t{ status = 's', warning = 'w', error = 'e', fastpath= 'f' }; Signed-off-by: Thomas Tsou --- public-trunk/Transceiver52M/UHDDevice.cpp | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/public-trunk/Transceiver52M/UHDDevice.cpp b/public-trunk/Transceiver52M/UHDDevice.cpp index ef5b2fc..9cdde8f 100644 --- a/public-trunk/Transceiver52M/UHDDevice.cpp +++ b/public-trunk/Transceiver52M/UHDDevice.cpp @@ -27,6 +27,7 @@ #include "Logger.h" #include #include +#include /* use_ext_ref - Enable external 10MHz clock reference @@ -233,6 +234,28 @@ void *async_event_loop(uhd_device *dev) } } +/* + Catch and drop underrun 'U' and overrun 'O' messages from stdout + since we already report using the logging facility. Direct + everything else appropriately. + */ +void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) +{ + switch (type) { + case uhd::msg::status: + LOG(INFO) << msg; + break; + case uhd::msg::warning: + LOG(WARN) << msg; + break; + case uhd::msg::error: + LOG(ERROR) << msg; + break; + case uhd::msg::fastpath: + break; + } +} + uhd_device::uhd_device(double rate, bool skip_rx) : desired_smpl_rt(rate), actual_smpl_rt(0), tx_gain(0.0), tx_gain_min(0.0), tx_gain_max(0.0), @@ -343,6 +366,9 @@ bool uhd_device::open() { LOG(INFO) << "creating USRP device..."; + // Register msg handler + uhd::msg::register_handler(&uhd_msg_handler); + // Allow all UHD devices uhd::device_addr_t dev_addr(""); try {