From 828c811f79261a78594160036f782786969bc704 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Wed, 30 Oct 2019 23:44:39 +0300 Subject: [PATCH] Fix uhd/utils/msg.hpp missing in newer UHD --- host/CMakeLists.txt | 7 +++++++ host/cores/apply_corrections.cpp | 2 +- host/cores/async_packet_handler.hpp | 8 ++++---- host/cores/rx_dsp_core_200.cpp | 2 +- host/cores/super_recv_packet_handler.hpp | 6 +++--- host/cores/super_send_packet_handler.hpp | 2 +- host/cores/tx_dsp_core_200.cpp | 2 +- host/lms6002d_ctrl.cpp | 2 +- host/power_amp.cpp | 2 +- host/umtrx_fifo_ctrl.cpp | 2 +- host/umtrx_find.cpp | 2 +- host/umtrx_iface.cpp | 2 +- host/umtrx_impl.cpp | 2 +- host/umtrx_log_adapter.hpp | 24 ++++++++++++++++++++++++ host/umtrx_monitor.cpp | 2 +- host/utils/usrp_cal_utils.hpp | 2 +- 16 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 host/umtrx_log_adapter.hpp diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 0b2646edf..81adc0456 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -77,6 +77,13 @@ list(APPEND UMTRX_LIBRARIES ${UHD_LIBRARIES}) MESSAGE(STATUS "UHD include directories: ${UHD_INCLUDE_DIRS}") MESSAGE(STATUS "UHD libraries: ${UHD_LIBRARIES}") +if (EXISTS "${UHD_INCLUDE_DIRS}/uhd/utils/msg.hpp") + add_definitions(-DUHD_HAS_MSG_HPP) + message(STATUS " use msg.hpp for logging") +else() + message(STATUS " use log.hpp for logging") +endif() + ######################################################################## # Setup Boost ######################################################################## diff --git a/host/cores/apply_corrections.cpp b/host/cores/apply_corrections.cpp index 4f483d386..54ae9ed95 100644 --- a/host/cores/apply_corrections.cpp +++ b/host/cores/apply_corrections.cpp @@ -18,7 +18,7 @@ #include "apply_corrections.hpp" #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/cores/async_packet_handler.hpp b/host/cores/async_packet_handler.hpp index fef03483f..65cc10026 100644 --- a/host/cores/async_packet_handler.hpp +++ b/host/cores/async_packet_handler.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include "umtrx_log_adapter.hpp" namespace uhd{ namespace usrp{ @@ -55,14 +55,14 @@ namespace uhd{ namespace usrp{ if (metadata.event_code & ( async_metadata_t::EVENT_CODE_UNDERFLOW | async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET) - ) UHD_MSG(fastpath) << "U"; + ) {UHD_LOG_FASTPATH("U");} else if (metadata.event_code & ( async_metadata_t::EVENT_CODE_SEQ_ERROR | async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST) - ) UHD_MSG(fastpath) << "S"; + ) {UHD_LOG_FASTPATH("S");} else if (metadata.event_code & async_metadata_t::EVENT_CODE_TIME_ERROR - ) UHD_MSG(fastpath) << "L"; + ) {UHD_LOG_FASTPATH("L");} } diff --git a/host/cores/rx_dsp_core_200.cpp b/host/cores/rx_dsp_core_200.cpp index bb419ae1f..0127eacdc 100644 --- a/host/cores/rx_dsp_core_200.cpp +++ b/host/cores/rx_dsp_core_200.cpp @@ -18,7 +18,7 @@ #include "rx_dsp_core_200.hpp" #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/cores/super_recv_packet_handler.hpp b/host/cores/super_recv_packet_handler.hpp index 348271a21..7a4402e3e 100644 --- a/host/cores/super_recv_packet_handler.hpp +++ b/host/cores/super_recv_packet_handler.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include @@ -559,7 +559,7 @@ class recv_packet_handler{ rx_metadata_t metadata = curr_info.metadata; _props[index].handle_overflow(); curr_info.metadata = metadata; - UHD_MSG(fastpath) << "O"; + UHD_LOG_FASTPATH("O"); } return; @@ -576,7 +576,7 @@ class recv_packet_handler{ prev_info[index].ifpi.num_payload_words32*sizeof(boost::uint32_t)/_bytes_per_otw_item, _samp_rate); curr_info.metadata.out_of_sequence = true; curr_info.metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW; - UHD_MSG(fastpath) << "D"; + UHD_LOG_FASTPATH("D"); return; } diff --git a/host/cores/super_send_packet_handler.hpp b/host/cores/super_send_packet_handler.hpp index d8c7cfc2b..b333e5d04 100644 --- a/host/cores/super_send_packet_handler.hpp +++ b/host/cores/super_send_packet_handler.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/cores/tx_dsp_core_200.cpp b/host/cores/tx_dsp_core_200.cpp index f8aa87aa3..08f187d7d 100644 --- a/host/cores/tx_dsp_core_200.cpp +++ b/host/cores/tx_dsp_core_200.cpp @@ -18,7 +18,7 @@ #include "tx_dsp_core_200.hpp" #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/lms6002d_ctrl.cpp b/host/lms6002d_ctrl.cpp index 96c47e8f3..b86a5df99 100644 --- a/host/lms6002d_ctrl.cpp +++ b/host/lms6002d_ctrl.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/power_amp.cpp b/host/power_amp.cpp index 9d2dc5f23..639c0bd72 100644 --- a/host/power_amp.cpp +++ b/host/power_amp.cpp @@ -1,5 +1,5 @@ #include "power_amp.hpp" -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/umtrx_fifo_ctrl.cpp b/host/umtrx_fifo_ctrl.cpp index 2220e4136..ba157aae5 100644 --- a/host/umtrx_fifo_ctrl.cpp +++ b/host/umtrx_fifo_ctrl.cpp @@ -17,7 +17,7 @@ #include "umtrx_regs.hpp" #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include "umtrx_fifo_ctrl.hpp" diff --git a/host/umtrx_find.cpp b/host/umtrx_find.cpp index a47aafafa..3a9462628 100644 --- a/host/umtrx_find.cpp +++ b/host/umtrx_find.cpp @@ -17,7 +17,7 @@ #include "usrp2/fw_common.h" #include "umtrx_iface.hpp" -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/umtrx_iface.cpp b/host/umtrx_iface.cpp index fb4dcc910..c281d1a52 100644 --- a/host/umtrx_iface.cpp +++ b/host/umtrx_iface.cpp @@ -20,7 +20,7 @@ #include "umtrx_impl.hpp" #include "umtrx_iface.hpp" #include -#include +#include "umtrx_log_adapter.hpp" #include "missing/platform.hpp" #include #include diff --git a/host/umtrx_impl.cpp b/host/umtrx_impl.cpp index 9a128e49a..c365630c9 100644 --- a/host/umtrx_impl.cpp +++ b/host/umtrx_impl.cpp @@ -18,9 +18,9 @@ #include "umtrx_impl.hpp" #include "umtrx_regs.hpp" #include "umtrx_version.hpp" +#include "umtrx_log_adapter.hpp" #include "cores/apply_corrections.hpp" #include -#include #include #include //sleep #include diff --git a/host/umtrx_log_adapter.hpp b/host/umtrx_log_adapter.hpp new file mode 100644 index 000000000..c41d27545 --- /dev/null +++ b/host/umtrx_log_adapter.hpp @@ -0,0 +1,24 @@ +#ifndef UMTRX_LOG_ADAPTER_HPP +#define UMTRX_LOG_ADAPTER_HPP + +#ifdef UHD_HAS_MSG_HPP +#include + +#define UHD_LOG_FASTPATH(message) UHD_MSG(fastpath) << (message) + +#else // UHD_HAS_MSG_HPP +#include + +enum { + _uhd_log_level_status, + _uhd_log_level_warning, + _uhd_log_level_error +}; + +#define UHD_MSG(severity) ((_uhd_log_level_##severity==_uhd_log_level_status)?UHD_LOGGER_INFO("UmTRX"): \ + (_uhd_log_level_##severity==_uhd_log_level_warning)?UHD_LOGGER_WARNING("UmTRX"): \ + UHD_LOGGER_ERROR("UmTRX")) + +#endif // UHD_HAS_MSG_HPP + +#endif // UMTRX_LOG_ADAPTER_HPP diff --git a/host/umtrx_monitor.cpp b/host/umtrx_monitor.cpp index 06284a303..1f0cbce31 100644 --- a/host/umtrx_monitor.cpp +++ b/host/umtrx_monitor.cpp @@ -16,7 +16,7 @@ // #include "umtrx_impl.hpp" -#include +#include "umtrx_log_adapter.hpp" #include #include #include diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index 876793e4a..e3507c266 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include "umtrx_log_adapter.hpp" #include #include #include