aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-02-07 16:37:25 -0800
committerMartin Braun <martin.braun@ettus.com>2017-02-20 17:13:15 -0800
commit21aad77c9ca07f4271136b9241f5adb00a6bb908 (patch)
tree636ffe3ab2296e9afa661d3a12eb359224cd3254 /host/utils
parent2b33f2bb4c01d4306fd46f78edf6e355a03e2ed7 (diff)
downloaduhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.gz
uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.bz2
uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.zip
utils: introduce new logging API and remove msg API
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/latency/include/Responder.hpp5
-rw-r--r--host/utils/latency/lib/Responder.cpp62
-rw-r--r--host/utils/uhd_cal_rx_iq_balance.cpp3
-rw-r--r--host/utils/uhd_cal_tx_dc_offset.cpp3
-rw-r--r--host/utils/uhd_cal_tx_iq_balance.cpp2
-rw-r--r--host/utils/usrp_cal_utils.hpp5
-rw-r--r--host/utils/usrp_e3x0_network_mode.cpp5
7 files changed, 29 insertions, 56 deletions
diff --git a/host/utils/latency/include/Responder.hpp b/host/utils/latency/include/Responder.hpp
index a9f616a24..7ee910500 100644
--- a/host/utils/latency/include/Responder.hpp
+++ b/host/utils/latency/include/Responder.hpp
@@ -24,7 +24,6 @@
#include <stdint.h>
#include <uhd/usrp/multi_usrp.hpp>
-#include <uhd/utils/msg.hpp>
using namespace std;
@@ -141,9 +140,6 @@ class Responder
// Main entry point after constructor.
int run();
- // Public method to inject UHD messages in the main ncurses window.
- void print_uhd_late_handler(uhd::msg::type_t type, const std::string& msg);
-
int get_return_code(){return _return_code;}
protected:
@@ -151,6 +147,7 @@ class Responder
// These 2 variables are used for ncurses output.
WINDOW* _window;
std::stringstream _ss;
+ std::stringstream _ss_cerr;
// struct which holds all arguments as constants settable from outside the class
const Options _opt;
diff --git a/host/utils/latency/lib/Responder.cpp b/host/utils/latency/lib/Responder.cpp
index e5be9e275..ba278f338 100644
--- a/host/utils/latency/lib/Responder.cpp
+++ b/host/utils/latency/lib/Responder.cpp
@@ -23,51 +23,33 @@
#include <complex>
#include <csignal>
#include <cmath>
+#include <sstream>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/thread/condition_variable.hpp>
#include <boost/filesystem.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/property_tree.hpp>
const std::string _eth_file("eths_info.txt");
-// UHD screen handler during initialization. Error messages will be printed to log file
-static std::string uhd_error_msgs;
-static void screen_handler(uhd::msg::type_t type, const std::string& msg)
-{
- printw( msg.c_str() );
- //printw("\n");
- refresh();
- if(type == uhd::msg::error){
- uhd_error_msgs.append(msg);
- uhd_error_msgs.append("\n");
- }
-}
-// UHD screen handler during test run. Error messages will be printed to log file
-static int s_late_count = 0;
-static Responder* s_responder; // needed here to have a way to inject uhd msg into Responder.
-// function is only called by UHD, if s_responder points to a valid instance.
-// this instance sets the function to be the output callback for UHD.
-static void _late_handler(uhd::msg::type_t type, const std::string& msg)
-{
- s_responder->print_uhd_late_handler(type, msg);
-}
+// Redirect output to stderr
+struct cerr_redirect {
+ cerr_redirect( std::streambuf * new_buffer )
+ : old( std::cerr.rdbuf( new_buffer ) )
+ { }
-void Responder::print_uhd_late_handler(uhd::msg::type_t type, const std::string& msg)
-{
- if (msg == "L") // This is just a test
- {
- ++s_late_count;
- }
- if(type == uhd::msg::error){
- uhd_error_msgs.append(msg);
- uhd_error_msgs.append("\n");
- // Only print error messages. There will be very many 'L's due to the way the test works.
- print_msg(msg);
+ ~cerr_redirect( ) {
+ std::cerr.rdbuf( old );
}
-}
+
+private:
+ std::streambuf * old;
+};
+
+
// Catch keyboard interrupts for clean manual abort
static bool s_stop_signal_called = false;
@@ -132,7 +114,9 @@ Responder::Responder( Options& opt)
_last_overrun_count(0)
{
time( &_dbginfo.start_time ); // for debugging
- s_responder = this;
+
+ // Disable logging to console
+ uhd::log::set_console_level(uhd::log::off);
if (uhd::set_thread_priority_safe(_opt.rt_priority, _opt.realtime) == false) // try to set realtime scheduling
{
@@ -141,7 +125,6 @@ Responder::Responder( Options& opt)
_return_code = calculate_dependent_values();
- uhd::msg::register_handler(&screen_handler); // used to print USRP initialization status
// From this point on, everything is written to a ncurses window!
create_ncurses_window();
@@ -180,7 +163,9 @@ Responder::Responder( Options& opt)
}
// set up handlers for test run
- uhd::msg::register_handler(&_late_handler); // capture UHD output.
+ // uhd::msg::register_handler(&_late_handler); // capture UHD output.
+
+ cerr_redirect(_ss_cerr.rdbuf());
register_stop_signal_handler();
}
@@ -1211,11 +1196,6 @@ Responder::write_log_file()
write_debug_info(logs);
- if(uhd_error_msgs.length() > 0)
- {
- logs << endl << "%% UHD ERROR MESSAGES %%" << endl;
- logs << uhd_error_msgs;
- }
}
}
catch(...)
diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp
index 99a5abdda..d599a4e03 100644
--- a/host/utils/uhd_cal_rx_iq_balance.cpp
+++ b/host/utils/uhd_cal_rx_iq_balance.cpp
@@ -20,7 +20,6 @@
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/msg.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
@@ -184,7 +183,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
return EXIT_FAILURE;
}
- UHD_MSG(status) << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
+ std::cout << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
for (double rx_lo_i = freq_start; rx_lo_i <= freq_stop; rx_lo_i += freq_step)
{
diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp
index 8b12f7e95..e3cdc087e 100644
--- a/host/utils/uhd_cal_tx_dc_offset.cpp
+++ b/host/utils/uhd_cal_tx_dc_offset.cpp
@@ -20,7 +20,6 @@
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/msg.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
@@ -192,7 +191,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
return EXIT_FAILURE;
}
- UHD_MSG(status) << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
+ std::cout << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
//set RX gain
usrp->set_rx_gain(0);
diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp
index f08f8c9d1..445b86694 100644
--- a/host/utils/uhd_cal_tx_iq_balance.cpp
+++ b/host/utils/uhd_cal_tx_iq_balance.cpp
@@ -189,7 +189,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
return EXIT_FAILURE;
}
- UHD_MSG(status) << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
+ std::cout << boost::format("Calibration frequency range: %d MHz -> %d MHz") % (freq_start/1e6) % (freq_stop/1e6) << std::endl;
for (double tx_lo_i = freq_start; tx_lo_i <= freq_stop; tx_lo_i += freq_step)
{
diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp
index ccdb0a61d..0b807e341 100644
--- a/host/utils/usrp_cal_utils.hpp
+++ b/host/utils/usrp_cal_utils.hpp
@@ -21,7 +21,6 @@
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/msg.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <iostream>
@@ -303,9 +302,9 @@ static uhd::usrp::multi_usrp::sptr setup_usrp_for_cal(std::string &args, std::st
usrp->set_tx_subdev_spec(subdev);
usrp->set_rx_subdev_spec(subdev);
}
- UHD_MSG(status) << "Running calibration for " << usrp->get_tx_subdev_name(0) << std::endl;
+ std::cout << "Running calibration for " << usrp->get_tx_subdev_name(0);
serial = get_serial(usrp, "tx");
- UHD_MSG(status) << "Daughterboard serial: " << serial << std::endl;
+ std::cout << "Daughterboard serial: " << serial;
//set the antennas to cal
if (not uhd::has(usrp->get_rx_antennas(), "CAL") or not uhd::has(usrp->get_tx_antennas(), "CAL"))
diff --git a/host/utils/usrp_e3x0_network_mode.cpp b/host/utils/usrp_e3x0_network_mode.cpp
index dae4b6ff7..881c6c8ca 100644
--- a/host/utils/usrp_e3x0_network_mode.cpp
+++ b/host/utils/usrp_e3x0_network_mode.cpp
@@ -19,7 +19,6 @@
#include <uhd/device.hpp>
#include <uhd/exception.hpp>
-#include <uhd/utils/msg.hpp>
#include <uhd/transport/if_addrs.hpp>
#include <boost/program_options.hpp>
@@ -69,11 +68,11 @@ int main(int argc, char *argv[])
uhd::usrp::e300::network_server::sptr server = uhd::usrp::e300::network_server::make(args);
server->run();
} catch (uhd::assertion_error &e) {
- UHD_MSG(error) << "This executable is supposed to run on the device, not on the host." << std::endl
+ std::cout << "This executable is supposed to run on the device, not on the host." << std::endl
<< "Please refer to the manual section on operating your e3x0 device in network mode." << std::endl;
return EXIT_FAILURE;
} catch (uhd::runtime_error &e) {
- UHD_MSG(error) << e.what() << std::endl;
+ std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;