diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-01-05 14:59:03 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-01-10 12:25:13 -0800 |
commit | 02b407c92174717fd571ed7b1c85ebc0e5ac35c7 (patch) | |
tree | fad57e31f42c7d11ceb27526ba4b1c7b64a7ccc2 /host | |
parent | cf7f3d5a47929e04dbb2664ee163f59ff6f84b4a (diff) | |
download | uhd-02b407c92174717fd571ed7b1c85ebc0e5ac35c7.tar.gz uhd-02b407c92174717fd571ed7b1c85ebc0e5ac35c7.tar.bz2 uhd-02b407c92174717fd571ed7b1c85ebc0e5ac35c7.zip |
mpmd: Add API to read back logs from device and send to native logging
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.hpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_mboard_impl.cpp | 66 |
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 |