aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/mpmd/mpmd_impl.hpp5
-rw-r--r--host/lib/usrp/mpmd/mpmd_mboard_impl.cpp66
2 files changed, 71 insertions, 0 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.hpp b/host/lib/usrp/mpmd/mpmd_impl.hpp
index e71e83af6..f24f6d3fc 100644
--- a/host/lib/usrp/mpmd/mpmd_impl.hpp
+++ b/host/lib/usrp/mpmd/mpmd_impl.hpp
@@ -130,6 +130,11 @@ class mpmd_mboard_impl
const uhd::device_addr_t mb_args
);
+ /*! Read out the log buffer from the MPM device and send it to native
+ * logging system.
+ */
+ void dump_logs(const bool dump_to_null=false);
+
/*************************************************************************
* Private attributes
************************************************************************/
diff --git a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp
index 59983414a..bd37e5ffb 100644
--- a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp
+++ b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp
@@ -27,6 +27,8 @@ namespace {
//! Duration of a latency measurement test
constexpr size_t MPMD_MEAS_LATENCY_DURATION = 1000;
+ using log_buf_t = std::vector<std::map<std::string, std::string>>;
+
/*************************************************************************
* Helper functions
@@ -91,6 +93,61 @@ namespace {
<< ", n = " << ctr);
}
+ /*! Forward entries from a list of dictionaries to UHD's native logging
+ * system.
+ */
+ void forward_logs(log_buf_t&& log_buf)
+ {
+ for (const auto &log_record : log_buf) {
+ if (log_record.count("levelname") == 0 or \
+ log_record.count("message") == 0) {
+ UHD_LOG_ERROR("MPMD",
+ "Invalid logging structure returned from MPM device!");
+ continue;
+ }
+ if (log_record.at("levelname") == "TRACE") {
+ UHD_LOG_TRACE(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ }
+ else if (log_record.at("levelname") == "DEBUG") {
+ UHD_LOG_DEBUG(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ }
+ else if (log_record.at("levelname") == "INFO") {
+ UHD_LOG_INFO(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ }
+ else if (log_record.at("levelname") == "WARNING") {
+ UHD_LOG_WARNING(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ }
+ else if (log_record.at("levelname") == "ERROR") {
+ UHD_LOG_ERROR(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ }
+ else if (log_record.at("levelname") == "CRITICAL") {
+ UHD_LOG_FATAL(
+ log_record.at("name"),
+ log_record.at("message")
+ );
+ } else {
+ UHD_LOG_ERROR("MPMD",
+ "Invalid log level returned from MPM device: "
+ "`" << log_record.at("levelname") << "'");
+ }
+ }
+ }
+
}
using namespace uhd;
@@ -304,6 +361,15 @@ uhd::task::sptr mpmd_mboard_impl::claim_device_and_make_task(
});
}
+void mpmd_mboard_impl::dump_logs(const bool dump_to_null)
+{
+ if (dump_to_null) {
+ rpc->request_with_token<log_buf_t>("get_log_buf");
+ } else {
+ forward_logs(rpc->request_with_token<log_buf_t>("get_log_buf"));
+ }
+}
+
/*****************************************************************************
* Factory