summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-03-10 22:28:08 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-03-10 22:28:08 +0100
commit83a57b493a992ea202faf2ce223b660d211c00d4 (patch)
tree941bd6b5e6b498fed1dccd4b11d5cdaaed96884c /src
parent0265c80544aac93e238bcfb2d61afc547c48a829 (diff)
downloaddabmod-83a57b493a992ea202faf2ce223b660d211c00d4.tar.gz
dabmod-83a57b493a992ea202faf2ce223b660d211c00d4.tar.bz2
dabmod-83a57b493a992ea202faf2ce223b660d211c00d4.zip
Support UHD 3.11 logging subsystem
Diffstat (limited to 'src')
-rw-r--r--src/output/UHD.cpp38
-rw-r--r--src/output/UHD.h1
2 files changed, 37 insertions, 2 deletions
diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp
index 6838338..04137cc 100644
--- a/src/output/UHD.cpp
+++ b/src/output/UHD.cpp
@@ -38,7 +38,19 @@
#include <boost/thread/future.hpp>
-#include <uhd/utils/msg.hpp>
+#include <uhd/version.hpp>
+// 3.11.0.0 introduces the API breaking change, where
+// uhd::msg is replaced by the new log API
+#if UHD_VERSION >= 3110000
+# define UHD_HAS_LOG_API 1
+# include <uhd/utils/log_add.hpp>
+# include <uhd/utils/thread.hpp>
+#else
+# define UHD_HAS_LOG_API 0
+# include <uhd/utils/msg.hpp>
+# include <uhd/utils/thread_priority.hpp>
+#endif
+
#include <cmath>
#include <iostream>
@@ -67,6 +79,19 @@ static std::string stringtrim(const std::string &s)
[](int c){ return std::isspace(c);} ).base());
}
+#if UHD_HAS_LOG_API == 1
+static void uhd_log_handler(const uhd::log::logging_info& info)
+{
+ // do not print very short U messages, nor those of
+ // verbosity trace or debug
+ if (info.verbosity >= uhd::log::info and
+ stringtrim(info.message).size() != 1) {
+ etiLog.level(debug) << "UHD Message (" <<
+ (int)info.verbosity << ") " <<
+ info.component << ": " << info.message;
+ }
+}
+#else
static void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
{
if (type == uhd::msg::warning) {
@@ -82,6 +107,7 @@ static void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
}
}
}
+#endif // UHD_HAS_LOG_API
@@ -103,7 +129,17 @@ UHD::UHD(SDRDeviceConfig& config) :
MDEBUG("OutputUHD::OutputUHD(device: %s) @ %p\n",
device.str().c_str(), this);
+#if UHD_HAS_LOG_API == 1
+ uhd::log::add_logger("dabmod", uhd_log_handler);
+ try {
+ uhd::log::set_console_level(uhd::log::fatal);
+ }
+ catch (const uhd::key_error&) {
+ etiLog.level(warn) << "OutputUHD: Could not set UHD console loglevel";
+ }
+#else
uhd::msg::register_handler(uhd_msg_handler);
+#endif
uhd::set_thread_priority_safe();
diff --git a/src/output/UHD.h b/src/output/UHD.h
index b34455c..0e9911c 100644
--- a/src/output/UHD.h
+++ b/src/output/UHD.h
@@ -37,7 +37,6 @@ DESCRIPTION:
#ifdef HAVE_OUTPUT_UHD
-#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <chrono>