diff options
177 files changed, 1387 insertions, 1415 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 368db6309..aab71d7e8 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -305,6 +305,7 @@ MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}") # Note: RFNoC never gets fully disabled, but the public APIs do SET(ENABLE_RFNOC OFF CACHE BOOL "Export RFNoC includes and symbols") INCLUDE(UHDGlobalDefs) +INCLUDE(UHDLog) ######################################################################## # Check Python Modules diff --git a/host/cmake/Modules/UHDLog.cmake b/host/cmake/Modules/UHDLog.cmake new file mode 100644 index 000000000..d5612f1ed --- /dev/null +++ b/host/cmake/Modules/UHDLog.cmake @@ -0,0 +1,57 @@ +######################################################################## +# Logging Variables +######################################################################## +IF(CMAKE_BUILD_TYPE STREQUAL "Debug") + SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + SET(UHD_LOG_FILE_LEVEL "trace" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_LEVEL "debug" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +ELSE() + SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + SET(UHD_LOG_FILE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +ENDIF() + +FUNCTION(UHD_LOG_LEVEL_CONVERT ARG1 ARG2) + string(TOLOWER "${ARG1}" LOG_LEVEL_LOWER) + IF(LOG_LEVEL_LOWER STREQUAL "trace") + ADD_DEFINITIONS(-D${ARG2}=0) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "debug") + ADD_DEFINITIONS(-D${ARG2}=1) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "info") + ADD_DEFINITIONS(-D${ARG2}=2) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "warning") + ADD_DEFINITIONS(-D${ARG2}=3) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "error") + ADD_DEFINITIONS(-D${ARG2}=4) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "fatal") + ADD_DEFINITIONS(-D${ARG2}=5) + ELSE() + ADD_DEFINITIONS(-D${ARG2}=${ARG1}) + ENDIF() +ENDFUNCTION() + +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_MIN_LEVEL} "UHD_LOG_MIN_LEVEL") +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_CONSOLE_LEVEL} "UHD_LOG_CONSOLE_LEVEL") +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_FILE_LEVEL} "UHD_LOG_FILE_LEVEL") + +IF(UHD_LOG_CONSOLE_DISABLE) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_DISABLE) +ELSE() + IF(UHD_LOG_CONSOLE_TIME) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_TIME) + ENDIF() + IF(UHD_LOG_CONSOLE_THREAD) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_THREAD) + ENDIF() + IF(UHD_LOG_CONSOLE_SRC) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_SRC) + ENDIF() +ENDIF() + +SET(UHD_LOG_FILE "" CACHE FILE "Set UHD log file to a file in a existing directory") +IF(NOT UHD_LOG_FILE STREQUAL "") + ADD_DEFINITIONS(-DUHD_LOG_FILE=${UHD_LOG_FILE}) +ENDIF() + diff --git a/host/docs/general.dox b/host/docs/general.dox index ff407a304..06a8887c9 100644 --- a/host/docs/general.dox +++ b/host/docs/general.dox @@ -219,7 +219,7 @@ registered at a time. Make **register_handler** your first call into the UHD library: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} -#include <uhd/utils/msg.hpp> + void my_handler(uhd::msg::type_t type, const std::string &msg){ //handle the message... diff --git a/host/include/uhd/rfnoc/node_ctrl_base.hpp b/host/include/uhd/rfnoc/node_ctrl_base.hpp index 6fd6fd288..0505556ec 100644 --- a/host/include/uhd/rfnoc/node_ctrl_base.hpp +++ b/host/include/uhd/rfnoc/node_ctrl_base.hpp @@ -32,7 +32,7 @@ namespace uhd { namespace rfnoc { -#define UHD_RFNOC_BLOCK_TRACE() UHD_LOGV(never) << "[" << unique_id() << "] " +#define UHD_RFNOC_BLOCK_TRACE() UHD_LOGGER_TRACE("RFNOC") /*! \brief Abstract base class for streaming nodes. * diff --git a/host/include/uhd/rfnoc/node_ctrl_base.ipp b/host/include/uhd/rfnoc/node_ctrl_base.ipp index d300f72a7..df92e2e8b 100644 --- a/host/include/uhd/rfnoc/node_ctrl_base.ipp +++ b/host/include/uhd/rfnoc/node_ctrl_base.ipp @@ -21,7 +21,7 @@ #define INCLUDED_LIBUHD_NODE_CTRL_BASE_IPP #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> + #include <boost/shared_ptr.hpp> #include <vector> diff --git a/host/include/uhd/transport/nirio/nirio_quirks.h b/host/include/uhd/transport/nirio/nirio_quirks.h index 45ef40394..f98432d6b 100644 --- a/host/include/uhd/transport/nirio/nirio_quirks.h +++ b/host/include/uhd/transport/nirio/nirio_quirks.h @@ -44,7 +44,7 @@ public: UHD_INLINE void add_tx_fifo(uint32_t index) { if (_tx_stream_fifo_indices.find(index) != _tx_stream_fifo_indices.end()) { if (_tx_stream_count == 0) { - UHD_LOG << "NI-RIO RX FIFO Transfer Check Quirk Enabled."; + UHD_LOGGER_DEBUG("NIRIO") << "NI-RIO RX FIFO Transfer Check Quirk Enabled."; } _tx_stream_count++; } @@ -54,7 +54,7 @@ public: if (_tx_stream_fifo_indices.find(index) != _tx_stream_fifo_indices.end()) { _tx_stream_count--; if (_tx_stream_count == 0) { - UHD_LOG << "NI-RIO RX FIFO Transfer Check Quirk Disabled."; + UHD_LOGGER_DEBUG("NIRIO") << "NI-RIO RX FIFO Transfer Check Quirk Disabled."; } } } diff --git a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp index 78761c1fc..422f57e8a 100644 --- a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp +++ b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp @@ -65,11 +65,11 @@ private: inline void _stop_io_service() { if (_io_service_thread.get()) { - UHD_LOG << "rpc_client stopping..." << std::endl; + UHD_LOGGER_INFO("NIRIO") << "rpc_client stopping..."; _io_service.stop(); _io_service_thread->join(); _io_service_thread.reset(); - UHD_LOG << "rpc_client stopped." << std::endl; + UHD_LOGGER_INFO("NIRIO") << "rpc_client stopped."; } } diff --git a/host/include/uhd/types/filters.hpp b/host/include/uhd/types/filters.hpp index e3756b7a5..f91f35030 100644 --- a/host/include/uhd/types/filters.hpp +++ b/host/include/uhd/types/filters.hpp @@ -20,7 +20,7 @@ #include <uhd/config.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <stdint.h> #include <boost/shared_ptr.hpp> #include <boost/scoped_array.hpp> @@ -263,7 +263,7 @@ namespace uhd{ { std::size_t num_taps = taps.size(); if(num_taps < this->_max_num_taps){ - UHD_MSG(warning) << "digital_filter_fir::set_taps not enough coefficients. Appending zeros"; + UHD_LOGGER_WARNING("FILTERS") << "digital_filter_fir::set_taps not enough coefficients. Appending zeros"; std::vector<tap_t> coeffs; for (size_t i = 0; i < this->_max_num_taps; i++) { diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index af6d3ee47..5a6e9a48f 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -29,7 +29,6 @@ UHD_INSTALL(FILES gain_group.hpp log.hpp math.hpp - msg.hpp msg_task.hpp paths.hpp pimpl.hpp diff --git a/host/include/uhd/utils/fp_compare_delta.ipp b/host/include/uhd/utils/fp_compare_delta.ipp index 292ef4bf6..9a03bd95b 100644 --- a/host/include/uhd/utils/fp_compare_delta.ipp +++ b/host/include/uhd/utils/fp_compare_delta.ipp @@ -15,7 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#include <uhd/utils/msg.hpp> + #include <cmath> #include <typeinfo> diff --git a/host/include/uhd/utils/fp_compare_epsilon.ipp b/host/include/uhd/utils/fp_compare_epsilon.ipp index ff2d585db..af71046ed 100644 --- a/host/include/uhd/utils/fp_compare_epsilon.ipp +++ b/host/include/uhd/utils/fp_compare_epsilon.ipp @@ -15,7 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#include <uhd/utils/msg.hpp> + #include <cmath> #include <typeinfo> diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp index 106c0d9d5..d90fb4667 100644 --- a/host/include/uhd/utils/log.hpp +++ b/host/include/uhd/utils/log.hpp @@ -21,81 +21,219 @@ #include <uhd/config.hpp> #include <uhd/utils/pimpl.hpp> #include <boost/current_function.hpp> -#include <boost/format.hpp> +#include <boost/thread/thread.hpp> #include <ostream> #include <string> #include <sstream> +#include <iostream> /*! \file log.hpp - * The UHD logging facility. + * The UHD logging facility + * ========================= * - * The logger enables UHD library code to easily log events into a file. + * The logger enables UHD library code to easily log events into a file and display + * messages above a certain level in the terminal. * Log entries are time-stamped and stored with file, line, and function. - * Each call to the UHD_LOG macros is synchronous and thread-safe. + * Each call to the UHD_LOG macros is thread-safe. Each thread will aquire the lock + * for the logger. * - * The log file can be found in the path <temp-directory>/uhd.log, - * where <temp-directory> is the user or system's temporary directory. - * To override <temp-directory>, set the UHD_TEMP_PATH environment variable. + * To disable console logging completely at compile time specify + * `-DUHD_LOG_CONSOLE_DISABLE` during configuration with CMake. + * + * By default no file logging will occur. Set a log file path: + * - at compile time by specifying `-DUHD_LOG_FILE=$file_path` + * - and/or override at runtime by setting the environment variable `UHD_LOG_FILE` + * + * Log levels + * ---------- * * All log messages with verbosity greater than or equal to the log level * (in other words, as often or less often than the current log level) - * are recorded into the log file. All other messages are sent to null. + * are recorded to std::clog and/or the log file. + * Log levels can be specified using string or numeric values of uhd::log::severity_level. * - * The default log level is "never", but can be overridden: - * - at compile time by setting the pre-processor define UHD_LOG_LEVEL. - * - at runtime by setting the environment variable UHD_LOG_LEVEL. + * The default log level is "info", but can be overridden: + * - at compile time by setting the pre-processor define `-DUHD_LOG_MIN_LEVEL`. + * - at runtime by setting the environment variable `UHD_LOG_LEVEL`. + * - for console logging by setting `(-D)UHD_LOG_CONSOLE_LEVEL` at run-/compiletime + * - for file logging by setting `(-D)UHD_LOG_FILE_LEVEL` at run-/compiletime * * UHD_LOG_LEVEL can be the name of a verbosity enum or integer value: - * - Example pre-processor define: -DUHD_LOG_LEVEL=3 - * - Example pre-processor define: -DUHD_LOG_LEVEL=regularly - * - Example environment variable: export UHD_LOG_LEVEL=3 - * - Example environment variable: export UHD_LOG_LEVEL=regularly + * - Example pre-processor define: `-DUHD_LOG_MIN_LEVEL=3` + * - Example pre-processor define: `-DUHD_LOG_MIN_LEVEL=info` + * - Example environment variable: `export UHD_LOG_LEVEL=3` + * - Example environment variable: `export UHD_LOG_LEVEL=info` + * + * Log formatting + * -------------- + * + * The log format for messages going into a log file is CSV. + * All log messages going into a logfile will contain following fields: + * - timestamp + * - thread-id + * - source-file + line information + * - severity level + * - component/channel information which logged the information + * - the actual log message + * + * The log format of log messages displayed on the terminal is plain text with space separated tags prepended. + * For example: + * - `[INFO] [x300] This is a informational log message` + * + * The log format for log output on the console by using these preprocessor defines in CMake: + * - `-DUHD_LOG_CONSOLE_TIME` adds a timestamp [2017-01-01 00:00:00.000000] + * - `-DUHD_LOG_CONSOLE_THREAD` adds a thread-id `[0x001234]` + * - `-DUHD_LOG_CONSOLE_SRC` adds a sourcefile and line tag `[src_file:line]` */ -/*! - * A UHD logger macro with configurable verbosity. - * Usage: UHD_LOGV(very_rarely) << "the log message" << std::endl; +/* + * Advanced logging macros + * UHD_LOG_MIN_LEVEL definitions + * trace: 0 + * debug: 1 + * info: 2 + * warning: 3 + * error: 4 + * fatal: 5 */ -#define UHD_LOGV(verbosity) \ - uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) -/*! - * A UHD logger macro with default verbosity. - * Usage: UHD_LOG << "the log message" << std::endl; - */ -#define UHD_LOG \ - UHD_LOGV(regularly) +namespace uhd { + namespace log { + /** logging severity levels + * Either numeric value or string can be used to define loglevel in CMake and environment variables + */ + enum severity_level { + trace = 0, /**< displays every available log message */ + debug = 1, /**< displays most log messages necessary for debugging internals */ + info = 2, /**< informational messages about setup and what is going on*/ + warning = 3, /**< something is not right but operation can continue */ + error = 4, /**< something has gone wrong */ + fatal = 5, /**< something has gone horribly wrong */ + off = 6, /**< logging is turned off */ + }; + // The operator is used when putting the severity level to log + template <typename CharT, typename TraitsT> + inline std::basic_ostream<CharT, TraitsT>& + operator<<(std::basic_ostream<CharT, TraitsT>& strm, severity_level level) + { + static const char* strings[] = {"TRACE", "DEBUG", "INFO", + "WARNING", "ERROR", "FATAL" + }; -namespace uhd{ namespace _log{ + if (static_cast<std::size_t>(level) < sizeof(strings) / sizeof(*strings)) { + strm << strings[level]; + } else { + strm << static_cast<int>(level); + } - //! Verbosity levels for the logger - enum verbosity_t{ - always = 1, - often = 2, - regularly = 3, - rarely = 4, - very_rarely = 5, - never = 6 - }; + return strm; + } + + + } +} + + +// internal logging macro to be used in other macros +#define _UHD_LOG_INTERNAL(component, level) \ + uhd::_log::log(level, __FILE__, __LINE__, component, boost::this_thread::get_id()) + +// macro-style logging (compile-time determined) +#if UHD_LOG_MIN_LEVEL < 1 +#define UHD_LOG_TRACE(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::trace) << message; +#else +#define UHD_LOG_TRACE(component, message) +#endif + +#if UHD_LOG_MIN_LEVEL < 2 +#define UHD_LOG_DEBUG(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::debug) << message; +#else +#define UHD_LOG_DEBUG(component, message) +#endif + +#if UHD_LOG_MIN_LEVEL < 3 +#define UHD_LOG_INFO(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::info) << message; +#else +#define UHD_LOG_INFO(component, message) +#endif + +#if UHD_LOG_MIN_LEVEL < 4 +#define UHD_LOG_WARNING(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::warning) << message; +#else +#define UHD_LOG_WARNING(component, message) +#endif + +#if UHD_LOG_MIN_LEVEL < 5 +#define UHD_LOG_ERROR(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::error) << message; +#else +#define UHD_LOG_ERROR(component, message) +#endif + +#if UHD_LOG_MIN_LEVEL < 6 +#define UHD_LOG_FATAL(component, message) \ + _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message; +#else +#define UHD_LOG_FATAL(component, message) +#endif + +#define UHD_LOG_FASTPATH(message) \ + std::cerr << message << std::flush; + +// iostream-style logging +#define UHD_LOGGER_TRACE(component) _UHD_LOG_INTERNAL(component, uhd::log::trace) +#define UHD_LOGGER_DEBUG(component) _UHD_LOG_INTERNAL(component, uhd::log::debug) +#define UHD_LOGGER_INFO(component) _UHD_LOG_INTERNAL(component, uhd::log::info) +#define UHD_LOGGER_WARNING(component) _UHD_LOG_INTERNAL(component, uhd::log::warning) +#define UHD_LOGGER_ERROR(component) _UHD_LOG_INTERNAL(component, uhd::log::error) +#define UHD_LOGGER_FATAL(component) _UHD_LOG_INTERNAL(component, uhd::log::fatal) + + +//! Helpful debug tool to print site info +#define UHD_HERE() \ + UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__; + +//! Helpful debug tool to print a variable +#define UHD_VAR(var) \ + UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var; + +//! Helpful debug tool to print a variable in hex +#define UHD_HEX(var) \ + UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec; + + + +namespace uhd{ namespace _log{ //! Internal logging object (called by UHD_LOG macros) class UHD_API log { public: log( - const verbosity_t verbosity, + const uhd::log::severity_level verbosity, const std::string &file, const unsigned int line, - const std::string &function + const std::string &component, + const boost::thread::id id ); ~log(void); + static void set_log_level(uhd::log::severity_level level); + static void set_console_level(uhd::log::severity_level level); + static void set_file_level(uhd::log::severity_level level); + // Macro for overloading insertion operators to avoid costly // conversion of types if not logging. #define INSERTION_OVERLOAD(x) log& operator<< (x) \ { \ - if(_log_it) _ss << val; \ + if(_log_it) { \ + _ss << val ; \ + } \ return *this; \ } @@ -110,9 +248,30 @@ namespace uhd{ namespace _log{ private: std::ostringstream _ss; + std::ostringstream _file; + std::ostringstream _console; bool _log_it; + bool _log_file; + bool _log_console; }; -}} //namespace uhd::_log + } //namespace uhd::_log + namespace log{ + inline void + set_console_level(severity_level level){ + ::uhd::_log::log::set_console_level(level); + } + + inline void + set_log_level(severity_level level){ + ::uhd::_log::log::set_log_level(level); + } + + inline void + set_file_level(severity_level level){ + ::uhd::_log::log::set_file_level(level); + } + } +} #endif /* INCLUDED_UHD_UTILS_LOG_HPP */ diff --git a/host/include/uhd/utils/msg.hpp b/host/include/uhd/utils/msg.hpp deleted file mode 100644 index 48ffb28a1..000000000 --- a/host/include/uhd/utils/msg.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright 2011-2013 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_UTILS_MSG_HPP -#define INCLUDED_UHD_UTILS_MSG_HPP - -#include <uhd/config.hpp> -#include <uhd/utils/pimpl.hpp> -#include <ostream> -#include <iomanip> -#include <string> - -/*! - * A UHD message macro with configurable type. - * Usage: UHD_MSG(warning) << "some warning message" << std::endl; - */ -#define UHD_MSG(type) \ - uhd::msg::_msg(uhd::msg::type)() - -//! Helpful debug tool to print site info -#define UHD_HERE() \ - UHD_MSG(status) << __FILE__ << ":" << __LINE__ << std::endl - -//! Helpful debug tool to print a variable -#define UHD_VAR(var) \ - UHD_MSG(status) << #var << " = " << var << std::endl; - -//! Helpful debug tool to print a variable in hex -#define UHD_HEX(var) \ - UHD_MSG(status) << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec << std::endl; - -namespace uhd{ namespace msg{ - - //! Possible message types - enum type_t{ - status = 's', - warning = 'w', - error = 'e', - fastpath= 'f' - }; - - //! Typedef for a user-registered message handler - typedef void (*handler_t)(type_t, const std::string &); - - /*! - * Default message handler for printing uhd system messages - * \param type message type, such as status, warning, or error - * \param msg contents of the system message as a string - */ - void default_msg_handler(type_t type, const std::string &msg); - - /*! - * Register the handler for uhd system messages. - * Only one handler can be registered at once. - * This replaces the default std::cout/cerr handler. - * \param handler a new handler callback function - */ - UHD_API void register_handler(const handler_t &handler); - - /*! - * Returns the current message handler for uhd system messages - * \returns the current message handler - */ - UHD_API const handler_t& get_handler(); - - //! Internal message object (called by UHD_MSG macro) - class UHD_API _msg{ - public: - _msg(const type_t type); - ~_msg(void); - std::ostream &operator()(void); - private: - UHD_PIMPL_DECL(impl) _impl; - }; - -}} //namespace uhd::msg - -#endif /* INCLUDED_UHD_UTILS_MSG_HPP */ diff --git a/host/include/uhd/utils/safe_call.hpp b/host/include/uhd/utils/safe_call.hpp index ab287cc66..d04d89436 100644 --- a/host/include/uhd/utils/safe_call.hpp +++ b/host/include/uhd/utils/safe_call.hpp @@ -23,7 +23,7 @@ #include <uhd/utils/log.hpp> //! helper macro for safe call to produce warnings -#define _UHD_SAFE_CALL_WARNING(code, what) UHD_LOGV(rarely) << \ +#define _UHD_SAFE_CALL_WARNING(code, what) UHD_LOGGER_ERROR("UHD") << \ UHD_THROW_SITE_INFO("Exception caught in safe-call.") + #code + " -> " + what \ ; diff --git a/host/lib/cal/interpolation.ipp b/host/lib/cal/interpolation.ipp index f58b70b68..1544b041c 100644 --- a/host/lib/cal/interpolation.ipp +++ b/host/lib/cal/interpolation.ipp @@ -19,7 +19,7 @@ #define INCLUDED_UHD_INTERPOLATION_IPP #include "interpolation.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/numeric/ublas/io.hpp> #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/lu.hpp> @@ -175,9 +175,9 @@ CAL_INTERP_METHOD(const out_type, bl_interp, CONTAINER_T &data, const ARGS_T &ar // Fall back to 1D interpolation if the matrix is singular if (is_singular) { // Warn the user that the A matrix is singular - UHD_MSG(warning) << "Bilinear interpolation: singular matrix detected." << std::endl - << "Performing 1D linear interpolation against the nearest measurements." << std::endl - << "Provide calibration data with more measurements" << std::endl; + UHD_LOGGER_WARNING("CAL") << "Bilinear interpolation: singular matrix detected. " + << "Performing 1D linear interpolation against the nearest measurements. " + << "Provide calibration data with more measurements"; output = (b[7] - b[6]) / 2.0; output += b[6]; diff --git a/host/lib/convert/convert_fc32_item32.cpp b/host/lib/convert/convert_fc32_item32.cpp index 4a188780a..38f71a62b 100644 --- a/host/lib/convert/convert_fc32_item32.cpp +++ b/host/lib/convert/convert_fc32_item32.cpp @@ -17,7 +17,7 @@ #include "convert_common.hpp" #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/math/special_functions/round.hpp> #include <vector> diff --git a/host/lib/convert/convert_impl.cpp b/host/lib/convert/convert_impl.cpp index 9508e7984..33f88d70b 100644 --- a/host/lib/convert/convert_impl.cpp +++ b/host/lib/convert/convert_impl.cpp @@ -80,10 +80,7 @@ void uhd::convert::register_converter( get_table()[id][prio] = fcn; //----------------------------------------------------------------// - UHD_LOGV(always) << "register_converter: " << id.to_pp_string() << std::endl - << " prio: " << prio << std::endl - << std::endl - ; + UHD_LOG_TRACE("CONVERT", boost::format("register_converter: %s prio: %s") % id.to_string() % prio) //----------------------------------------------------------------// } @@ -102,9 +99,8 @@ convert::function_type convert::get_converter( for(priority_type prio_i: get_table()[id].keys()){ if (prio_i == prio) { //----------------------------------------------------------------// - UHD_LOGV(always) << "get_converter: For converter ID: " << id.to_pp_string() << std::endl - << "Using prio: " << prio << std::endl - << std::endl + UHD_LOGGER_DEBUG("CONVERT") << "get_converter: For converter ID: " << id.to_pp_string() + << " Using prio: " << prio; ; //----------------------------------------------------------------// return get_table()[id][prio]; @@ -117,10 +113,8 @@ convert::function_type convert::get_converter( "Cannot find a conversion routine [with prio] for " + id.to_pp_string()); //----------------------------------------------------------------// - UHD_LOGV(always) << "get_converter: For converter ID: " << id.to_pp_string() << std::endl - << "Using prio: " << best_prio << std::endl - << std::endl - ; + UHD_LOGGER_DEBUG("CONVERT") << "get_converter: For converter ID: " << id.to_pp_string() + << " Using prio: " << best_prio; //----------------------------------------------------------------// //otherwise, return best prio diff --git a/host/lib/convert/convert_pack_sc12.cpp b/host/lib/convert/convert_pack_sc12.cpp index fd32fc95f..aaa6f2632 100644 --- a/host/lib/convert/convert_pack_sc12.cpp +++ b/host/lib/convert/convert_pack_sc12.cpp @@ -17,7 +17,7 @@ #include "convert_common.hpp" #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/math/special_functions/round.hpp> #include <vector> diff --git a/host/lib/convert/convert_unpack_sc12.cpp b/host/lib/convert/convert_unpack_sc12.cpp index acc815951..f42e51c00 100644 --- a/host/lib/convert/convert_unpack_sc12.cpp +++ b/host/lib/convert/convert_unpack_sc12.cpp @@ -17,7 +17,7 @@ #include "convert_common.hpp" #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/math/special_functions/round.hpp> #include <vector> diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 40798c6c3..0cdfc14aa 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -19,7 +19,7 @@ #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/static.hpp> #include <uhd/utils/algorithm.hpp> #include <boost/format.hpp> @@ -73,7 +73,7 @@ void device::register_device( const make_t &make, const device_filter_t filter ){ - UHD_LOGV(always) << "registering device" << std::endl; + UHD_LOGGER_TRACE("UHD") << "registering device"; get_dev_fcn_regs().push_back(dev_fcn_reg_t(find, make, filter)); } @@ -101,7 +101,7 @@ device_addrs_t device::find(const device_addr_t &hint, device_filter_t filter){ } } catch (const std::exception &e) { - UHD_MSG(error) << "Device discovery error: " << e.what() << std::endl; + UHD_LOGGER_ERROR("UHD") << "Device discovery error: " << e.what(); } } @@ -127,7 +127,7 @@ device::sptr device::make(const device_addr_t &hint, device_filter_t filter, siz } } catch(const std::exception &e){ - UHD_MSG(error) << "Device discovery error: " << e.what() << std::endl; + UHD_LOGGER_ERROR("UHD") << "Device discovery error: " << e.what() ; } } @@ -149,7 +149,7 @@ device::sptr device::make(const device_addr_t &hint, device_filter_t filter, siz device_addr_t dev_addr; make_t maker; boost::tie(dev_addr, maker) = dev_addr_makers.at(which); size_t dev_hash = hash_device_addr(dev_addr); - UHD_LOG << boost::format("Device hash: %u") % dev_hash << std::endl; + UHD_LOGGER_DEBUG("UHD") << boost::format("Device hash: %u") % dev_hash ; //copy keys that were in hint but not in dev_addr //this way, we can pass additional transport arguments diff --git a/host/lib/device3.cpp b/host/lib/device3.cpp index e1f53656f..c3bfb83d2 100644 --- a/host/lib/device3.cpp +++ b/host/lib/device3.cpp @@ -17,7 +17,7 @@ #include <boost/format.hpp> #include <uhd/device3.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd; using namespace uhd::rfnoc; diff --git a/host/lib/experts/expert_container.cpp b/host/lib/experts/expert_container.cpp index 53995e5e3..f010293b7 100644 --- a/host/lib/experts/expert_container.cpp +++ b/host/lib/experts/expert_container.cpp @@ -17,7 +17,7 @@ #include "expert_container.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/format.hpp> #include <boost/function.hpp> #include <boost/bind.hpp> @@ -513,7 +513,7 @@ private: { std::string indents; for (size_t i = 0; i < depth; i++) indents += "- "; - UHD_MSG(fastpath) << "[expert::" + _name + "] " << indents << str << std::endl; + UHD_LOG_DEBUG("EXPERT","[expert::" + _name + "] " << indents << str) } private: diff --git a/host/lib/image_loader.cpp b/host/lib/image_loader.cpp index 5ad257368..b7c3fda4d 100644 --- a/host/lib/image_loader.cpp +++ b/host/lib/image_loader.cpp @@ -25,7 +25,7 @@ #include <uhd/exception.hpp> #include <uhd/image_loader.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/static.hpp> namespace fs = boost::filesystem; @@ -46,8 +46,8 @@ UHD_SINGLETON_FCN(string_map_t, get_recovery_strings); void uhd::image_loader::register_image_loader(const std::string &device_type, const loader_fcn_t &loader_fcn, const std::string &recovery_instructions){ - UHD_LOGV(always) << "Registering image loader and recovery instructions for " - << device_type << std::endl; + UHD_LOGGER_DEBUG("UHD") << "Registering image loader and recovery instructions for " + << device_type; get_image_loaders().insert(loader_fcn_pair_t(device_type, loader_fcn)); get_recovery_strings().insert(string_pair_t(device_type, recovery_instructions)); diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp index 2a486ac31..efd723fcb 100644 --- a/host/lib/rfnoc/block_ctrl_base.cpp +++ b/host/lib/rfnoc/block_ctrl_base.cpp @@ -20,7 +20,7 @@ #include "ctrl_iface.hpp" #include "nocscript/block_iface.hpp" -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> @@ -28,7 +28,7 @@ #include <boost/format.hpp> #include <boost/bind.hpp> -#define UHD_BLOCK_LOG() UHD_LOGV(never) +#define UHD_BLOCK_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd; using namespace uhd::rfnoc; @@ -50,13 +50,13 @@ block_ctrl_base::block_ctrl_base( _ctrl_ifaces(make_args.ctrl_ifaces), _base_address(make_args.base_address & 0xFFF0) { - UHD_BLOCK_LOG() << "block_ctrl_base()" << std::endl; + UHD_BLOCK_LOG() << "block_ctrl_base()" ; /*** Identify this block (NoC-ID, block-ID, and block definition) *******/ // Read NoC-ID (name is passed in through make_args): uint64_t noc_id = sr_read64(SR_READBACK_REG_ID); _block_def = blockdef::make_from_noc_id(noc_id); - if (_block_def) UHD_BLOCK_LOG() << "Found valid blockdef" << std::endl; + if (_block_def) UHD_BLOCK_LOG() << "Found valid blockdef" ; if (not _block_def) _block_def = blockdef::make_from_noc_id(DEFAULT_NOC_ID); UHD_ASSERT_THROW(_block_def); @@ -68,7 +68,7 @@ block_ctrl_base::block_ctrl_base( } UHD_BLOCK_LOG() << "NOC ID: " << str(boost::format("0x%016X ") % noc_id) - << "Block ID: " << _block_id << std::endl; + << "Block ID: " << _block_id ; /*** Initialize property tree *******************************************/ _root_path = "xbar/" + _block_id.get_local(); @@ -114,10 +114,10 @@ block_ctrl_base::block_ctrl_base( _init_port_defs("out", _block_def->get_output_ports()); // FIXME this warning always fails until the input buffer code above is fixed if (_tree->list(_root_path / "ports/in").size() != n_valid_input_buffers) { - UHD_MSG(warning) << + UHD_LOGGER_WARNING("RFNOC") << boost::format("[%s] defines %d input buffer sizes, but %d input ports") % get_block_id().get() % n_valid_input_buffers % _tree->list(_root_path / "ports/in").size() - << std::endl; + ; } /*** Init default block args ********************************************/ @@ -143,7 +143,7 @@ void block_ctrl_base::_init_port_defs( } UHD_RFNOC_BLOCK_TRACE() << "Adding port definition at " << port_path << boost::format(": type = '%s' pkt_size = '%s' vlen = '%s'") % port_def["type"] % port_def["pkt_size"] % port_def["vlen"] - << std::endl; + ; _tree->access<blockdef::port_t>(port_path).set(port_def); port_index++; } @@ -225,7 +225,7 @@ std::vector<size_t> block_ctrl_base::get_ctrl_ports() const void block_ctrl_base::sr_write(const uint32_t reg, const uint32_t data, const size_t port) { //UHD_BLOCK_LOG() << " "; - //UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%d, %08X, %d)") % reg % data % port << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%d, %08X, %d)") % reg % data % port ; if (not _ctrl_ifaces.count(port)) { throw uhd::key_error(str(boost::format("[%s] sr_write(): No such port: %d") % get_block_id().get() % port)); } @@ -252,7 +252,7 @@ void block_ctrl_base::sr_write(const std::string ®, const uint32_t data, cons reg_addr = uint32_t(_tree->access<size_t>(_root_path / "registers" / "sr" / reg).get()); } UHD_BLOCK_LOG() << " "; - UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%s, %08X) ==> ") % reg % data << std::endl; + UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%s, %08X) ==> ") % reg % data ; return sr_write(reg_addr, data, port); } @@ -409,7 +409,7 @@ void block_ctrl_base::clear_command_time(const size_t port) void block_ctrl_base::clear() { - UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::clear() " ; // Call parent... node_ctrl_base::clear(); // ...then child @@ -532,7 +532,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.item_type = port_def["type"]; } - //UHD_RFNOC_BLOCK_TRACE() << " item type: " << stream_sig.item_type << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " item type: " << stream_sig.item_type ; // Vector length if (port_def.is_variable("vlen")) { @@ -543,7 +543,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.vlen = boost::lexical_cast<size_t>(port_def["vlen"]); } - //UHD_RFNOC_BLOCK_TRACE() << " vector length: " << stream_sig.vlen << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " vector length: " << stream_sig.vlen ; // Packet size if (port_def.is_variable("pkt_size")) { @@ -565,7 +565,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.packet_size = boost::lexical_cast<size_t>(port_def["pkt_size"]); } - //UHD_RFNOC_BLOCK_TRACE() << " packet size: " << stream_sig.vlen << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " packet size: " << stream_sig.vlen ; return stream_sig; } @@ -576,7 +576,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def **********************************************************************/ void block_ctrl_base::_clear(const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::_clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::_clear() " ; sr_write(SR_CLEAR_TX_FC, 0x00C1EA12, port); // 'CLEAR', but we can write anything, really sr_write(SR_CLEAR_RX_FC, 0x00C1EA12, port); // 'CLEAR', but we can write anything, really } diff --git a/host/lib/rfnoc/block_ctrl_base_factory.cpp b/host/lib/rfnoc/block_ctrl_base_factory.cpp index 0e2d5ae03..9e32b81d7 100644 --- a/host/lib/rfnoc/block_ctrl_base_factory.cpp +++ b/host/lib/rfnoc/block_ctrl_base_factory.cpp @@ -16,12 +16,12 @@ // #include <boost/format.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/rfnoc/blockdef.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> -#define UHD_FACTORY_LOG() UHD_LOGV(never) +#define UHD_FACTORY_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd; using namespace uhd::rfnoc; @@ -59,7 +59,7 @@ static void lookup_block_key(uint64_t noc_id, make_args_t &make_args) make_args.block_name = bd->get_name(); return; } catch (std::exception &e) { - UHD_MSG(warning) << str(boost::format("Error while looking up name for NoC-ID %016X.\n%s") % noc_id % e.what()) << std::endl; + UHD_LOGGER_WARNING("RFNOC") << str(boost::format("Error while looking up name for NoC-ID %016X.\n%s") % noc_id % e.what()) ; } make_args.block_key = DEFAULT_BLOCK_NAME; @@ -71,7 +71,7 @@ block_ctrl_base::sptr block_ctrl_base::make( const make_args_t &make_args_, uint64_t noc_id ) { - UHD_FACTORY_LOG() << "[RFNoC Factory] block_ctrl_base::make() " << std::endl; + UHD_FACTORY_LOG() << "[RFNoC Factory] block_ctrl_base::make() " ; make_args_t make_args = make_args_; // Check if a block key was specified, in this case, we *must* either @@ -90,7 +90,7 @@ block_ctrl_base::sptr block_ctrl_base::make( make_args.block_name = make_args.block_key; } - UHD_FACTORY_LOG() << "[RFNoC Factory] Using controller key '" << make_args.block_key << "' and block name '" << make_args.block_name << "'" << std::endl; + UHD_FACTORY_LOG() << "[RFNoC Factory] Using controller key '" << make_args.block_key << "' and block name '" << make_args.block_name << "'" ; return get_block_fcn_regs()[make_args.block_key](make_args); } diff --git a/host/lib/rfnoc/blockdef_xml_impl.cpp b/host/lib/rfnoc/blockdef_xml_impl.cpp index 9c56d82a6..5f8af232d 100644 --- a/host/lib/rfnoc/blockdef_xml_impl.cpp +++ b/host/lib/rfnoc/blockdef_xml_impl.cpp @@ -18,7 +18,7 @@ #include <uhd/exception.hpp> #include <uhd/rfnoc/constants.hpp> #include <uhd/rfnoc/blockdef.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -223,7 +223,7 @@ public: } } } catch (std::exception &e) { - UHD_MSG(warning) << "has_noc_id(): caught exception " << e.what() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "has_noc_id(): caught exception " << e.what() ; return false; } return false; @@ -233,7 +233,7 @@ public: _type(type), _noc_id(noc_id) { - //UHD_MSG(status) << "Reading XML file: " << filename.string().c_str() << std::endl; + //UHD_LOGGER_INFO("RFNOC") << "Reading XML file: " << filename.string().c_str() ; read_xml(filename.string(), _pt); try { // Check key is valid @@ -362,7 +362,7 @@ public: arg["type"] = "string"; } if (not arg.is_valid()) { - UHD_MSG(warning) << boost::format("Found invalid argument: %s") % arg.to_string() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << boost::format("Found invalid argument: %s") % arg.to_string() ; is_valid = false; } args.push_back(arg); diff --git a/host/lib/rfnoc/ctrl_iface.cpp b/host/lib/rfnoc/ctrl_iface.cpp index 8e4474af7..3a16f7ec1 100644 --- a/host/lib/rfnoc/ctrl_iface.cpp +++ b/host/lib/rfnoc/ctrl_iface.cpp @@ -17,7 +17,7 @@ #include "ctrl_iface.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/byteswap.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/bounded_buffer.hpp> @@ -168,7 +168,7 @@ private: //load payload pkt[packet_info.num_header_words32+0] = (_bige)? uhd::htonx(addr) : uhd::htowx(addr); pkt[packet_info.num_header_words32+1] = (_bige)? uhd::htonx(data) : uhd::htowx(data); - //UHD_MSG(status) << boost::format("0x%08x, 0x%08x\n") % addr % data; + //UHD_LOGGER_INFO("RFNOC") << boost::format("0x%08x, 0x%08x\n") % addr % data; //send the buffer over the interface _outstanding_seqs.push(_seq_out); buff->commit(sizeof(uint32_t)*(packet_info.num_packet_words32)); @@ -212,15 +212,15 @@ private: } catch(const std::exception &ex) { - UHD_MSG(error) << "[" << _name << "] Block ctrl bad VITA packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("RFNOC") << "[" << _name << "] Block ctrl bad VITA packet: " << ex.what() ; if (buff){ - UHD_MSG(status) << boost::format("%08X") % pkt[0] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[1] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[2] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[3] << std::endl; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[0] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[1] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[2] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[3] ; } else{ - UHD_MSG(status) << "buff is NULL" << std::endl; + UHD_LOGGER_INFO("RFNOC") << "buff is NULL" ; } } diff --git a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp index fb70b6f45..830664e5c 100644 --- a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp @@ -17,7 +17,7 @@ #include "dsp_core_utils.hpp" #include <uhd/rfnoc/ddc_block_ctrl.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/types/ranges.hpp> #include <boost/math/special_functions/round.hpp> @@ -141,10 +141,10 @@ public: const uhd::stream_cmd_t &stream_cmd_, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "ddc_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "ddc_block_ctrl_base::issue_stream_cmd()" ; if (list_upstream_nodes().count(chan) == 0) { - UHD_MSG(status) << "No upstream blocks." << std::endl; + UHD_LOGGER_INFO("RFNOC") << "No upstream blocks." ; return; } @@ -232,7 +232,7 @@ private: sr_write("M", 1, chan); if (decim > 1 and hb_enable == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("RFNOC") << boost::format( "The requested decimation is odd; the user should expect passband CIC rolloff.\n" "Select an even decimation to ensure that a halfband filter is enabled.\n" "Decimations factorable by 4 will enable 2 halfbands, those factorable by 8 will enable 3 halfbands.\n" diff --git a/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp b/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp index aea7c591c..93f599314 100644 --- a/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp @@ -19,7 +19,7 @@ #include "dma_fifo_core_3000.hpp" #include "wb_iface_adapter.hpp" #include <uhd/convert.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/wb_iface.hpp> #include <boost/make_shared.hpp> #include <boost/thread/mutex.hpp> @@ -64,18 +64,18 @@ public: _perifs[i].depth = DEFAULT_SIZE; _perifs[i].core = dma_fifo_core_3000::make(_perifs[i].ctrl, USER_SR_BASE, USER_RB_BASE); _perifs[i].core->resize(_perifs[i].base_addr, _perifs[i].depth); - UHD_MSG(status) << boost::format("[DMA FIFO] Running BIST for FIFO %d... ") % i; + UHD_LOGGER_INFO("RFNOC") << boost::format("[DMA FIFO] Running BIST for FIFO %d... ") % i; if (_perifs[i].core->ext_bist_supported()) { uint32_t bisterr = _perifs[i].core->run_bist(); if (bisterr != 0) { throw uhd::runtime_error(str(boost::format("BIST failed! (code: %d)\n") % bisterr)); } else { double throughput = _perifs[i].core->get_bist_throughput(BUS_CLK_RATE); - UHD_MSG(status) << (boost::format("pass (Throughput: %.1fMB/s)") % (throughput/1e6)) << std::endl; + UHD_LOGGER_INFO("RFNOC") << (boost::format("pass (Throughput: %.1fMB/s)") % (throughput/1e6)) ; } } else { if (_perifs[i].core->run_bist() == 0) { - UHD_MSG(status) << "pass\n"; + UHD_LOGGER_INFO("RFNOC") << "pass\n"; } else { throw uhd::runtime_error("BIST failed!\n"); } diff --git a/host/lib/rfnoc/duc_block_ctrl_impl.cpp b/host/lib/rfnoc/duc_block_ctrl_impl.cpp index 6a3f32eaf..07279ed47 100644 --- a/host/lib/rfnoc/duc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/duc_block_ctrl_impl.cpp @@ -17,7 +17,7 @@ #include "dsp_core_utils.hpp" #include <uhd/rfnoc/duc_block_ctrl.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/types/ranges.hpp> #include <boost/math/special_functions/round.hpp> @@ -132,7 +132,7 @@ public: const uhd::stream_cmd_t &stream_cmd_, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "duc_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "duc_block_ctrl_base::issue_stream_cmd()" ; uhd::stream_cmd_t stream_cmd = stream_cmd_; if (stream_cmd.stream_mode == uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE or @@ -217,7 +217,7 @@ private: sr_write("M", std::pow(2.0, double(hb_enable)) * (interp & 0xff), chan); if (interp > 1 and hb_enable == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("RFNOC") << boost::format( "The requested interpolation is odd; the user should expect passband CIC rolloff.\n" "Select an even interpolation to ensure that a halfband filter is enabled.\n" "interpolation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" diff --git a/host/lib/rfnoc/graph_impl.cpp b/host/lib/rfnoc/graph_impl.cpp index 64c6f6abe..005e23815 100644 --- a/host/lib/rfnoc/graph_impl.cpp +++ b/host/lib/rfnoc/graph_impl.cpp @@ -18,7 +18,7 @@ #include "graph_impl.hpp" #include <uhd/rfnoc/source_block_ctrl_base.hpp> #include <uhd/rfnoc/sink_block_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd::rfnoc; @@ -85,10 +85,10 @@ void graph_impl::connect( dst->set_upstream_port(actual_dst_block_port, actual_src_block_port); // At this point, ports are locked and no one else can simply connect // into them. - //UHD_MSG(status) + //UHD_LOGGER_INFO("RFNOC") //<< "[" << _name << "] Connecting " //<< src_block << ":" << actual_src_block_port << " --> " - //<< dst_block << ":" << actual_dst_block_port << std::endl; + //<< dst_block << ":" << actual_dst_block_port ; /******************************************************************** * 2. Check IO signatures match @@ -120,7 +120,7 @@ void graph_impl::connect( ********************************************************************/ size_t pkt_size = (pkt_size_ != 0) ? pkt_size_ : src->get_output_signature(src_block_port).packet_size; if (pkt_size == 0) { // Unspecified packet rate. Assume max packet size. - UHD_MSG(status) << "Assuming max packet size for " << src->get_block_id() << std::endl; + UHD_LOGGER_INFO("RFNOC") << "Assuming max packet size for " << src->get_block_id() ; pkt_size = uhd::rfnoc::MAX_PACKET_SIZE; } // FC window (in packets) depends on FIFO size... ...and packet size. diff --git a/host/lib/rfnoc/legacy_compat.cpp b/host/lib/rfnoc/legacy_compat.cpp index 8d64cb51a..dc711b909 100644 --- a/host/lib/rfnoc/legacy_compat.cpp +++ b/host/lib/rfnoc/legacy_compat.cpp @@ -26,14 +26,14 @@ #include <uhd/types/stream_cmd.hpp> #include <uhd/types/direction.hpp> #include <uhd/types/ranges.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/transport/chdr.hpp> #include <uhd/usrp/multi_usrp.hpp> #include <boost/make_shared.hpp> #include <boost/assign.hpp> -#define UHD_LEGACY_LOG() UHD_LOGV(never) +#define UHD_LEGACY_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd::rfnoc; using uhd::usrp::subdev_spec_t; @@ -143,21 +143,21 @@ public: } connect_blocks(); if (args.has_key("skip_ddc")) { - UHD_LEGACY_LOG() << "[legacy_compat] Skipping DDCs by user request." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Skipping DDCs by user request." ; } else if (not _has_ddcs) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No DDCs detected. You will only be able to receive at the radio frontend rate." - << std::endl; + ; } if (args.has_key("skip_duc")) { - UHD_LEGACY_LOG() << "[legacy_compat] Skipping DUCs by user request." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Skipping DUCs by user request." ; } else if (not _has_ducs) { - UHD_MSG(warning) << "[legacy_compat] No DUCs detected. You will only be able to transmit at the radio frontend rate." << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No DUCs detected. You will only be able to transmit at the radio frontend rate." ; } if (args.has_key("skip_dram")) { - UHD_LEGACY_LOG() << "[legacy_compat] Skipping DRAM by user request." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Skipping DRAM by user request." ; } else if (not _has_dmafifo) { - UHD_MSG(warning) << "[legacy_compat] No DMA FIFO detected. You will only be able to transmit at slow rates." << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No DMA FIFO detected. You will only be able to transmit at slow rates." ; } for (size_t mboard = 0; mboard < _num_mboards; mboard++) { @@ -241,7 +241,7 @@ public: void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t mboard, size_t chan) { - UHD_LEGACY_LOG() << "[legacy_compat] issue_stream_cmd() " << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] issue_stream_cmd() " ; const size_t &radio_index = _rx_channel_map[mboard][chan].radio_index; const size_t &port_index = _rx_channel_map[mboard][chan].port_index; if (_has_ddcs) { @@ -259,7 +259,7 @@ public: args.otw_format = "sc16"; } _update_stream_args_for_streaming<uhd::RX_DIRECTION>(args, _rx_channel_map); - UHD_LEGACY_LOG() << "[legacy_compat] rx stream args: " << args.args.to_string() << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] rx stream args: " << args.args.to_string() ; uhd::rx_streamer::sptr streamer = _device->get_rx_stream(args); for(const size_t chan: args.channels) { _rx_stream_cache[chan] = streamer; @@ -276,7 +276,7 @@ public: args.otw_format = "sc16"; } _update_stream_args_for_streaming<uhd::TX_DIRECTION>(args, _tx_channel_map); - UHD_LEGACY_LOG() << "[legacy_compat] tx stream args: " << args.args.to_string() << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] tx stream args: " << args.args.to_string() ; uhd::tx_streamer::sptr streamer = _device->get_tx_stream(args); for(const size_t chan: args.channels) { _tx_stream_cache[chan] = streamer; @@ -573,7 +573,7 @@ private: // methods const size_t this_spp = get_block_ctrl<radio_ctrl>(i, RADIO_BLOCK_NAME, k)->get_arg<int>("spp"); if (this_spp != _rx_spp) { - UHD_LOG << str( + UHD_LOGGER_WARNING("RFNOC") << str( boost::format("[legacy compat] Radios have differing spp values: %s has %d, others have %d. UHD will use smaller spp value for all connections. Performance might be not optimal.") % radio_block_id.to_string() % this_spp % _rx_spp ); @@ -865,7 +865,7 @@ legacy_compat::sptr legacy_compat::make( if (legacy_cache.count(device.get()) and not legacy_cache.at(device.get()).expired()) { legacy_compat::sptr legacy_compat_copy = legacy_cache.at(device.get()).lock(); UHD_ASSERT_THROW(bool(legacy_compat_copy)); - UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." ; return legacy_compat_copy; } diff --git a/host/lib/rfnoc/nocscript/block_iface.cpp b/host/lib/rfnoc/nocscript/block_iface.cpp index 0d301e5bc..544593def 100644 --- a/host/lib/rfnoc/nocscript/block_iface.cpp +++ b/host/lib/rfnoc/nocscript/block_iface.cpp @@ -18,12 +18,12 @@ #include "block_iface.hpp" #include "function_table.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/assign.hpp> #include <boost/bind.hpp> #include <boost/format.hpp> -#define UHD_NOCSCRIPT_LOG() UHD_LOGV(never) +#define UHD_NOCSCRIPT_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd::rfnoc; using namespace uhd::rfnoc::nocscript; @@ -116,7 +116,7 @@ void block_iface::run_and_check(const std::string &code, const std::string &erro { boost::mutex::scoped_lock local_interpreter_lock(_lil_mutex); - UHD_NOCSCRIPT_LOG() << "[NocScript] Executing and asserting code: " << code << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Executing and asserting code: " << code ; expression::sptr e = _parser->create_expr_tree(code); expression_literal result = e->eval(); if (not result.to_bool()) { @@ -143,12 +143,12 @@ expression_literal block_iface::_nocscript__sr_write(expression_container::expr_ const uint32_t reg_val = uint32_t(args[1]->eval().get_int()); bool result = true; try { - UHD_NOCSCRIPT_LOG() << "[NocScript] Executing SR_WRITE() " << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Executing SR_WRITE() " ; _block_ptr->sr_write(reg_name, reg_val); } catch (const uhd::exception &e) { - UHD_MSG(error) << boost::format("[NocScript] Error while executing SR_WRITE(%s, 0x%X):\n%s") + UHD_LOGGER_ERROR("RFNOC") << boost::format("[NocScript] Error while executing SR_WRITE(%s, 0x%X):\n%s") % reg_name % reg_val % e.what() - << std::endl; + ; result = false; } @@ -195,7 +195,7 @@ expression_literal block_iface::_nocscript__arg_set_int(const expression_contain if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<int>(var_name, val, port); return expression_literal(true); } @@ -208,7 +208,7 @@ expression_literal block_iface::_nocscript__arg_set_string(const expression_cont if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<std::string>(var_name, val, port); return expression_literal(true); } @@ -221,7 +221,7 @@ expression_literal block_iface::_nocscript__arg_set_double(const expression_cont if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<double>(var_name, val, port); return expression_literal(true); } @@ -239,8 +239,8 @@ block_iface::sptr block_iface::make(uhd::rfnoc::block_ctrl_base* block_ptr) expression_literal block_iface::_nocscript__var_get(const expression_container::expr_list_type &args) { expression_literal expr = _vars[args[0]->eval().get_string()]; - //std::cout << "[NocScript] Getting var " << args[0]->eval().get_string() << " == " << expr << std::endl; - //std::cout << "[NocScript] Type " << expr.infer_type() << std::endl; + //std::cout << "[NocScript] Getting var " << args[0]->eval().get_string() << " == " << expr ; + //std::cout << "[NocScript] Type " << expr.infer_type() ; //return _vars[args[0]->eval().get_string()]; return expr; } @@ -248,8 +248,8 @@ expression_literal block_iface::_nocscript__var_get(const expression_container:: expression_literal block_iface::_nocscript__var_set(const expression_container::expr_list_type &args) { _vars[args[0]->eval().get_string()] = args[1]->eval(); - //std::cout << "[NocScript] Set var " << args[0]->eval().get_string() << " to " << _vars[args[0]->eval().get_string()] << std::endl; - //std::cout << "[NocScript] Type " << _vars[args[0]->eval().get_string()].infer_type() << std::endl; + //std::cout << "[NocScript] Set var " << args[0]->eval().get_string() << " to " << _vars[args[0]->eval().get_string()] ; + //std::cout << "[NocScript] Type " << _vars[args[0]->eval().get_string()].infer_type() ; return expression_literal(true); } diff --git a/host/lib/rfnoc/node_ctrl_base.cpp b/host/lib/rfnoc/node_ctrl_base.cpp index b4d0a30ff..e9424d319 100644 --- a/host/lib/rfnoc/node_ctrl_base.cpp +++ b/host/lib/rfnoc/node_ctrl_base.cpp @@ -16,7 +16,7 @@ // #include <uhd/rfnoc/node_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/range/adaptor/map.hpp> using namespace uhd::rfnoc; @@ -30,7 +30,7 @@ std::string node_ctrl_base::unique_id() const void node_ctrl_base::clear() { - UHD_RFNOC_BLOCK_TRACE() << "node_ctrl_base::clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "node_ctrl_base::clear() " ; // Reset connections: _upstream_nodes.clear(); _downstream_nodes.clear(); diff --git a/host/lib/rfnoc/radio_ctrl_impl.cpp b/host/lib/rfnoc/radio_ctrl_impl.cpp index 7a3cae79c..0dc5cd168 100644 --- a/host/lib/rfnoc/radio_ctrl_impl.cpp +++ b/host/lib/rfnoc/radio_ctrl_impl.cpp @@ -19,7 +19,7 @@ #include <boost/format.hpp> #include <boost/bind.hpp> #include <uhd/convert.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/direction.hpp> #include "radio_ctrl_impl.hpp" @@ -136,7 +136,6 @@ radio_ctrl_impl::radio_ctrl_impl() : void radio_ctrl_impl::_register_loopback_self_test(size_t chan) { - UHD_MSG(status) << "[RFNoC Radio] Performing register loopback test... " << std::flush; size_t hash = size_t(time(NULL)); for (size_t i = 0; i < 100; i++) { @@ -144,12 +143,12 @@ void radio_ctrl_impl::_register_loopback_self_test(size_t chan) sr_write(regs::TEST, uint32_t(hash), chan); uint32_t result = user_reg_read32(regs::RB_TEST, chan); if (result != uint32_t(hash)) { - UHD_MSG(status) << "fail" << std::endl; - UHD_MSG(status) << boost::format("expected: %x result: %x") % uint32_t(hash) % result << std::endl; + UHD_LOGGER_ERROR("RFNOC RADIO") << "Register loopback test failed"; + UHD_LOGGER_ERROR("RFNOC RADIO") << boost::format("expected: %x result: %x") % uint32_t(hash) % result ; return; // exit on any failure } } - UHD_MSG(status) << "pass" << std::endl; + UHD_LOGGER_INFO("RFNOC RADIO") << "Register loopback test passed"; } /**************************************************************************** @@ -241,9 +240,9 @@ double radio_ctrl_impl::get_rx_gain(const size_t chan) /* const */ void radio_ctrl_impl::issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd, const size_t chan) { boost::mutex::scoped_lock lock(_mutex); - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() " << chan << " " << char(stream_cmd.stream_mode) << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() " << chan << " " << char(stream_cmd.stream_mode) ; if (not _is_streamer_active(uhd::RX_DIRECTION, chan)) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() called on inactive channel. Skipping." << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() called on inactive channel. Skipping." ; return; } UHD_ASSERT_THROW(stream_cmd.num_samps <= 0x0fffffff); @@ -295,7 +294,7 @@ std::vector<size_t> radio_ctrl_impl::get_active_rx_ports() **********************************************************************/ void radio_ctrl_impl::set_rx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_rx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_rx_streamer() " << port << " -> " << active ; if (port > _num_rx_channels) { throw uhd::value_error(str( boost::format("[%s] Can't (un)register RX streamer on port %d (invalid port)") @@ -313,7 +312,7 @@ void radio_ctrl_impl::set_rx_streamer(bool active, const size_t port) void radio_ctrl_impl::set_tx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_tx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_tx_streamer() " << port << " -> " << active ; if (port > _num_tx_channels) { throw uhd::value_error(str( boost::format("[%s] Can't (un)register TX streamer on port %d (invalid port)") @@ -334,11 +333,11 @@ void radio_ctrl_impl::set_tx_streamer(bool active, const size_t port) void radio_ctrl_impl::_update_spp(int spp) { boost::mutex::scoped_lock lock(_mutex); - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Requested spp: " << spp << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Requested spp: " << spp ; if (spp == 0) { spp = DEFAULT_PACKET_SIZE / BYTES_PER_SAMPLE; } - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Setting spp to: " << spp << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Setting spp to: " << spp ; for (size_t i = 0; i < _num_rx_channels; i++) { sr_write(regs::RX_CTRL_MAXLEN, uint32_t(spp), i); } diff --git a/host/lib/rfnoc/rx_stream_terminator.cpp b/host/lib/rfnoc/rx_stream_terminator.cpp index 52803d6b6..e05d9cd49 100644 --- a/host/lib/rfnoc/rx_stream_terminator.cpp +++ b/host/lib/rfnoc/rx_stream_terminator.cpp @@ -18,7 +18,7 @@ #include "rx_stream_terminator.hpp" #include "radio_ctrl_impl.hpp" #include "../transport/super_recv_packet_handler.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> #include <boost/format.hpp> @@ -47,7 +47,7 @@ void rx_stream_terminator::set_tx_streamer(bool, const size_t) void rx_stream_terminator::set_rx_streamer(bool active, const size_t) { // TODO this is identical to source_node_ctrl::set_rx_streamer() -> factor out - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::set_rx_streamer() " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::set_rx_streamer() " << active; for(const node_ctrl_base::node_map_pair_t upstream_node: _upstream_nodes) { source_node_ctrl::sptr curr_upstream_block_ctrl = boost::dynamic_pointer_cast<source_node_ctrl>(upstream_node.second.lock()); @@ -70,7 +70,7 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre return; } - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::handle_overrun()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::handle_overrun()" ; boost::shared_ptr<uhd::transport::sph::recv_packet_streamer> my_streamer = boost::dynamic_pointer_cast<uhd::transport::sph::recv_packet_streamer>(streamer.lock()); if (not my_streamer) return; //If the rx_streamer has expired then overflow handling makes no sense. @@ -125,7 +125,7 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre rx_stream_terminator::~rx_stream_terminator() { - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::~rx_stream_terminator() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::~rx_stream_terminator() " ; set_rx_streamer(false, 0); } diff --git a/host/lib/rfnoc/sink_block_ctrl_base.cpp b/host/lib/rfnoc/sink_block_ctrl_base.cpp index 4b4eec20d..48291e02f 100644 --- a/host/lib/rfnoc/sink_block_ctrl_base.cpp +++ b/host/lib/rfnoc/sink_block_ctrl_base.cpp @@ -18,7 +18,7 @@ #include "utils.hpp" #include <uhd/rfnoc/sink_block_ctrl_base.hpp> #include <uhd/rfnoc/constants.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd; using namespace uhd::rfnoc; @@ -66,7 +66,7 @@ void sink_block_ctrl_base::configure_flow_control_in( size_t packets, size_t block_port ) { - UHD_RFNOC_BLOCK_TRACE() << boost::format("sink_block_ctrl_base::configure_flow_control_in(cycles=%d, packets=%d)") % cycles % packets << std::endl; + UHD_RFNOC_BLOCK_TRACE() << boost::format("sink_block_ctrl_base::configure_flow_control_in(cycles=%d, packets=%d)") % cycles % packets ; uint32_t cycles_word = 0; if (cycles) { cycles_word = (1<<31) | cycles; diff --git a/host/lib/rfnoc/sink_node_ctrl.cpp b/host/lib/rfnoc/sink_node_ctrl.cpp index 2915369f3..c570b8eca 100644 --- a/host/lib/rfnoc/sink_node_ctrl.cpp +++ b/host/lib/rfnoc/sink_node_ctrl.cpp @@ -16,7 +16,7 @@ // #include "utils.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/sink_node_ctrl.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> @@ -35,7 +35,7 @@ size_t sink_node_ctrl::connect_upstream( void sink_node_ctrl::set_tx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "sink_node_ctrl::set_tx_streamer() " << active << " " << port << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "sink_node_ctrl::set_tx_streamer() " << active << " " << port ; /* Enable all downstream connections: for(const node_ctrl_base::node_map_pair_t downstream_node: list_downstream_nodes()) { diff --git a/host/lib/rfnoc/source_block_ctrl_base.cpp b/host/lib/rfnoc/source_block_ctrl_base.cpp index 3d5d2b2b6..4cc889545 100644 --- a/host/lib/rfnoc/source_block_ctrl_base.cpp +++ b/host/lib/rfnoc/source_block_ctrl_base.cpp @@ -17,7 +17,7 @@ #include "utils.hpp" #include <uhd/rfnoc/source_block_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/constants.hpp> using namespace uhd; @@ -30,9 +30,9 @@ void source_block_ctrl_base::issue_stream_cmd( const uhd::stream_cmd_t &stream_cmd, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::issue_stream_cmd()" ; if (_upstream_nodes.empty()) { - UHD_MSG(warning) << "issue_stream_cmd() not implemented for " << get_block_id() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "issue_stream_cmd() not implemented for " << get_block_id() ; return; } @@ -77,10 +77,10 @@ void source_block_ctrl_base::set_destination( uint32_t next_address, size_t output_block_port ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::set_destination() " << uhd::sid_t(next_address) << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::set_destination() " << uhd::sid_t(next_address) ; sid_t new_sid(next_address); new_sid.set_src(get_address(output_block_port)); - UHD_RFNOC_BLOCK_TRACE() << " Setting SID: " << new_sid << std::endl << " "; + UHD_RFNOC_BLOCK_TRACE() << " Setting SID: " << new_sid << " "; sr_write(SR_NEXT_DST_SID, (1<<16) | next_address, output_block_port); } @@ -89,7 +89,7 @@ void source_block_ctrl_base::configure_flow_control_out( size_t block_port, UHD_UNUSED(const uhd::sid_t &sid) ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::configure_flow_control_out() buf_size_pkts==" << buf_size_pkts << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::configure_flow_control_out() buf_size_pkts==" << buf_size_pkts ; if (buf_size_pkts < 2) { throw uhd::runtime_error(str( boost::format("Invalid window size %d for block %s. Window size must at least be 2.") diff --git a/host/lib/rfnoc/source_node_ctrl.cpp b/host/lib/rfnoc/source_node_ctrl.cpp index b3cc5e640..1b9d427b9 100644 --- a/host/lib/rfnoc/source_node_ctrl.cpp +++ b/host/lib/rfnoc/source_node_ctrl.cpp @@ -16,7 +16,7 @@ // #include "utils.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> #include <uhd/rfnoc/sink_node_ctrl.hpp> @@ -35,7 +35,7 @@ size_t source_node_ctrl::connect_downstream( void source_node_ctrl::set_rx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "source_node_ctrl::set_rx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_node_ctrl::set_rx_streamer() " << port << " -> " << active ; /* This will enable all upstream blocks: for(const node_ctrl_base::node_map_pair_t upstream_node: list_upstream_nodes()) { diff --git a/host/lib/rfnoc/tx_stream_terminator.cpp b/host/lib/rfnoc/tx_stream_terminator.cpp index 8544b945d..1d2653d47 100644 --- a/host/lib/rfnoc/tx_stream_terminator.cpp +++ b/host/lib/rfnoc/tx_stream_terminator.cpp @@ -44,7 +44,7 @@ void tx_stream_terminator::set_rx_streamer(bool, const size_t) void tx_stream_terminator::set_tx_streamer(bool active, const size_t /* port */) { // TODO this is identical to sink_node_ctrl::set_tx_streamer() -> factor out - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::set_tx_streamer() " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::set_tx_streamer() " << active; for(const node_ctrl_base::node_map_pair_t downstream_node: _downstream_nodes) { sink_node_ctrl::sptr curr_downstream_block_ctrl = boost::dynamic_pointer_cast<sink_node_ctrl>(downstream_node.second.lock()); @@ -61,7 +61,7 @@ void tx_stream_terminator::set_tx_streamer(bool active, const size_t /* port */) tx_stream_terminator::~tx_stream_terminator() { - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::~tx_stream_terminator() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::~tx_stream_terminator() " ; set_tx_streamer(false, 0); } diff --git a/host/lib/rfnoc/tx_stream_terminator.hpp b/host/lib/rfnoc/tx_stream_terminator.hpp index 169d7cd6a..dd2b991f6 100644 --- a/host/lib/rfnoc/tx_stream_terminator.hpp +++ b/host/lib/rfnoc/tx_stream_terminator.hpp @@ -24,7 +24,7 @@ #include <uhd/rfnoc/scalar_node_ctrl.hpp> #include <uhd/rfnoc/terminator_node_ctrl.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> // For the block macros -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> namespace uhd { namespace rfnoc { @@ -51,7 +51,7 @@ public: void issue_stream_cmd(const uhd::stream_cmd_t &, const size_t) { - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::issue_stream_cmd()" ; } // If this is called, then by a send terminator at the other end diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index 720e54e4d..2a6fc2b8a 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -17,7 +17,7 @@ #include "libusb1_base.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/types/dict.hpp> @@ -76,7 +76,7 @@ private: case LIBUSB_ERROR_NO_DEVICE: throw uhd::io_error(libusb_strerror(LIBUSB_ERROR_NO_DEVICE)); default: - UHD_MSG(error) << __FUNCTION__ << ": " << libusb_strerror((libusb_error)ret) << std::endl; + UHD_LOGGER_ERROR("USB") << __FUNCTION__ << ": " << libusb_strerror((libusb_error)ret) ; break; } } @@ -275,15 +275,15 @@ public: { int ret; ret = libusb_clear_halt(this->get(), recv_endpoint | 0x80); - UHD_LOG << "usb device handle: recv endpoint clear: " << libusb_error_name(ret) << std::endl; + UHD_LOGGER_DEBUG("USB") << "usb device handle: recv endpoint clear: " << libusb_error_name(ret) ; ret = libusb_clear_halt(this->get(), send_endpoint | 0x00); - UHD_LOG << "usb device handle: send endpoint clear: " << libusb_error_name(ret) << std::endl; + UHD_LOGGER_DEBUG("USB") << "usb device handle: send endpoint clear: " << libusb_error_name(ret) ; } void reset_device(void) { int ret = libusb_reset_device(this->get()); - UHD_LOG << "usb device handle: dev Reset: " << libusb_error_name(ret) << std::endl; + UHD_LOGGER_DEBUG("USB") << "usb device handle: dev Reset: " << libusb_error_name(ret) ; } private: @@ -320,12 +320,12 @@ libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::spt } catch(const uhd::exception &){ #ifdef UHD_PLATFORM_LINUX - UHD_MSG(error) << + UHD_LOGGER_ERROR("USB") << "USB open failed: insufficient permissions.\n" "See the application notes for your device.\n" - << std::endl; + ; #else - UHD_LOG << "USB open failed: device already claimed." << std::endl; + UHD_LOGGER_DEBUG("USB") << "USB open failed: device already claimed." ; #endif throw; } diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 719893bcd..39666af94 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -19,7 +19,7 @@ #include <uhd/transport/usb_zero_copy.hpp> #include <uhd/transport/buffer_pool.hpp> #include <uhd/transport/bounded_buffer.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/function.hpp> diff --git a/host/lib/transport/nirio/rpc/rpc_client.cpp b/host/lib/transport/nirio/rpc/rpc_client.cpp index 7beaf9974..4dfcd29e0 100644 --- a/host/lib/transport/nirio/rpc/rpc_client.cpp +++ b/host/lib/transport/nirio/rpc/rpc_client.cpp @@ -25,7 +25,7 @@ if (status) { \ status = (static_cast<size_t>((func)) == exp); \ } else { \ - UHD_LOG << "rpc_client operation skipped: " #func "\n"; \ + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client operation skipped: " #func "\n"; \ } \ namespace uhd { namespace usrprio_rpc { @@ -57,7 +57,7 @@ rpc_client::rpc_client ( tcp::resolver::iterator iterator = resolver.resolve(query); boost::asio::connect(_socket, iterator); - UHD_LOG << "rpc_client connected to server." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client connected to server." ; try { //Perform handshake @@ -75,24 +75,24 @@ rpc_client::rpc_client ( _hshake_args_client.version >= _hshake_args_server.oldest_comp_version && status) { - UHD_LOG << "rpc_client bound to server." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client bound to server." ; _wait_for_next_response_header(); //Spawn a thread for the io_service callback handler. This thread will run until rpc_client is destroyed. _io_service_thread.reset(new boost::thread(boost::bind(&boost::asio::io_service::run, &_io_service))); } else { - UHD_LOG << "rpc_client handshake failed." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client handshake failed." ; _exec_err.assign(boost::asio::error::connection_refused, boost::asio::error::get_system_category()); } - UHD_LOG << boost::format("rpc_client archive = %d, rpc_server archive = %d\n.") % + UHD_LOGGER_DEBUG("NIRIO") << boost::format("rpc_client archive = %d, rpc_server archive = %d\n.") % _hshake_args_client.boost_archive_version % _hshake_args_server.boost_archive_version; } catch (boost::exception&) { - UHD_LOG << "rpc_client handshake aborted." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client handshake aborted." ; _exec_err.assign(boost::asio::error::connection_refused, boost::asio::error::get_system_category()); } } catch (boost::exception&) { - UHD_LOG << "rpc_client connection request cancelled/aborted." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client connection request cancelled/aborted." ; _exec_err.assign(boost::asio::error::connection_aborted, boost::asio::error::get_system_category()); } } @@ -136,18 +136,18 @@ const boost::system::error_code& rpc_client::call( //Wait for response using condition variable if (status) { if (!_exec_gate.timed_wait(lock, timeout)) { - UHD_LOG << "rpc_client function timed out." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client function timed out." ; _exec_err.assign(boost::asio::error::timed_out, boost::asio::error::get_system_category()); } } else { - UHD_LOG << "rpc_client connection dropped." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client connection dropped." ; _exec_err.assign(boost::asio::error::connection_aborted, boost::asio::error::get_system_category()); _stop_io_service(); } //Verify that we are talking to the correct endpoint if ((_request.header.client_id != _response.header.client_id) && !_exec_err) { - UHD_LOG << "rpc_client confused about who its talking to." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client confused about who its talking to." ; _exec_err.assign(boost::asio::error::operation_aborted, boost::asio::error::get_system_category()); } @@ -180,7 +180,7 @@ void rpc_client::_handle_response_hdr(const boost::system::error_code& err, size } } else { //Unexpected response. Ignore it. - UHD_LOG << "rpc_client received garbage responses." << std::endl; + UHD_LOGGER_DEBUG("NIRIO") << "rpc_client received garbage responses." ; _exec_err.assign(boost::asio::error::operation_aborted, boost::asio::error::get_system_category()); _wait_for_next_response_header(); diff --git a/host/lib/transport/nirio_zero_copy.cpp b/host/lib/transport/nirio_zero_copy.cpp index 8bec49a5f..e7a37eb08 100644 --- a/host/lib/transport/nirio_zero_copy.cpp +++ b/host/lib/transport/nirio_zero_copy.cpp @@ -19,7 +19,7 @@ #include <stdio.h> #include <uhd/transport/nirio/nirio_fifo.h> #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/atomic.hpp> #include <boost/format.hpp> @@ -131,11 +131,11 @@ public: _xport_params(xport_params), _next_recv_buff_index(0), _next_send_buff_index(0) { - UHD_LOG << boost::format("Creating PCIe transport for channel %d") % instance << std::endl; - UHD_LOG << boost::format("nirio zero-copy RX transport configured with frame size = %u, #frames = %u, buffer size = %u\n") + UHD_LOGGER_DEBUG("NIRIO") << boost::format("Creating PCIe transport for channel %d") % instance ; + UHD_LOGGER_DEBUG("NIRIO") << boost::format("nirio zero-copy RX transport configured with frame size = %u, #frames = %u, buffer size = %u\n") % _xport_params.recv_frame_size % _xport_params.num_recv_frames % (_xport_params.recv_frame_size * _xport_params.num_recv_frames); - UHD_LOG << boost::format("nirio zero-copy TX transport configured with frame size = %u, #frames = %u, buffer size = %u\n") + UHD_LOGGER_DEBUG("NIRIO") << boost::format("nirio zero-copy TX transport configured with frame size = %u, #frames = %u, buffer size = %u\n") % _xport_params.send_frame_size % _xport_params.num_send_frames % (_xport_params.send_frame_size * _xport_params.num_send_frames); _recv_buffer_pool = buffer_pool::make(_xport_params.num_recv_frames, _xport_params.recv_frame_size); diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index b6b4fb937..4abc73398 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -23,7 +23,7 @@ #include <uhd/exception.hpp> #include <uhd/convert.hpp> #include <uhd/stream.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/types/metadata.hpp> @@ -460,7 +460,7 @@ private: const size_t expected_packet_count = _props[index].packet_count; _props[index].packet_count = (info.ifpi.packet_count + 1) & seq_mask; if (expected_packet_count != info.ifpi.packet_count){ - //UHD_MSG(status) << "expected: " << expected_packet_count << " got: " << info.ifpi.packet_count << std::endl; + //UHD_LOGGER_INFO("STREAMER") << "expected: " << expected_packet_count << " got: " << info.ifpi.packet_count; if (_props[index].handle_flowctrl) { // Always update flow control in this case, because we don't // know which packet was dropped and what state the upstream @@ -573,9 +573,9 @@ private: //handle the case where a bad header exists catch(const uhd::value_error &e){ - UHD_MSG(error) << boost::format( + UHD_LOGGER_ERROR("STREAMER") << boost::format( "The receive packet handler caught a value exception.\n%s" - ) % e.what() << std::endl; + ) % e.what(); std::swap(curr_info, next_info); //save progress from curr -> next curr_info.metadata.error_code = rx_metadata_t::ERROR_CODE_BAD_PACKET; return; @@ -613,7 +613,7 @@ private: rx_metadata_t metadata = curr_info.metadata; _props[index].handle_overflow(); curr_info.metadata = metadata; - UHD_MSG(fastpath) << "O"; + UHD_LOG_FASTPATH("O") } curr_info[index].buff.reset(); curr_info[index].copy_buff = nullptr; @@ -635,18 +635,18 @@ private: prev_info[index].ifpi.num_payload_words32*sizeof(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; } //too many iterations: detect alignment failure if (iterations++ > _alignment_failure_threshold){ - UHD_MSG(error) << boost::format( - "The receive packet handler failed to time-align packets.\n" - "%u received packets were processed by the handler.\n" - "However, a timestamp match could not be determined.\n" - ) % iterations << std::endl; + UHD_LOGGER_ERROR("STREAMER") << boost::format( + "The receive packet handler failed to time-align packets. " + "%u received packets were processed by the handler. " + "However, a timestamp match could not be determined." + ) % iterations; std::swap(curr_info, next_info); //save progress from curr -> next curr_info.metadata.error_code = rx_metadata_t::ERROR_CODE_ALIGNMENT; _props[index].handle_overflow(); diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index 09ae0c882..8ad76fa39 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -23,7 +23,7 @@ #include <uhd/exception.hpp> #include <uhd/convert.hpp> #include <uhd/stream.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/types/metadata.hpp> diff --git a/host/lib/transport/tcp_zero_copy.cpp b/host/lib/transport/tcp_zero_copy.cpp index f2ae51695..6cb5906de 100644 --- a/host/lib/transport/tcp_zero_copy.cpp +++ b/host/lib/transport/tcp_zero_copy.cpp @@ -18,7 +18,7 @@ #include "udp_common.hpp" #include <uhd/transport/tcp_zero_copy.hpp> #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/atomic.hpp> #include <boost/format.hpp> @@ -144,7 +144,7 @@ public: _send_buffer_pool(buffer_pool::make(_num_send_frames, _send_frame_size)), _next_recv_buff_index(0), _next_send_buff_index(0) { - UHD_LOG << boost::format("Creating tcp transport for %s %s") % addr % port << std::endl; + UHD_LOGGER_DEBUG("TCP") << boost::format("Creating tcp transport for %s %s") % addr % port ; //resolve the address asio::ip::tcp::resolver resolver(_io_service); diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp index 0a93941b8..735c199a2 100644 --- a/host/lib/transport/udp_simple.cpp +++ b/host/lib/transport/udp_simple.cpp @@ -31,7 +31,7 @@ public: udp_simple_impl( const std::string &addr, const std::string &port, bool bcast, bool connect ):_connected(connect){ - UHD_LOG << boost::format("Creating udp transport for %s %s") % addr % port << std::endl; + UHD_LOGGER_DEBUG("UDP") << boost::format("Creating udp transport for %s %s") % addr % port ; //resolve the address asio::ip::udp::resolver resolver(_io_service); diff --git a/host/lib/transport/udp_wsa_zero_copy.cpp b/host/lib/transport/udp_wsa_zero_copy.cpp index 52382f84d..c1a4f4db6 100644 --- a/host/lib/transport/udp_wsa_zero_copy.cpp +++ b/host/lib/transport/udp_wsa_zero_copy.cpp @@ -19,7 +19,7 @@ #include <uhd/transport/udp_zero_copy.hpp> #include <uhd/transport/udp_simple.hpp> //mtu #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <boost/format.hpp> #include <vector> @@ -47,11 +47,11 @@ static void check_registry_for_fast_send_threshold(const size_t mtu){ reg_key.Open(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\AFD\\Parameters", KEY_READ) != ERROR_SUCCESS or reg_key.QueryDWORDValue("FastSendDatagramThreshold", threshold) != ERROR_SUCCESS or threshold < mtu ){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("UDP") << boost::format( "The MTU (%d) is larger than the FastSendDatagramThreshold (%d)!\n" "This will negatively affect the transmit performance.\n" "See the transport application notes for more detail.\n" - ) % mtu % threshold << std::endl; + ) % mtu % threshold ; warned = true; } reg_key.Close(); @@ -197,7 +197,7 @@ public: check_registry_for_fast_send_threshold(this->get_send_frame_size()); #endif /*CHECK_REG_SEND_THRESH*/ - UHD_MSG(status) << boost::format("Creating WSA UDP transport for %s:%s") % addr % port << std::endl; + UHD_LOGGER_INFO("UDP") << boost::format("Creating WSA UDP transport for %s:%s") % addr % port ; static uhd_wsa_control uhd_wsa; //makes wsa start happen via lazy initialization UHD_ASSERT_THROW(_num_send_frames <= WSA_MAXIMUM_WAIT_EVENTS); @@ -327,11 +327,11 @@ void check_usr_buff_size( size_t user_buff_size, // Set this to zero for no user-defined preference const std::string tx_rx ){ - UHD_LOG << boost::format( + UHD_LOGGER_DEBUG("UDP") << boost::format( "Target %s sock buff size: %d bytes\n" "Actual %s sock buff size: %d bytes" - ) % tx_rx % user_buff_size % tx_rx % actual_buff_size << std::endl; - if ((user_buff_size != 0.0) and (actual_buff_size < user_buff_size)) UHD_MSG(warning) << boost::format( + ) % tx_rx % user_buff_size % tx_rx % actual_buff_size ; + if ((user_buff_size != 0.0) and (actual_buff_size < user_buff_size)) UHD_LOGGER_WARNING("UDP") << boost::format( "The %s buffer could not be resized sufficiently.\n" "Target sock buff size: %d bytes.\n" "Actual sock buff size: %d bytes.\n" diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index 036a84a05..121bb9b64 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -19,7 +19,7 @@ #include <uhd/transport/udp_zero_copy.hpp> #include <uhd/transport/udp_simple.hpp> //mtu #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/atomic.hpp> #include <boost/format.hpp> @@ -50,11 +50,11 @@ static void check_registry_for_fast_send_threshold(const size_t mtu){ reg_key.Open(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\AFD\\Parameters", KEY_READ) != ERROR_SUCCESS or reg_key.QueryDWORDValue("FastSendDatagramThreshold", threshold) != ERROR_SUCCESS or threshold < mtu ){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("UDP") << boost::format( "The MTU (%d) is larger than the FastSendDatagramThreshold (%d)!\n" "This will negatively affect the transmit performance.\n" "See the transport application notes for more detail.\n" - ) % mtu % threshold << std::endl; + ) % mtu % threshold ; warned = true; } reg_key.Close(); @@ -175,7 +175,7 @@ public: _send_buffer_pool(buffer_pool::make(xport_params.num_send_frames, xport_params.send_frame_size)), _next_recv_buff_index(0), _next_send_buff_index(0) { - UHD_LOG << boost::format("Creating udp transport for %s %s") % addr % port << std::endl; + UHD_LOGGER_DEBUG("UDP") << boost::format("Creating udp transport for %s %s") % addr % port ; #ifdef CHECK_REG_SEND_THRESH check_registry_for_fast_send_threshold(this->get_send_frame_size()); @@ -279,11 +279,11 @@ template<typename Opt> static size_t resize_buff_helper( //resize the buffer if size was provided if (target_size > 0){ actual_size = udp_trans->resize_buff<Opt>(target_size); - UHD_LOG << boost::format( + UHD_LOGGER_DEBUG("UDP") << boost::format( "Target %s sock buff size: %d bytes\n" "Actual %s sock buff size: %d bytes" - ) % name % target_size % name % actual_size << std::endl; - if (actual_size < target_size) UHD_MSG(warning) << boost::format( + ) % name % target_size % name % actual_size ; + if (actual_size < target_size) UHD_LOGGER_WARNING("UDP") << boost::format( "The %s buffer could not be resized sufficiently.\n" "Target sock buff size: %d bytes.\n" "Actual sock buff size: %d bytes.\n" diff --git a/host/lib/transport/xport_benchmarker.hpp b/host/lib/transport/xport_benchmarker.hpp index 7383d34f1..ffafbea5a 100644 --- a/host/lib/transport/xport_benchmarker.hpp +++ b/host/lib/transport/xport_benchmarker.hpp @@ -20,7 +20,7 @@ #include <uhd/transport/zero_copy.hpp> #include <uhd/types/device_addr.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread/thread.hpp> #include <uhd/transport/vrt_if_packet.hpp> diff --git a/host/lib/transport/zero_copy_recv_offload.cpp b/host/lib/transport/zero_copy_recv_offload.cpp index e8b013abc..d2c4d2991 100644 --- a/host/lib/transport/zero_copy_recv_offload.cpp +++ b/host/lib/transport/zero_copy_recv_offload.cpp @@ -18,7 +18,7 @@ #include <uhd/transport/zero_copy_recv_offload.hpp> #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/buffer_pool.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/format.hpp> @@ -47,7 +47,7 @@ public: _inbox(transport->get_num_recv_frames()), _recv_done(false) { - UHD_LOG << "Created threaded transport" << std::endl; + UHD_LOGGER_DEBUG("XPORT") << "Created threaded transport" ; // Create the receive and send threads to offload // the system calls onto other threads diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 71acd7f1f..69380fa26 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -71,7 +71,7 @@ std::string device_addr_t::to_string(void) const{ return args_str; } -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ //------------ support old deprecated way and print warning -------- @@ -83,7 +83,7 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ for (size_t i = 0; i < addrs.size(); i++){ fixed_dev_addr[str(boost::format("addr%d") % i)] = addrs[i]; } - UHD_MSG(warning) << + UHD_LOGGER_WARNING("UHD") << "addr = <space separated list of ip addresses> is deprecated.\n" "To address a multi-device, use multiple <key><index> = <val>.\n" "See the USRP-NXXX application notes. Two device example:\n" diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index d87d0890d..25f99e85e 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -19,7 +19,7 @@ #include "b100_impl.hpp" #include "b100_regs.hpp" #include <uhd/transport/usb_control.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> @@ -80,10 +80,10 @@ static device_addrs_t b100_find(const device_addr_t &hint) b100_fw_image = find_image_path(hint.get("fw", B100_FW_FILE_NAME)); } catch(...){ - UHD_MSG(warning) << boost::format("Could not locate B100 firmware. %s\n") % print_utility_error("uhd_images_downloader.py"); + UHD_LOGGER_WARNING("B100") << boost::format("Could not locate B100 firmware. %s\n") % print_utility_error("uhd_images_downloader.py"); return b100_addrs; } - UHD_LOG << "the firmware image: " << b100_fw_image << std::endl; + UHD_LOGGER_DEBUG("B100") << "the firmware image: " << b100_fw_image ; usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -202,9 +202,9 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //try reset once in the case of failure catch(const uhd::exception &ex){ if (initialization_count > 1) throw; - UHD_MSG(warning) << + UHD_LOGGER_WARNING("B100") << "The control endpoint was left in a bad state.\n" - "Attempting endpoint re-enumeration...\n" << ex.what() << std::endl; + "Attempting endpoint re-enumeration...\n" << ex.what() ; _fifo_ctrl.reset(); _ctrl_transport.reset(); _fx2_ctrl->usrp_fx2_reset(); @@ -230,9 +230,9 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //try reset once in the case of failure catch(const uhd::exception &){ if (initialization_count > 1) throw; - UHD_MSG(warning) << + UHD_LOGGER_WARNING("B100") << "The control endpoint was left in a bad state.\n" - "Attempting endpoint re-enumeration...\n" << std::endl; + "Attempting endpoint re-enumeration...\n" ; _fifo_ctrl.reset(); _ctrl_transport.reset(); _fx2_ctrl->usrp_fx2_reset(); diff --git a/host/lib/usrp/b100/clock_ctrl.cpp b/host/lib/usrp/b100/clock_ctrl.cpp index 99ad6a052..cc20e4a0f 100644 --- a/host/lib/usrp/b100/clock_ctrl.cpp +++ b/host/lib/usrp/b100/clock_ctrl.cpp @@ -18,7 +18,7 @@ #include "clock_ctrl.hpp" #include "ad9522_regs.hpp" #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/exception.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/safe_call.hpp> @@ -148,11 +148,11 @@ static clock_settings_type get_clock_settings(double rate){ cs.chan_divider /= cs.vco_divider; } - UHD_LOGV(always) - << "gcd " << gcd << std::endl - << "X " << X << std::endl - << "Y " << Y << std::endl - << cs.to_pp_string() << std::endl + UHD_LOGGER_DEBUG("B100") + << "gcd: " << gcd + << " X: " << X + << " Y: " << Y + << cs.to_pp_string() ; //filter limits on the counters @@ -166,7 +166,7 @@ static clock_settings_type get_clock_settings(double rate){ if (cs.get_vco_rate() < 1400e6 + vco_bound_pad) continue; if (cs.get_out_rate() != rate) continue; - UHD_MSG(status) << "USRP-B100 clock control: " << i << std::endl << cs.to_pp_string() << std::endl; + UHD_LOGGER_INFO("B100") << "USRP-B100 clock control: " << i << cs.to_pp_string() ; return cs; } } @@ -465,7 +465,7 @@ private: void send_reg(uint16_t addr){ uint32_t reg = _ad9522_regs.get_write_reg(addr); - UHD_LOGV(often) << "clock control write reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("B100") << "clock control write reg: " << std::hex << reg ; byte_vector_t buf; buf.push_back(uint8_t(reg >> 16)); buf.push_back(uint8_t(reg >> 8)); @@ -501,7 +501,7 @@ private: _ad9522_regs.set_reg(addr, reg); if (_ad9522_regs.vco_calibration_finished) goto wait_for_ld; } - UHD_MSG(error) << "USRP-B100 clock control: VCO calibration timeout" << std::endl; + UHD_LOGGER_ERROR("B100") << "USRP-B100 clock control: VCO calibration timeout"; wait_for_ld: //wait for digital lock detect: for (size_t ms10 = 0; ms10 < 100; ms10++){ @@ -510,7 +510,7 @@ private: _ad9522_regs.set_reg(addr, reg); if (_ad9522_regs.digital_lock_detect) return; } - UHD_MSG(error) << "USRP-B100 clock control: lock detection timeout" << std::endl; + UHD_LOGGER_ERROR("B100") << "USRP-B100 clock control: lock detection timeout"; } void soft_sync(void){ diff --git a/host/lib/usrp/b100/codec_ctrl.cpp b/host/lib/usrp/b100/codec_ctrl.cpp index e78608beb..26ee877dc 100644 --- a/host/lib/usrp/b100/codec_ctrl.cpp +++ b/host/lib/usrp/b100/codec_ctrl.cpp @@ -259,7 +259,7 @@ void b100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){ **********************************************************************/ void b100_codec_ctrl_impl::send_reg(uint8_t addr){ uint32_t reg = _ad9862_regs.get_write_reg(addr); - UHD_LOGV(rarely) << "codec control write reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("B100") << "codec control write reg: " << std::hex << reg ; _iface->transact_spi( B100_SPI_SS_AD9862, spi_config_t::EDGE_RISE, @@ -269,13 +269,13 @@ void b100_codec_ctrl_impl::send_reg(uint8_t addr){ void b100_codec_ctrl_impl::recv_reg(uint8_t addr){ uint32_t reg = _ad9862_regs.get_read_reg(addr); - UHD_LOGV(rarely) << "codec control read reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("B100") << "codec control read reg: " << std::hex << reg ; uint32_t ret = _iface->transact_spi( B100_SPI_SS_AD9862, spi_config_t::EDGE_RISE, reg, 16, true /*rb*/ ); - UHD_LOGV(rarely) << "codec control read ret: " << std::hex << uint16_t(ret & 0xFF) << std::endl; + UHD_LOGGER_DEBUG("B100") << "codec control read ret: " << std::hex << uint16_t(ret & 0xFF) ; _ad9862_regs.set_reg(addr, uint8_t(ret&0xff)); } diff --git a/host/lib/usrp/b100/io_impl.cpp b/host/lib/usrp/b100/io_impl.cpp index 09973491c..7cccc7752 100644 --- a/host/lib/usrp/b100/io_impl.cpp +++ b/host/lib/usrp/b100/io_impl.cpp @@ -23,7 +23,7 @@ #include <boost/format.hpp> #include <boost/bind.hpp> #include <boost/thread.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <boost/make_shared.hpp> diff --git a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp index 568b7add9..ea3e9f87e 100644 --- a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp +++ b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp @@ -18,7 +18,7 @@ #include <uhd/transport/usb_zero_copy.hpp> #include <uhd/transport/buffer_pool.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/atomic.hpp> #include <boost/make_shared.hpp> diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 6f9bdd330..81752b28f 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -19,7 +19,7 @@ #include "../../utils/ihex.hpp" #include <uhd/config.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/functional/hash.hpp> @@ -212,7 +212,7 @@ public: void load_firmware(const std::string filestring, UHD_UNUSED(bool force) = false) { if (load_img_msg) - UHD_MSG(status) << "Loading firmware image: " + UHD_LOGGER_INFO("B200") << "Loading firmware image: " << filestring << "..." << std::flush; ihex_reader file_reader(filestring); @@ -227,7 +227,7 @@ public: throw uhd::io_error(str(boost::format("Could not load firmware: \n%s") % e.what())); } - UHD_MSG(status) << std::endl; + UHD_LOGGER_INFO("B200") ; //TODO //usrp_set_firmware_hash(hash); //set hash before reset @@ -446,7 +446,7 @@ public: wait_count++; } while(fx3_state != FX3_STATE_FPGA_READY); - if (load_img_msg) UHD_MSG(status) << "Loading FPGA image: " \ + if (load_img_msg) UHD_LOGGER_INFO("B200") << "Loading FPGA image: " \ << filestring << "..." << std::flush; bytes_to_xfer = 1; @@ -487,13 +487,13 @@ public: if (load_img_msg) { - if (bytes_sent == 0) UHD_MSG(status) << " 0%" << std::flush; + if (bytes_sent == 0) UHD_LOGGER_INFO("B200") << " 0%" << std::flush; const size_t percent_before = size_t((bytes_sent*100)/file_size); bytes_sent += transfer_count; const size_t percent_after = size_t((bytes_sent*100)/file_size); if (percent_before != percent_after) { - UHD_MSG(status) << "\b\b\b\b" << std::setw(3) << percent_after << "%" << std::flush; + UHD_LOGGER_INFO("B200") << "\b\b\b\b" << std::setw(3) << percent_after << "%" << std::flush; } } } @@ -516,7 +516,7 @@ public: usrp_set_fpga_hash(hash); if (load_img_msg) - UHD_MSG(status) << "\b\b\b\b done" << std::endl; + UHD_LOGGER_INFO("B200") << "\b\b\b\b done" ; return 0; } diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index fd87cf24a..a513e1336 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -19,7 +19,7 @@ #include "b200_regs.hpp" #include <uhd/config.hpp> #include <uhd/transport/usb_control.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> @@ -190,10 +190,10 @@ static device_addrs_t b200_find(const device_addr_t &hint) b200_fw_image = uhd::find_image_path(b200_fw_image, STR(UHD_IMAGES_DIR)); // FIXME } catch(uhd::exception &e){ - UHD_MSG(warning) << e.what(); + UHD_LOGGER_WARNING("B200") << e.what(); return b200_addrs; } - UHD_LOG << "the firmware image: " << b200_fw_image << std::endl; + UHD_LOGGER_DEBUG("B200") << "the firmware image: " << b200_fw_image ; usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -261,7 +261,7 @@ static device::sptr b200_make(const device_addr_t &device_addr) return device::sptr(new b200_impl(device_addr, handle)); } catch (const uhd::usb_error &) { - UHD_MSG(status) << "Detected bad USB state; resetting." << std::endl; + UHD_LOGGER_INFO("B200") << "Detected bad USB state; resetting." ; libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle( boost::static_pointer_cast<libusb::special_handle>(handle)->get_device() )); @@ -390,7 +390,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s _revision = boost::lexical_cast<size_t>(mb_eeprom["revision"]); } - UHD_MSG(status) << "Detected Device: " << B2XX_STR_NAMES[_product] << std::endl; + UHD_LOGGER_INFO("B200") << "Detected Device: " << B2XX_STR_NAMES[_product] ; _gpsdo_capable = (not (_product == B200MINI or _product == B205MINI)); @@ -437,7 +437,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s // Create control transport //////////////////////////////////////////////////////////////////// uint8_t usb_speed = _iface->get_usb_speed(); - UHD_MSG(status) << "Operating over USB " << (int) usb_speed << "." << std::endl; + UHD_LOGGER_INFO("B200") << "Operating over USB " << (int) usb_speed << "." ; const std::string min_frame_size = (usb_speed == 3) ? "1024" : "512"; device_addr_t ctrl_xport_args; @@ -488,18 +488,17 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s if ((_local_ctrl->peek32(RB32_CORE_STATUS) & 0xff) != B200_GPSDO_ST_NONE) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("B200") << "Detecting internal GPSDO.... " << std::flush; try { _gps = gps_ctrl::make(_async_task_data->gpsdo_uart); } catch(std::exception &e) { - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("B200") << "An error occurred making GPSDO control: " << e.what(); } if (_gps and _gps->gps_detected()) { - //UHD_MSG(status) << "found" << std::endl; for(const std::string &name: _gps->get_sensors()) { _tree->create<sensor_value_t>(mb_path / "sensors" / name) @@ -553,7 +552,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // Init codec - turns on clocks //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Initialize CODEC control..." << std::endl; + UHD_LOGGER_INFO("B200") << "Initialize CODEC control..." ; ad9361_params::sptr client_settings; if (_product == B200MINI or _product == B205MINI) { client_settings = boost::make_shared<b2xxmini_ad9361_client_t>(); @@ -610,7 +609,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // setup radio control //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Initialize Radio control..." << std::endl; + UHD_LOGGER_INFO("B200") << "Initialize Radio control..." ; const size_t num_radio_chains = ((_local_ctrl->peek32(RB32_CORE_STATUS) >> 8) & 0xff); UHD_ASSERT_THROW(num_radio_chains > 0); UHD_ASSERT_THROW(num_radio_chains <= 2); @@ -692,7 +691,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // Init the clock rate and the auto mcr appropriately if (not device_addr.has_key("master_clock_rate")) { - UHD_MSG(status) << "Setting master clock rate selection to 'automatic'." << std::endl; + UHD_LOGGER_INFO("B200") << "Setting master clock rate selection to 'automatic'." ; } // We can automatically choose a master clock rate, but not if the user specifies one const double default_tick_rate = device_addr.cast<double>("master_clock_rate", ad936x_manager::DEFAULT_TICK_RATE); @@ -874,7 +873,7 @@ void b200_impl::setup_radio(const size_t dspno) void b200_impl::register_loopback_self_test(wb_iface::sptr iface) { bool test_fail = false; - UHD_MSG(status) << "Performing register loopback test... " << std::flush; + UHD_LOGGER_INFO("B200") << "Performing register loopback test... " << std::flush; size_t hash = size_t(time(NULL)); for (size_t i = 0; i < 100; i++) { @@ -883,7 +882,7 @@ void b200_impl::register_loopback_self_test(wb_iface::sptr iface) test_fail = iface->peek32(RB32_TEST) != uint32_t(hash); if (test_fail) break; //exit loop on any failure } - UHD_MSG(status) << ((test_fail)? "fail" : "pass") << std::endl; + UHD_LOGGER_INFO("B200") << ((test_fail)? "fail" : "pass") ; } /*********************************************************************** @@ -919,18 +918,18 @@ void b200_impl::enforce_tick_rate_limits(size_t chan_count, double tick_rate, co double b200_impl::set_tick_rate(const double new_tick_rate) { - UHD_MSG(status) << (boost::format("Asking for clock rate %.6f MHz... ") % (new_tick_rate/1e6)) << std::flush; + UHD_LOGGER_INFO("B200") << (boost::format("Asking for clock rate %.6f MHz... ") % (new_tick_rate/1e6)) << std::flush; check_tick_rate_with_current_streamers(new_tick_rate); // Defined in b200_io_impl.cpp // Make sure the clock rate is actually changed before doing // the full Monty of setting regs and loopback tests etc. if (std::abs(new_tick_rate - _tick_rate) < 1.0) { - UHD_MSG(status) << "OK" << std::endl; + UHD_LOGGER_INFO("B200") << "OK" ; return _tick_rate; } _tick_rate = _codec_ctrl->set_clock_rate(new_tick_rate); - UHD_MSG(status) << std::endl << (boost::format("Actually got clock rate %.6f MHz.") % (_tick_rate/1e6)) << std::endl; + UHD_LOGGER_INFO("B200") << (boost::format("Actually got clock rate %.6f MHz.") % (_tick_rate/1e6)) ; for(radio_perifs_t &perif: _radio_perifs) { diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 09aaff7ed..7366b06f5 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -135,9 +135,9 @@ void b200_impl::set_auto_tick_rate( _tree->access<double>("/mboards/0/tick_rate").set(new_rate); } } catch (const uhd::value_error &) { - UHD_MSG(warning) - << "Cannot automatically determine an appropriate tick rate for these sampling rates." << std::endl - << "Consider using different sampling rates, or manually specify a suitable master clock rate." << std::endl; + UHD_LOGGER_WARNING("B200") + << "Cannot automatically determine an appropriate tick rate for these sampling rates." + << "Consider using different sampling rates, or manually specify a suitable master clock rate." ; return; // Let the others handle this } } @@ -356,7 +356,7 @@ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( } catch(const std::exception &ex) { - UHD_MSG(error) << "Error parsing ctrl packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("B200") << "Error parsing ctrl packet: " << ex.what(); break; } @@ -370,7 +370,7 @@ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( //doh! default: - UHD_MSG(error) << "Got a ctrl packet with unknown SID " << sid << std::endl; + UHD_LOGGER_ERROR("B200") << "Got a ctrl packet with unknown SID " << sid; } return boost::none; } diff --git a/host/lib/usrp/b200/b200_uart.cpp b/host/lib/usrp/b200/b200_uart.cpp index 016dd4ca3..143600c51 100644 --- a/host/lib/usrp/b200/b200_uart.cpp +++ b/host/lib/usrp/b200/b200_uart.cpp @@ -20,7 +20,7 @@ #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/vrt_if_packet.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/exception.hpp> diff --git a/host/lib/usrp/common/ad9361_ctrl.cpp b/host/lib/usrp/common/ad9361_ctrl.cpp index 0dc5e7919..a1c158eae 100644 --- a/host/lib/usrp/common/ad9361_ctrl.cpp +++ b/host/lib/usrp/common/ad9361_ctrl.cpp @@ -17,7 +17,7 @@ #include "ad9361_ctrl.hpp" #include <uhd/types/ranges.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/serial.hpp> #include <cstring> #include <boost/format.hpp> @@ -153,10 +153,10 @@ public: const double clipped_rate = clock_rate_range.clip(rate); if (clipped_rate != rate) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("AD936X") << boost::format( "The requested master_clock_rate %f MHz exceeds bounds imposed by UHD.\n" "The master_clock_rate has been forced to %f MHz.\n" - ) % (rate/1e6) % (clipped_rate/1e6) << std::endl; + ) % (rate/1e6) % (clipped_rate/1e6) ; } double return_rate = _device.set_clock_rate(clipped_rate); diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp index 110756eb5..e11079ae3 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp @@ -24,7 +24,7 @@ #include <cmath> #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <stdint.h> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/thread/thread.hpp> @@ -321,7 +321,7 @@ double ad9361_device_t::_calibrate_baseband_rx_analog_filter(double req_rfbw) double bbbw = req_rfbw / 2.0; if(bbbw > _baseband_bw / 2.0) { - UHD_LOG << "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; + UHD_LOGGER_DEBUG("AD936X")<< "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; bbbw = _baseband_bw / 2.0; } @@ -388,7 +388,7 @@ double ad9361_device_t::_calibrate_baseband_tx_analog_filter(double req_rfbw) if(bbbw > _baseband_bw / 2.0) { - UHD_LOG << "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; + UHD_LOGGER_DEBUG("AD936X")<< "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; bbbw = _baseband_bw / 2.0; } @@ -443,7 +443,7 @@ double ad9361_device_t::_calibrate_secondary_tx_filter(double req_rfbw) if(bbbw > _baseband_bw / 2.0) { - UHD_LOG << "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; + UHD_LOGGER_DEBUG("AD936X")<< "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; bbbw = _baseband_bw / 2.0; } @@ -539,7 +539,7 @@ double ad9361_device_t::_calibrate_rx_TIAs(double req_rfbw) if(bbbw > _baseband_bw / 2.0) { - UHD_LOG << "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; + UHD_LOGGER_DEBUG("AD936X")<< "baseband bandwidth too large for current sample rate. Setting bandwidth to: "<<_baseband_bw; bbbw = _baseband_bw / 2.0; } @@ -1169,7 +1169,7 @@ void ad9361_device_t::_setup_synth(direction_t direction, double vcorate) * fed to the public set_clock_rate function. */ double ad9361_device_t::_tune_bbvco(const double rate) { - UHD_LOG << boost::format("[ad9361_device_t::_tune_bbvco] rate=%.10f\n") % rate; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_tune_bbvco] rate=%.10f\n") % rate; /* Let's not re-tune to the same frequency over and over... */ if (freq_is_nearly_equal(rate, _req_coreclk)) { @@ -1197,13 +1197,13 @@ double ad9361_device_t::_tune_bbvco(const double rate) if (i == 7) throw uhd::runtime_error("[ad9361_device_t] _tune_bbvco: wrong vcorate"); - UHD_LOG << boost::format("[ad9361_device_t::_tune_bbvco] vcodiv=%d vcorate=%.10f\n") % vcodiv % vcorate; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_tune_bbvco] vcodiv=%d vcorate=%.10f\n") % vcodiv % vcorate; /* Fo = Fref * (Nint + Nfrac / mod) */ int nint = static_cast<int>(vcorate / fref); - UHD_LOG << boost::format("[ad9361_device_t::_tune_bbvco] (nint)=%.10f\n") % (vcorate / fref); + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_tune_bbvco] (nint)=%.10f\n") % (vcorate / fref); int nfrac = static_cast<int>(boost::math::round(((vcorate / fref) - (double) nint) * (double) modulus)); - UHD_LOG << boost::format("[ad9361_device_t::_tune_bbvco] (nfrac)=%.10f\n") % (((vcorate / fref) - (double) nint) * (double) modulus); - UHD_LOG << boost::format("[ad9361_device_t::_tune_bbvco] nint=%d nfrac=%d\n") % nint % nfrac; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_tune_bbvco] (nfrac)=%.10f\n") % (((vcorate / fref) - (double) nint) * (double) modulus); + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_tune_bbvco] nint=%d nfrac=%d\n") % nint % nfrac; double actual_vcorate = fref * ((double) nint + ((double) nfrac / (double) modulus)); @@ -1381,7 +1381,7 @@ double ad9361_device_t::_setup_rates(const double rate) /* If we make it into this function, then we are tuning to a new rate. * Store the new rate. */ _req_clock_rate = rate; - UHD_LOG << boost::format("[ad9361_device_t::_setup_rates] rate=%.6d\n") % rate; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_setup_rates] rate=%.6d\n") % rate; /* Set the decimation and interpolation values in the RX and TX chains. * This also switches filters in / out. Note that all transmitters and @@ -1467,7 +1467,7 @@ double ad9361_device_t::_setup_rates(const double rate) throw uhd::runtime_error("[ad9361_device_t] [_setup_rates] INVALID_CODE_PATH"); } - UHD_LOG << boost::format("[ad9361_device_t::_setup_rates] divfactor=%d\n") % divfactor; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_setup_rates] divfactor=%d\n") % divfactor; /* Tune the BBPLL to get the ADC and DAC clocks. */ const double adcclk = _tune_bbvco(rate * divfactor); @@ -1489,7 +1489,7 @@ double ad9361_device_t::_setup_rates(const double rate) _io_iface->poke8(0x004, _regs.inputsel); _io_iface->poke8(0x00A, _regs.bbpll); - UHD_LOG << boost::format("[ad9361_device_t::_setup_rates] adcclk=%f\n") % adcclk; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::_setup_rates] adcclk=%f\n") % adcclk; _baseband_bw = (adcclk / divfactor); /* @@ -1798,7 +1798,7 @@ double ad9361_device_t::set_clock_rate(const double req_rate) throw uhd::runtime_error("[ad9361_device_t] Requested master clock rate outside range"); } - UHD_LOG << boost::format("[ad9361_device_t::set_clock_rate] req_rate=%.10f\n") % req_rate; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::set_clock_rate] req_rate=%.10f\n") % req_rate; /* UHD has a habit of requesting the same rate like four times when it * starts up. This prevents that, and any bugs in user code that request @@ -1840,7 +1840,7 @@ double ad9361_device_t::set_clock_rate(const double req_rate) * all the hard work gets done. */ double rate = _setup_rates(req_rate); - UHD_LOG << boost::format("[ad9361_device_t::set_clock_rate] rate=%.10f\n") % rate; + UHD_LOGGER_DEBUG("AD936X")<< boost::format("[ad9361_device_t::set_clock_rate] rate=%.10f\n") % rate; /* Transition to the ALERT state and calibrate everything. */ _io_iface->poke8(0x015, 0x04); //dual synth mode, synth en ctrl en diff --git a/host/lib/usrp/common/ad936x_manager.cpp b/host/lib/usrp/common/ad936x_manager.cpp index 20e06a072..503678554 100644 --- a/host/lib/usrp/common/ad936x_manager.cpp +++ b/host/lib/usrp/common/ad936x_manager.cpp @@ -16,7 +16,7 @@ // #include "ad936x_manager.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/functional/hash.hpp> #include <boost/thread/thread.hpp> @@ -97,7 +97,7 @@ class ad936x_manager_impl : public ad936x_manager ) { // Put AD936x in loopback mode _codec_ctrl->data_port_loopback(true); - UHD_MSG(status) << "Performing CODEC loopback test... " << std::flush; + UHD_LOGGER_INFO("AD936X") << "Performing CODEC loopback test... "; size_t hash = size_t(time(NULL)); // Allow some time for AD936x to enter loopback mode. @@ -126,11 +126,11 @@ class ad936x_manager_impl : public ad936x_manager bool test_fail = word32 != rb_tx or word32 != rb_rx; if(test_fail) { - UHD_MSG(status) << "fail" << std::endl; + UHD_LOGGER_INFO("AD936X") << "CODEC loopback test failed"; throw uhd::runtime_error("CODEC loopback test failed."); } } - UHD_MSG(status) << "pass" << std::endl; + UHD_LOGGER_INFO("AD936X") << "CODEC loopback test passed"; // Zero out the idle data. poker_functor(0); @@ -193,10 +193,10 @@ class ad936x_manager_impl : public ad936x_manager bool check_bandwidth(double rate, const std::string dir) { if (rate > _codec_ctrl->get_bw_filter_range(dir).stop()) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("AD936X") << "Selected " << dir << " bandwidth (" << (rate/1e6) << " MHz) exceeds\n" << "analog frontend filter bandwidth (" << (_codec_ctrl->get_bw_filter_range(dir).stop()/1e6) << " MHz)." - << std::endl; + ; return false; } return true; diff --git a/host/lib/usrp/common/ad936x_manager.hpp b/host/lib/usrp/common/ad936x_manager.hpp index c456715e3..99464d0af 100644 --- a/host/lib/usrp/common/ad936x_manager.hpp +++ b/host/lib/usrp/common/ad936x_manager.hpp @@ -22,6 +22,7 @@ #include <uhd/utils/math.hpp> #include <uhd/property_tree.hpp> #include <uhd/types/direction.hpp> +#include <boost/format.hpp> #include <boost/shared_ptr.hpp> #include "ad9361_ctrl.hpp" #include <stdint.h> diff --git a/host/lib/usrp/common/adf4001_ctrl.cpp b/host/lib/usrp/common/adf4001_ctrl.cpp index 01a35dbec..b824824a4 100644 --- a/host/lib/usrp/common/adf4001_ctrl.cpp +++ b/host/lib/usrp/common/adf4001_ctrl.cpp @@ -22,7 +22,7 @@ #include "adf4001_ctrl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <iostream> #include <iomanip> diff --git a/host/lib/usrp/common/adf435x.hpp b/host/lib/usrp/common/adf435x.hpp index ff7b1a2f4..daa539982 100644 --- a/host/lib/usrp/common/adf435x.hpp +++ b/host/lib/usrp/common/adf435x.hpp @@ -268,14 +268,14 @@ public: adf435x_regs_t::LDF_FRAC_N; std::string tuning_str = (int_n_mode) ? "Integer-N" : "Fractional"; - UHD_LOGV(often) + UHD_LOGGER_DEBUG("ADF435X") << boost::format("ADF 435X Frequencies (MHz): REQUESTED=%0.9f, ACTUAL=%0.9f" - ) % (target_freq/1e6) % (actual_freq/1e6) << std::endl + ) % (target_freq/1e6) % (actual_freq/1e6) << boost::format("ADF 435X Intermediates (MHz): Feedback=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f, REF=%0.2f" - ) % (feedback_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) % (_reference_freq/1e6) << std::endl - << boost::format("ADF 435X Tuning: %s") % tuning_str.c_str() << std::endl + ) % (feedback_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) % (_reference_freq/1e6) + << boost::format("ADF 435X Tuning: %s") % tuning_str.c_str() << boost::format("ADF 435X Settings: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d" - ) % R % BS % N % FRAC % MOD % T % D % RFdiv << std::endl; + ) % R % BS % N % FRAC % MOD % T % D % RFdiv ; UHD_ASSERT_THROW((_regs.frac_12_bit & ((uint16_t)~0xFFF)) == 0); UHD_ASSERT_THROW((_regs.mod_12_bit & ((uint16_t)~0xFFF)) == 0); diff --git a/host/lib/usrp/common/apply_corrections.cpp b/host/lib/usrp/common/apply_corrections.cpp index f1ba47bd9..32c7e3c45 100644 --- a/host/lib/usrp/common/apply_corrections.cpp +++ b/host/lib/usrp/common/apply_corrections.cpp @@ -18,7 +18,7 @@ #include "apply_corrections.hpp" #include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/utils/paths.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/csv.hpp> #include <uhd/types/dict.hpp> #include <boost/filesystem.hpp> @@ -132,7 +132,7 @@ static void apply_fe_corrections( } std::sort(datas.begin(), datas.end(), fe_cal_comp); fe_cal_cache[cal_data_path.string()] = datas; - UHD_MSG(status) << "Loaded " << cal_data_path.string() << std::endl; + UHD_LOGGER_INFO("CAL") << "Calibration data loaded: " << cal_data_path.string(); } @@ -167,7 +167,7 @@ void uhd::usrp::apply_tx_fe_corrections( //overloading to work according to rfno ); } catch(const std::exception &e){ - UHD_MSG(error) << "Failure in apply_tx_fe_corrections: " << e.what() << std::endl; + UHD_LOGGER_ERROR("CAL") << "Failure in apply_tx_fe_corrections: " << e.what(); } } @@ -194,7 +194,7 @@ void uhd::usrp::apply_tx_fe_corrections( ); } catch(const std::exception &e){ - UHD_MSG(error) << "Failure in apply_tx_fe_corrections: " << e.what() << std::endl; + UHD_LOGGER_ERROR("CAL") << "Failure in apply_tx_fe_corrections: " << e.what(); } } @@ -215,7 +215,7 @@ void uhd::usrp::apply_rx_fe_corrections( //overloading to work according to rfno ); } catch(const std::exception &e){ - UHD_MSG(error) << "Failure in apply_tx_fe_corrections: " << e.what() << std::endl; + UHD_LOGGER_ERROR("CAL") << "Failure in apply_tx_fe_corrections: " << e.what(); } } @@ -235,6 +235,6 @@ void uhd::usrp::apply_rx_fe_corrections( ); } catch(const std::exception &e){ - UHD_MSG(error) << "Failure in apply_rx_fe_corrections: " << e.what() << std::endl; + UHD_LOGGER_ERROR("CAL") << "Failure in apply_rx_fe_corrections: " << e.what(); } } diff --git a/host/lib/usrp/common/async_packet_handler.hpp b/host/lib/usrp/common/async_packet_handler.hpp index 20409c77a..15f05e508 100644 --- a/host/lib/usrp/common/async_packet_handler.hpp +++ b/host/lib/usrp/common/async_packet_handler.hpp @@ -22,7 +22,7 @@ #include <uhd/transport/vrt_if_packet.hpp> #include <uhd/types/metadata.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.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/lib/usrp/common/fifo_ctrl_excelsior.cpp b/host/lib/usrp/common/fifo_ctrl_excelsior.cpp index a9995a161..c86380354 100644 --- a/host/lib/usrp/common/fifo_ctrl_excelsior.cpp +++ b/host/lib/usrp/common/fifo_ctrl_excelsior.cpp @@ -18,7 +18,7 @@ #include "fifo_ctrl_excelsior.hpp" #include "async_packet_handler.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/safe_call.hpp> @@ -97,7 +97,7 @@ public: vrt::if_hdr_unpack_le(pkt, packet_info); } catch(const std::exception &ex){ - UHD_MSG(error) << "FIFO ctrl bad VITA packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("UHD") << "FIFO ctrl bad VITA packet: " << ex.what(); } if (packet_info.has_sid and packet_info.sid == _config.ctrl_sid_base){ ctrl_result_t res = ctrl_result_t(); @@ -112,7 +112,7 @@ public: standard_async_msg_prints(metadata); } else{ - UHD_MSG(error) << "FIFO ctrl got unknown SID: " << packet_info.sid << std::endl; + UHD_LOGGER_ERROR("UHD") << "FIFO ctrl got unknown SID: " << packet_info.sid ; } } diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index c69223747..9fa774851 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -16,7 +16,7 @@ // #include "fx2_ctrl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/transport/usb_control.hpp> #include <boost/functional/hash.hpp> @@ -177,7 +177,7 @@ public: unsigned char reset_n = 0; //hit the reset line - if (load_img_msg) UHD_MSG(status) << "Loading firmware image: " << filestring << "..." << std::flush; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "Loading firmware image: " << filestring << "..."; usrp_control_write(FX2_FIRMWARE_LOAD, 0xe600, 0, &reset_y, 1); while (!file.eof()) { @@ -205,7 +205,7 @@ public: //wait for things to settle boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - if (load_img_msg) UHD_MSG(status) << " done" << std::endl; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "Firmware loaded"; return; } //type anything else is unhandled @@ -242,7 +242,7 @@ public: const int ep0_size = 64; unsigned char buf[ep0_size]; - if (load_img_msg) UHD_MSG(status) << "Loading FPGA image: " << filestring << "..." << std::flush; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "Loading FPGA image: " << filestring << "..."; std::ifstream file; file.open(filename, std::ios::in | std::ios::binary); if (not file.good()) { @@ -274,12 +274,12 @@ public: usrp_fpga_reset(false); //done loading, take fpga out of reset file.close(); - if (load_img_msg) UHD_MSG(status) << " done" << std::endl; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "FPGA image loaded"; } void usrp_load_eeprom(std::string filestring) { - if (load_img_msg) UHD_MSG(status) << "Loading EEPROM image: " << filestring << "..." << std::flush; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "Loading EEPROM image: " << filestring << "..."; const char *filename = filestring.c_str(); const uint16_t i2c_addr = 0x50; @@ -315,7 +315,7 @@ public: boost::this_thread::sleep(boost::posix_time::milliseconds(100)); } file.close(); - if (load_img_msg) UHD_MSG(status) << " done" << std::endl; + if (load_img_msg) UHD_LOGGER_INFO("FX2") << "EEPROM image loaded"; } diff --git a/host/lib/usrp/common/max287x.hpp b/host/lib/usrp/common/max287x.hpp index df6f6bc26..ab92df2db 100644 --- a/host/lib/usrp/common/max287x.hpp +++ b/host/lib/usrp/common/max287x.hpp @@ -634,13 +634,13 @@ double max287x<max287x_regs_t>::set_frequency( //actual frequency calculation double actual_freq = double((N + (double(FRAC)/double(MOD)))*ref_freq*(1+int(D))/(R*(1+int(T)))) * fb_divisor / RFdiv; - UHD_LOGV(rarely) + UHD_LOGGER_DEBUG("MAX287X") << boost::format("MAX287x: Intermediates: ref=%0.2f, outdiv=%f, fbdiv=%f" - ) % ref_freq % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << std::endl + ) % ref_freq % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << boost::format("MAX287x: tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, type=%s" - ) % R % BS % N % FRAC % MOD % T % D % RFdiv % ((is_int_n) ? "Integer-N" : "Fractional") << std::endl + ) % R % BS % N % FRAC % MOD % T % D % RFdiv % ((is_int_n) ? "Integer-N" : "Fractional") << boost::format("MAX287x: Frequencies (MHz): REQ=%0.2f, ACT=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f" - ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) << std::endl; + ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) ; //load the register values _regs.rf_output_enable = max287x_regs_t::RF_OUTPUT_ENABLE_ENABLED; diff --git a/host/lib/usrp/common/recv_packet_demuxer.cpp b/host/lib/usrp/common/recv_packet_demuxer.cpp index 8d9dcee9e..2a4c4d705 100644 --- a/host/lib/usrp/common/recv_packet_demuxer.cpp +++ b/host/lib/usrp/common/recv_packet_demuxer.cpp @@ -16,7 +16,7 @@ // #include "recv_packet_demuxer.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/byteswap.hpp> #include <boost/thread/mutex.hpp> #include <uhd/transport/vrt_if_packet.hpp> @@ -87,7 +87,7 @@ public: if (rx_index < _queues.size()) _queues[rx_index].wrapper.push(buff); else { - UHD_MSG(error) << "Got a data packet with unknown SID " << extract_sid(buff) << std::endl; + UHD_LOGGER_ERROR("STREAMER") << "Got a data packet with unknown SID " << extract_sid(buff) ; recv_pkt_demux_mrb *mrb = new recv_pkt_demux_mrb(); vrt::if_packet_info_t info; info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA; diff --git a/host/lib/usrp/common/recv_packet_demuxer_3000.hpp b/host/lib/usrp/common/recv_packet_demuxer_3000.hpp index 3ad76f1a0..a970e81a5 100644 --- a/host/lib/usrp/common/recv_packet_demuxer_3000.hpp +++ b/host/lib/usrp/common/recv_packet_demuxer_3000.hpp @@ -22,7 +22,7 @@ #include <uhd/transport/zero_copy.hpp> #include <stdint.h> #include <boost/thread.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/atomic.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/utils/byteswap.hpp> @@ -103,9 +103,9 @@ namespace uhd{ namespace usrp{ if (new_sid != sid) { boost::mutex::scoped_lock l(mutex); - if (_queues.count(new_sid) == 0) UHD_MSG(error) + if (_queues.count(new_sid) == 0) UHD_LOGGER_ERROR("STREAMER") << "recv packet demuxer unexpected sid 0x" << std::hex << new_sid << std::dec - << std::endl; + ; else _queues[new_sid].push(buff); buff.reset(); } diff --git a/host/lib/usrp/cores/dma_fifo_core_3000.cpp b/host/lib/usrp/cores/dma_fifo_core_3000.cpp index e1a841b96..18c79f4c5 100644 --- a/host/lib/usrp/cores/dma_fifo_core_3000.cpp +++ b/host/lib/usrp/cores/dma_fifo_core_3000.cpp @@ -19,7 +19,7 @@ #include <uhd/exception.hpp> #include <boost/thread/thread.hpp> //sleep #include <uhd/utils/soft_register.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd; diff --git a/host/lib/usrp/cores/i2c_core_100.cpp b/host/lib/usrp/cores/i2c_core_100.cpp index 029b6eaa7..e68dc2ea6 100644 --- a/host/lib/usrp/cores/i2c_core_100.cpp +++ b/host/lib/usrp/cores/i2c_core_100.cpp @@ -17,7 +17,7 @@ #include "i2c_core_100.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> //sleep #define REG_I2C_PRESCALER_LO _base + 0 @@ -127,7 +127,7 @@ private: if ((_iface->peek16(REG_I2C_CMD_STATUS) & I2C_ST_TIP) == 0) return; boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } - UHD_MSG(error) << "i2c_core_100: i2c_wait timeout" << std::endl; + UHD_LOGGER_ERROR("CORES") << "i2c_core_100: i2c_wait timeout" ; } bool wait_chk_ack(void){ diff --git a/host/lib/usrp/cores/i2c_core_100_wb32.cpp b/host/lib/usrp/cores/i2c_core_100_wb32.cpp index 099b80447..8e03a8c3c 100644 --- a/host/lib/usrp/cores/i2c_core_100_wb32.cpp +++ b/host/lib/usrp/cores/i2c_core_100_wb32.cpp @@ -17,7 +17,7 @@ #include "i2c_core_100_wb32.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> //sleep #define REG_I2C_PRESCALER_LO _base + 0 @@ -138,7 +138,7 @@ private: if ((_iface->peek32(REG_I2C_CMD_STATUS) & I2C_ST_TIP) == 0) return; boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } - UHD_MSG(error) << "i2c_core_100_wb32: i2c_wait timeout" << std::endl; + UHD_LOGGER_ERROR("CORES") << "i2c_core_100_wb32: i2c_wait timeout" ; } bool wait_chk_ack(void){ diff --git a/host/lib/usrp/cores/i2c_core_200.cpp b/host/lib/usrp/cores/i2c_core_200.cpp index eae91253c..7b28573e9 100644 --- a/host/lib/usrp/cores/i2c_core_200.cpp +++ b/host/lib/usrp/cores/i2c_core_200.cpp @@ -17,7 +17,7 @@ #include "i2c_core_200.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> //sleep #include <boost/thread/mutex.hpp> @@ -130,7 +130,7 @@ private: if ((this->peek(REG_I2C_RD_ST) & I2C_ST_TIP) == 0) return; boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } - UHD_MSG(error) << "i2c_core_200: i2c_wait timeout" << std::endl; + UHD_LOGGER_ERROR("CORES") << "i2c_core_200: i2c_wait timeout" ; } bool wait_chk_ack(void){ diff --git a/host/lib/usrp/cores/radio_ctrl_core_3000.cpp b/host/lib/usrp/cores/radio_ctrl_core_3000.cpp index 2e405d735..512a860e0 100644 --- a/host/lib/usrp/cores/radio_ctrl_core_3000.cpp +++ b/host/lib/usrp/cores/radio_ctrl_core_3000.cpp @@ -18,7 +18,7 @@ #include "radio_ctrl_core_3000.hpp" #include "async_packet_handler.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/bounded_buffer.hpp> @@ -165,7 +165,7 @@ private: //load payload pkt[packet_info.num_header_words32+0] = (_bige)? uhd::htonx(addr) : uhd::htowx(addr); pkt[packet_info.num_header_words32+1] = (_bige)? uhd::htonx(data) : uhd::htowx(data); - //UHD_MSG(status) << boost::format("0x%08x, 0x%08x\n") % addr % data; + //UHD_LOGGER_INFO("radio_ctrl") << boost::format("0x%08x, 0x%08x\n") % addr % data; //send the buffer over the interface _outstanding_seqs.push(_seq_out); buff->commit(sizeof(uint32_t)*(packet_info.num_packet_words32)); @@ -243,17 +243,17 @@ private: } catch(const std::exception &ex) { - UHD_MSG(error) << "Radio ctrl bad VITA packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("radio_ctrl") << "Radio ctrl bad VITA packet: " << ex.what() ; if (buff){ UHD_VAR(buff->size()); } else{ - UHD_MSG(status) << "buff is NULL" << std::endl; + UHD_LOGGER_INFO("radio_ctrl") << "buff is NULL" ; } - UHD_MSG(status) << std::hex << pkt[0] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[1] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[2] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[3] << std::dec << std::endl; + UHD_LOGGER_INFO("radio_ctrl") << std::hex << pkt[0] << std::dec ; + UHD_LOGGER_INFO("radio_ctrl") << std::hex << pkt[1] << std::dec ; + UHD_LOGGER_INFO("radio_ctrl") << std::hex << pkt[2] << std::dec ; + UHD_LOGGER_INFO("radio_ctrl") << std::hex << pkt[3] << std::dec ; } //check the buffer diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index e781cfc6d..465a3b913 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -20,7 +20,7 @@ #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> #include <uhd/utils/math.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/assign/list_of.hpp> #include <boost/thread/thread.hpp> //thread sleep @@ -195,7 +195,7 @@ public: if (decim > 1 and hb0 == 0 and hb1 == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("CORES") << boost::format( "The requested decimation is odd; the user should expect CIC rolloff.\n" "Select an even decimation to ensure that a halfband filter is enabled.\n" "decimation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp index fdd73a7ac..45e4c6f49 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp @@ -20,7 +20,7 @@ #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> #include <uhd/utils/math.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/assign/list_of.hpp> #include <boost/thread/thread.hpp> //thread sleep @@ -169,7 +169,7 @@ public: _iface->poke32(REG_DSP_RX_DECIM, (hb0 << 9) /*small HB */ | (hb1 << 8) /*large HB*/ | (decim & 0xff)); if (decim > 1 and hb0 == 0 and hb1 == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("CORES") << boost::format( "The requested decimation is odd; the user should expect CIC rolloff.\n" "Select an even decimation to ensure that a halfband filter is enabled.\n" "decimation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" @@ -189,7 +189,7 @@ public: _iface->poke32(REG_DSP_RX_DECIM, (hb_enable << 8) | (decim & 0xff)); if (decim > 1 and hb0 == 0 and hb1 == 0 and hb2 == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("CORES") << boost::format( "The requested decimation is odd; the user should expect passband CIC rolloff.\n" "Select an even decimation to ensure that a halfband filter is enabled.\n" "Decimations factorable by 4 will enable 2 halfbands, those factorable by 8 will enable 3 halfbands.\n" diff --git a/host/lib/usrp/cores/rx_vita_core_3000.cpp b/host/lib/usrp/cores/rx_vita_core_3000.cpp index 57868ff54..e10913a22 100644 --- a/host/lib/usrp/cores/rx_vita_core_3000.cpp +++ b/host/lib/usrp/cores/rx_vita_core_3000.cpp @@ -16,7 +16,7 @@ // #include "rx_vita_core_3000.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/assign/list_of.hpp> #include <boost/tuple/tuple.hpp> @@ -96,7 +96,7 @@ struct rx_vita_core_3000_impl : rx_vita_core_3000 { if (not _is_setup) { - //UHD_MSG(warning) << "rx vita core 3000 issue stream command - not setup yet!"; + //UHD_LOGGER_WARNING("CORES") << "rx vita core 3000 issue stream command - not setup yet!"; return; } UHD_ASSERT_THROW(stream_cmd.num_samps <= 0x0fffffff); diff --git a/host/lib/usrp/cores/spi_core_100.cpp b/host/lib/usrp/cores/spi_core_100.cpp index 22b163b14..4d61821b4 100644 --- a/host/lib/usrp/cores/spi_core_100.cpp +++ b/host/lib/usrp/cores/spi_core_100.cpp @@ -17,7 +17,7 @@ #include "spi_core_100.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> //sleep #define REG_SPI_TXRX0 _base + 0 @@ -80,7 +80,7 @@ private: if ((_iface->peek16(REG_SPI_CTRL) & SPI_CTRL_GO_BSY) == 0) return; boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } - UHD_MSG(error) << "spi_core_100: spi_wait timeout" << std::endl; + UHD_LOGGER_ERROR("CORES") << "spi_core_100: spi_wait timeout" ; } wb_iface::sptr _iface; diff --git a/host/lib/usrp/cores/spi_core_3000.cpp b/host/lib/usrp/cores/spi_core_3000.cpp index 78b0af1a3..2abbac317 100644 --- a/host/lib/usrp/cores/spi_core_3000.cpp +++ b/host/lib/usrp/cores/spi_core_3000.cpp @@ -17,7 +17,7 @@ #include "spi_core_3000.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> //sleep #define SPI_DIV _base + 0 diff --git a/host/lib/usrp/cores/time_core_3000.cpp b/host/lib/usrp/cores/time_core_3000.cpp index 25142b9fe..296923756 100644 --- a/host/lib/usrp/cores/time_core_3000.cpp +++ b/host/lib/usrp/cores/time_core_3000.cpp @@ -17,7 +17,7 @@ #include "time_core_3000.hpp" #include <uhd/utils/safe_call.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> #define REG_TIME_HI _base + 0 @@ -63,21 +63,21 @@ struct time_core_3000_impl : time_core_3000 void self_test(void) { const size_t sleep_millis = 100; - UHD_MSG(status) << "Performing timer loopback test... " << std::flush; + UHD_LOGGER_INFO("CORES") << "Performing timer loopback test... "; const time_spec_t time0 = this->get_time_now(); boost::this_thread::sleep(boost::posix_time::milliseconds(sleep_millis)); const time_spec_t time1 = this->get_time_now(); const double approx_secs = (time1 - time0).get_real_secs(); const bool test_fail = (approx_secs > 0.15) or (approx_secs < 0.05); - UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl; + UHD_LOGGER_INFO("CORES") << "Timer loopback test " << ((test_fail)? "failed" : "passed"); //useful warning for debugging actual rate const size_t ticks_elapsed = size_t(_tick_rate*approx_secs); const size_t approx_rate = size_t(ticks_elapsed/(sleep_millis/1e3)); - if (test_fail) UHD_MSG(warning) + if (test_fail) UHD_LOGGER_WARNING("CORES") << "Expecting clock rate: " << (_tick_rate/1e6) << " MHz\n" << "Approximate clock rate: " << (approx_rate/1e6) << " MHz\n" - << std::endl; + ; } uhd::time_spec_t get_time_now(void) diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index 4e1743ee1..f1bf560dc 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -20,7 +20,7 @@ #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> #include <uhd/utils/math.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/assign/list_of.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/thread/thread.hpp> //sleep @@ -135,7 +135,7 @@ public: if (interp > 1 and hb0 == 0 and hb1 == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("CORES") << boost::format( "The requested interpolation is odd; the user should expect CIC rolloff.\n" "Select an even interpolation to ensure that a halfband filter is enabled.\n" "interpolation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp index 67ff418b3..c30e8dfc1 100644 --- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp @@ -20,7 +20,7 @@ #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> #include <uhd/utils/math.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/assign/list_of.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/thread/thread.hpp> //sleep @@ -103,7 +103,7 @@ public: if (interp > 1 and hb0 == 0 and hb1 == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("CORES") << boost::format( "The requested interpolation is odd; the user should expect CIC rolloff.\n" "Select an even interpolation to ensure that a halfband filter is enabled.\n" "interpolation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 941a80ea4..a3d9fb316 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -19,7 +19,7 @@ #include <uhd/types/ranges.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> diff --git a/host/lib/usrp/dboard/db_cbx.cpp b/host/lib/usrp/dboard/db_cbx.cpp index 05f8846d6..11cb092b8 100644 --- a/host/lib/usrp/dboard/db_cbx.cpp +++ b/host/lib/usrp/dboard/db_cbx.cpp @@ -51,9 +51,9 @@ void sbx_xcvr::cbx::write_lo_regs(dboard_iface::unit_t unit, const std::vector<u * Tuning **********************************************************************/ double sbx_xcvr::cbx::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("CBX") << boost::format( "CBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; //clip the input target_freq = cbx_freq_range.clip(target_freq); diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 2862f97dc..80faba5d2 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -24,7 +24,7 @@ #include <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> @@ -98,9 +98,9 @@ private: //get the register data for(int i=0; i<num_bytes; i++){ regs_vector[1+i] = _max2118_write_regs.get_reg(start_addr+i); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl; + ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes ; } //send the data @@ -130,9 +130,9 @@ private: if (i + start_addr >= status_addr){ _max2118_read_regs.set_reg(i + start_addr, regs_vector[i]); } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl; + ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes ; } } } @@ -147,9 +147,9 @@ private: //mask and return lock detect bool locked = 5 >= _max2118_read_regs.adc and _max2118_read_regs.adc >= 2; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: locked %d" - ) % locked << std::endl; + ) % locked ; return sensor_value_t("LO", locked, "locked", "unlocked"); } @@ -175,7 +175,7 @@ UHD_STATIC_BLOCK(reg_dbsrx_dboard){ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //warn user about incorrect DBID on USRP1, requires R193 populated if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D) - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("DBSRX") << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" @@ -184,7 +184,7 @@ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //warn user about incorrect DBID on non-USRP1, requires R194 populated if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002) - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("DBSRX") << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x000D and R194\n" "found dbid == %d\n" @@ -279,9 +279,9 @@ double dbsrx::set_lo_freq(double target_freq){ m = 31; while ((ref_clock/m < 1e6 or ref_clock/m > 2.5e6) and m > 0){ m--; } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: trying ref_clock %f and m_divider %d" - ) % (ref_clock) % m << std::endl; + ) % (ref_clock) % m ; if (m >= 32) continue; @@ -289,7 +289,7 @@ double dbsrx::set_lo_freq(double target_freq){ for(auto r = 0; r <= 6; r += 1) { //compute divider from setting R = 1 << (r+1); - UHD_LOGV(often) << boost::format("DBSRX R:%d\n") % R << std::endl; + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX R:%d\n") % R ; //compute PFD compare frequency = ref_clock/R pfd_freq = ref_clock / R; @@ -315,9 +315,9 @@ double dbsrx::set_lo_freq(double target_freq){ UHD_ASSERT_THROW((pfd_freq >= dbsrx_pfd_freq_range.start()) and (pfd_freq <= dbsrx_pfd_freq_range.stop())); UHD_ASSERT_THROW((N >= 256) and (N <= 32768)); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: choose ref_clock (current: %f, new: %f) and m_divider %d" - ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % ref_clock % m << std::endl; + ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % ref_clock % m ; //if ref_clock or m divider changed, we need to update the filter settings if (ref_clock != this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) or m != _max2118_write_regs.m_divider) update_filter_settings = true; @@ -337,9 +337,9 @@ double dbsrx::set_lo_freq(double target_freq){ int scaler = actual_freq > 1125e6 ? 2 : 4; _max2118_write_regs.div2 = scaler == 4 ? max2118_write_regs_t::DIV2_DIV4 : max2118_write_regs_t::DIV2_DIV2; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: scaler %d, actual_freq %f MHz, register bit: %d" - ) % scaler % (actual_freq/1e6) % int(_max2118_write_regs.div2) << std::endl; + ) % scaler % (actual_freq/1e6) % int(_max2118_write_regs.div2) ; //compute vco frequency and select vco double vco_freq = actual_freq * scaler; @@ -366,9 +366,9 @@ double dbsrx::set_lo_freq(double target_freq){ //check vtune for lock condition read_reg(0x0, 0x0); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: initial guess for vco %d, vtune adc %d" - ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; + ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) ; //if we are out of lock for chosen vco, change vco while ((_max2118_read_regs.adc == 0) or (_max2118_read_regs.adc == 7)){ @@ -376,7 +376,7 @@ double dbsrx::set_lo_freq(double target_freq){ //vtune is too low, try lower frequency vco if (_max2118_read_regs.adc == 0){ if (_max2118_write_regs.osc_band == 0){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("DBSRX") << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 0); //just to cause a throw @@ -388,7 +388,7 @@ double dbsrx::set_lo_freq(double target_freq){ //vtune is too high, try higher frequency vco if (_max2118_read_regs.adc == 7){ if (_max2118_write_regs.osc_band == 7){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("DBSRX") << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 7); //just to cause a throw @@ -397,9 +397,9 @@ double dbsrx::set_lo_freq(double target_freq){ _max2118_write_regs.osc_band += 1; } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: trying vco %d, vtune adc %d" - ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; + ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) ; //update vco selection and check vtune send_reg(0x2, 0x2); @@ -409,9 +409,9 @@ double dbsrx::set_lo_freq(double target_freq){ boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX: final vco %d, vtune adc %d" - ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; + ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) ; //select charge pump bias current if (_max2118_read_regs.adc <= 2) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_100UA; @@ -425,7 +425,7 @@ double dbsrx::set_lo_freq(double target_freq){ _lo_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) / std::pow(2.0,(1 + _max2118_write_regs.r_divider)) * _max2118_write_regs.get_n_divider(); //debug output of calculated variables - UHD_LOGV(often) + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX tune:\n") << boost::format(" VCO=%d, CP=%d, PFD Freq=%fMHz\n") % int(_max2118_write_regs.osc_band) % _max2118_write_regs.cp_current % (pfd_freq/1e6) << boost::format(" R=%d, N=%f, scaler=%d, div2=%d\n") % R % N % scaler % int(_max2118_write_regs.div2) @@ -433,7 +433,7 @@ double dbsrx::set_lo_freq(double target_freq){ << boost::format(" Target Freq=%fMHz\n") % (target_freq/1e6) << boost::format(" Actual Freq=%fMHz\n") % (_lo_freq/1e6) << boost::format(" VCO Freq=%fMHz\n") % (vco_freq/1e6) - << std::endl; + ; if (update_filter_settings) set_bandwidth(_bandwidth); get_locked(); @@ -463,9 +463,9 @@ static int gain_to_gc2_vga_reg(double &gain){ gain = double(boost::math::iround(gain)); } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX GC2 Gain: %f dB, reg: %d" - ) % gain % reg << std::endl; + ) % gain % reg ; return reg; } @@ -487,9 +487,9 @@ static double gain_to_gc1_rfvga_dac(double &gain){ //calculate the voltage for the aux dac double dac_volts = gain*slope + min_volts; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX GC1 Gain: %f dB, dac_volts: %f V" - ) % gain % dac_volts << std::endl; + ) % gain % dac_volts ; //the actual gain setting gain = (dac_volts - min_volts)/slope; @@ -533,9 +533,9 @@ double dbsrx::set_bandwidth(double bandwidth){ //determine actual bandwidth _bandwidth = double((ref_clock/(_max2118_write_regs.m_divider))*(4+0.145*_max2118_write_regs.f_dac)); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX Filter Bandwidth: %f MHz, m: %d, f_dac: %d\n" - ) % (_bandwidth/1e6) % int(_max2118_write_regs.m_divider) % int(_max2118_write_regs.f_dac) << std::endl; + ) % (_bandwidth/1e6) % int(_max2118_write_regs.m_divider) % int(_max2118_write_regs.f_dac) ; this->send_reg(0x3, 0x4); diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp index 544671d3b..1efc6efd7 100644 --- a/host/lib/usrp/dboard/db_dbsrx2.cpp +++ b/host/lib/usrp/dboard/db_dbsrx2.cpp @@ -92,9 +92,9 @@ private: //get the register data for(int i=0; i<num_bytes; i++){ regs_vector[1+i] = _max2112_write_regs.get_reg(start_addr+i); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX2: send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl; + ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes ; } //send the data @@ -133,14 +133,14 @@ private: if (i + start_addr >= status_addr){ _max2112_read_regs.set_reg(i + start_addr, regs_vector[i]); /* - UHD_LOGV(always) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX2: set reg 0x%02x, value 0x%04x" - ) % int(i + start_addr) % int(_max2112_read_regs.get_reg(i + start_addr)) << std::endl; + ) % int(i + start_addr) % int(_max2112_read_regs.get_reg(i + start_addr)); */ } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX2: read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl; + ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes ; } } } @@ -155,9 +155,9 @@ private: //mask and return lock detect bool locked = (_max2112_read_regs.ld & _max2112_read_regs.vasa & _max2112_read_regs.vase) != 0; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("DBSRX") << boost::format( "DBSRX2 locked: %d" - ) % locked << std::endl; + ) % locked ; return sensor_value_t("LO", locked, "locked", "unlocked"); } @@ -189,7 +189,7 @@ dbsrx2::dbsrx2(ctor_args_t args) : rx_dboard_base(args){ // Register properties //////////////////////////////////////////////////////////////////// this->get_rx_subtree()->create<std::string>("name") - .set("DBSRX2"); + .set("DBSRX"); this->get_rx_subtree()->create<sensor_value_t>("sensors/lo_locked") .set_publisher(boost::bind(&dbsrx2::get_locked, this)); for(const std::string &name: dbsrx2_gain_ranges.keys()){ @@ -270,14 +270,14 @@ double dbsrx2::set_lo_freq(double target_freq){ _max2112_write_regs.d24 = scaler == 4 ? max2112_write_regs_t::D24_DIV4 : max2112_write_regs_t::D24_DIV2; //debug output of calculated variables - UHD_LOGV(often) + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX2 tune:\n") << boost::format(" R=%d, N=%f, scaler=%d, ext_div=%d\n") % R % N % scaler % ext_div << boost::format(" int=%d, frac=%d, d24=%d\n") % intdiv % fracdiv % int(_max2112_write_regs.d24) << boost::format(" Ref Freq=%fMHz\n") % (ref_freq/1e6) << boost::format(" Target Freq=%fMHz\n") % (target_freq/1e6) << boost::format(" Actual Freq=%fMHz\n") % (_lo_freq/1e6) - << std::endl; + ; //send the registers 0x0 through 0x7 //writing register 0x4 (F divider LSB) starts the VCO auto seletion so it must be written last @@ -304,10 +304,10 @@ static int gain_to_bbg_vga_reg(double &gain){ gain = double(reg); - UHD_LOGV(often) + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX2 BBG Gain:\n") << boost::format(" %f dB, bbg: %d") % gain % reg - << std::endl; + ; return reg; } @@ -329,10 +329,10 @@ static double gain_to_gc1_rfvga_dac(double &gain){ //calculate the voltage for the aux dac double dac_volts = gain*slope + min_volts; - UHD_LOGV(often) + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX2 GC1 Gain:\n") << boost::format(" %f dB, dac_volts: %f V") % gain % dac_volts - << std::endl; + ; //the actual gain setting gain = (dac_volts - min_volts)/slope; @@ -369,10 +369,10 @@ double dbsrx2::set_bandwidth(double bandwidth){ _max2112_write_regs.lp = int((bandwidth/1e6 - 4)/0.29 + 12); _bandwidth = double(4 + (_max2112_write_regs.lp - 12) * 0.29)*1e6; - UHD_LOGV(often) + UHD_LOGGER_DEBUG("DBSRX") << boost::format("DBSRX2 Bandwidth:\n") << boost::format(" %f MHz, lp: %f V") % (_bandwidth/1e6) % int(_max2112_write_regs.lp) - << std::endl; + ; this->send_reg(0x8, 0x8); diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 3982ba224..0a2729320 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -40,7 +40,7 @@ #include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/usrp/dboard_id.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> @@ -339,9 +339,9 @@ double rfx_xcvr::set_lo_freq( dboard_iface::unit_t unit, double target_freq ){ - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("RFX") << boost::format( "RFX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; //clip the input target_freq = _freq_range.clip(target_freq); @@ -396,9 +396,9 @@ double rfx_xcvr::set_lo_freq( } } done_loop: - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("RFX") << boost::format( "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d" - ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) << std::endl; + ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) ; //load the register values adf4360_regs_t regs; @@ -442,8 +442,8 @@ double rfx_xcvr::set_lo_freq( //return the actual frequency if (_div2[unit]) actual_freq /= 2; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("RFX") << boost::format( "RFX tune: actual frequency %f MHz" - ) % (actual_freq/1e6) << std::endl; + ) % (actual_freq/1e6) ; return actual_freq; } diff --git a/host/lib/usrp/dboard/db_sbx_common.cpp b/host/lib/usrp/dboard/db_sbx_common.cpp index ab7eb2566..fccad7cf7 100644 --- a/host/lib/usrp/dboard/db_sbx_common.cpp +++ b/host/lib/usrp/dboard/db_sbx_common.cpp @@ -53,9 +53,9 @@ static int rx_pga0_gain_to_iobits(double &gain){ int attn_code = int(floor(attn*2)); int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("SBX") << boost::format( "SBX RX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK << std::endl; + ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK ; //the actual gain setting gain = sbx_rx_gain_ranges["PGA0"].stop() - double(attn_code)/2; @@ -74,9 +74,9 @@ static int tx_pga0_gain_to_iobits(double &gain){ int attn_code = int(floor(attn*2)); int iobits = ((~attn_code) << TX_ATTN_SHIFT) & TX_ATTN_MASK; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("SBX") << boost::format( "SBX TX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK << std::endl; + ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK ; //the actual gain setting gain = sbx_tx_gain_ranges["PGA0"].stop() - double(attn_code)/2; @@ -240,9 +240,9 @@ sbx_xcvr::sbx_xcvr(ctor_args_t args) : xcvr_dboard_base(args){ //Initialize ATR registers after direction and pin ctrl configuration update_atr(); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("SBX") << boost::format( "SBX GPIO Direction: RX: 0x%08x, TX: 0x%08x" - ) % RXIO_MASK % TXIO_MASK << std::endl; + ) % RXIO_MASK % TXIO_MASK ; } sbx_xcvr::~sbx_xcvr(void){ diff --git a/host/lib/usrp/dboard/db_sbx_common.hpp b/host/lib/usrp/dboard/db_sbx_common.hpp index ad64e2267..0e4dc5ace 100644 --- a/host/lib/usrp/dboard/db_sbx_common.hpp +++ b/host/lib/usrp/dboard/db_sbx_common.hpp @@ -84,7 +84,7 @@ #include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> diff --git a/host/lib/usrp/dboard/db_sbx_version3.cpp b/host/lib/usrp/dboard/db_sbx_version3.cpp index 91a1b6a53..9f762a7f2 100644 --- a/host/lib/usrp/dboard/db_sbx_version3.cpp +++ b/host/lib/usrp/dboard/db_sbx_version3.cpp @@ -50,9 +50,9 @@ void sbx_xcvr::sbx_version3::write_lo_regs(dboard_iface::unit_t unit, const std: * Tuning **********************************************************************/ double sbx_xcvr::sbx_version3::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("SBX") << boost::format( "SBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; /* * If the user sets 'mode_n=integer' in the tuning args, the user wishes to diff --git a/host/lib/usrp/dboard/db_sbx_version4.cpp b/host/lib/usrp/dboard/db_sbx_version4.cpp index 6521285ea..effe0b5eb 100644 --- a/host/lib/usrp/dboard/db_sbx_version4.cpp +++ b/host/lib/usrp/dboard/db_sbx_version4.cpp @@ -52,9 +52,9 @@ void sbx_xcvr::sbx_version4::write_lo_regs(dboard_iface::unit_t unit, const std: * Tuning **********************************************************************/ double sbx_xcvr::sbx_version4::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("SBX") << boost::format( "SBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; /* * If the user sets 'mode_n=integer' in the tuning args, the user wishes to diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index 5b25883f8..41188ff77 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -31,7 +31,7 @@ #include <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> @@ -153,9 +153,9 @@ private: //get the register data for(int i=0; i<4; i++){ regs_vector[i] = _tuner_4937di5_regs.get_reg(i); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "tvrx: send reg 0x%02x, value 0x%04x" - ) % int(i) % int(regs_vector[i]) << std::endl; + ) % int(i) % int(regs_vector[i]) ; } //send the data @@ -249,7 +249,7 @@ tvrx::~tvrx(void){ static std::string get_band(double freq) { for(const std::string &band: tvrx_freq_ranges.keys()) { if(freq >= tvrx_freq_ranges[band].start() && freq <= tvrx_freq_ranges[band].stop()){ - UHD_LOGV(often) << "Band: " << band << std::endl; + UHD_LOGGER_DEBUG("TVRX") << "Band: " << band ; return band; } } @@ -291,7 +291,7 @@ static double gain_interp(double gain, const boost::array<double, 17>& db_vector //use the volts per dB slope to find the final interpolated voltage volts = volts_vector[gain_step] + (slope * (gain - db_vector[gain_step])); - UHD_LOGV(often) << "Gain interp: gain: " << gain << ", gain_step: " << int(gain_step) << ", slope: " << slope << ", volts: " << volts << std::endl; + UHD_LOGGER_DEBUG("TVRX") << "Gain interp: gain: " << gain << ", gain_step: " << int(gain_step) << ", slope: " << slope << ", volts: " << volts ; return volts; } @@ -317,9 +317,9 @@ static double rf_gain_to_voltage(double gain, double lo_freq){ dac_volts = uhd::clip<double>(dac_volts, 0.0, 3.3); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "tvrx RF AGC gain: %f dB, dac_volts: %f V" - ) % gain % dac_volts << std::endl; + ) % gain % dac_volts ; return dac_volts; } @@ -340,9 +340,9 @@ static double if_gain_to_voltage(double gain){ dac_volts = uhd::clip<double>(dac_volts, 0.0, 3.3); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "tvrx IF AGC gain: %f dB, dac_volts: %f V" - ) % gain % dac_volts << std::endl; + ) % gain % dac_volts ; return dac_volts; } @@ -396,7 +396,7 @@ double tvrx::set_freq(double freq) { //not FAR off, but we do this to be consistent if(prev_band != new_band) set_gain(_gains["RF"], "RF"); - UHD_LOGV(often) << boost::format("set_freq: target LO: %f f_ref: %f divisor: %i actual LO: %f") % target_lo_freq % f_ref % divisor % actual_lo_freq << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format("set_freq: target LO: %f f_ref: %f divisor: %i actual LO: %f") % target_lo_freq % f_ref % divisor % actual_lo_freq ; _lo_freq = actual_lo_freq; //for rx props diff --git a/host/lib/usrp/dboard/db_tvrx2.cpp b/host/lib/usrp/dboard/db_tvrx2.cpp index 3ba581b0f..6be3684d7 100644 --- a/host/lib/usrp/dboard/db_tvrx2.cpp +++ b/host/lib/usrp/dboard/db_tvrx2.cpp @@ -52,7 +52,7 @@ #include "tda18272hnm_regs.hpp" #include <uhd/utils/static.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/safe_call.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> @@ -803,9 +803,9 @@ private: //return irq status bool irq = _tda18272hnm_regs.irq_status == tda18272hnm_regs_t::IRQ_STATUS_SET; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): IRQ %d" - ) % (get_subdev_name()) % irq << std::endl; + ) % (get_subdev_name()) % irq ; return irq; } @@ -821,9 +821,9 @@ private: //return POR state bool por = _tda18272hnm_regs.por == tda18272hnm_regs_t::POR_RESET; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): POR %d" - ) % (get_subdev_name()) % int(_tda18272hnm_regs.por) << std::endl; + ) % (get_subdev_name()) % int(_tda18272hnm_regs.por) ; return por; } @@ -838,9 +838,9 @@ private: //return lock detect bool locked = _tda18272hnm_regs.lo_lock == tda18272hnm_regs_t::LO_LOCK_LOCKED; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): locked %d" - ) % (get_subdev_name()) % locked << std::endl; + ) % (get_subdev_name()) % locked ; return sensor_value_t("LO", locked, "locked", "unlocked"); } @@ -881,9 +881,9 @@ private: //read temp in degC read_reg(0x3, 0x3); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Temperature %f C" - ) % (get_subdev_name()) % (double(_tda18272hnm_regs.tm_d)) << std::endl; + ) % (get_subdev_name()) % (double(_tda18272hnm_regs.tm_d)) ; //Disable Temperature reading _tda18272hnm_regs.tm_on = tda18272hnm_regs_t::TM_ON_SENSOR_OFF; @@ -999,42 +999,42 @@ tvrx2::tvrx2(ctor_args_t args) : rx_dboard_base(args){ if (ref_clock == 64.0e6) { this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, REFCLOCK_DIV4); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Dividing Refclock by 4" - ) % (get_subdev_name()) << std::endl; + ) % (get_subdev_name()) ; _freq_scalar = (4*16.0e6)/(this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)); } else if (ref_clock == 100e6) { this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, REFCLOCK_DIV6); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Dividing Refclock by 6" - ) % (get_subdev_name()) << std::endl; + ) % (get_subdev_name()) ; _freq_scalar = (6*16.0e6)/this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX); } else if (ref_clock == 200e6) { - UHD_MSG(warning) << boost::format("ref_clock was 200e6, setting ref_clock divider for 100e6.") << std::endl; + UHD_LOGGER_WARNING("TVRX") << boost::format("ref_clock was 200e6, setting ref_clock divider for 100e6.") ; this->get_iface()->set_clock_rate(dboard_iface::UNIT_RX, 100e6); this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, REFCLOCK_DIV6); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Dividing Refclock by 6" - ) % (get_subdev_name()) << std::endl; + ) % (get_subdev_name()) ; _freq_scalar = (6*16.0e6)/this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX); } else { this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, REFCLOCK_DIV6); - UHD_MSG(warning) << boost::format("Unsupported ref_clock %0.2f, valid options 64e6, 100e6, 200e6") % ref_clock << std::endl; + UHD_LOGGER_WARNING("TVRX") << boost::format("Unsupported ref_clock %0.2f, valid options 64e6, 100e6, 200e6") % ref_clock ; _freq_scalar = 1.0; } //enable only the clocks we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Refclock %f Hz, scalar = %f" - ) % (get_subdev_name()) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % _freq_scalar << std::endl; + ) % (get_subdev_name()) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % _freq_scalar ; _tda18272hnm_regs.irq_polarity = tda18272hnm_regs_t::IRQ_POLARITY_RAISED_VCC; _tda18272hnm_regs.irq_clear = tda18272hnm_regs_t::IRQ_CLEAR_TRUE; @@ -1092,9 +1092,9 @@ bool tvrx2::set_enabled(bool enable){ } tvrx2::~tvrx2(void){ - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s): Called Destructor" - ) % (get_subdev_name()) << std::endl; + ) % (get_subdev_name()) ; UHD_SAFE_CALL(if (_enabled) set_enabled(false);) } @@ -1134,9 +1134,9 @@ void tvrx2::send_reg(uint8_t start_reg, uint8_t stop_reg){ //get the register data for(int i=0; i<num_bytes; i++){ regs_vector[1+i] = _tda18272hnm_regs.get_reg(start_addr+i); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s, 0x%02x): send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % (get_subdev_name()) % int(tvrx2_sd_name_to_i2c_addr[get_subdev_name()]) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl; + ) % (get_subdev_name()) % int(tvrx2_sd_name_to_i2c_addr[get_subdev_name()]) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes ; } //send the data @@ -1177,9 +1177,9 @@ void tvrx2::read_reg(uint8_t start_reg, uint8_t stop_reg){ if (i + start_addr >= status_addr){ _tda18272hnm_regs.set_reg(i + start_addr, regs_vector[i]); } - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s, 0x%02x): read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" - ) % (get_subdev_name()) % int(tvrx2_sd_name_to_i2c_addr[get_subdev_name()]) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl; + ) % (get_subdev_name()) % int(tvrx2_sd_name_to_i2c_addr[get_subdev_name()]) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes ; } } } @@ -1374,7 +1374,7 @@ void tvrx2::tvrx2_tda18272_tune_rf_filter(uint32_t uRF) _tda18272hnm_regs.gain_taper = gain_taper; _tda18272hnm_regs.rf_filter_band = RFBand; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "\nTVRX2 (%s): Software Calibration:\n" "\tRF Filter Bypass = %d\n" "\tRF Filter Cap = %d\n" @@ -1385,14 +1385,14 @@ void tvrx2::tvrx2_tda18272_tune_rf_filter(uint32_t uRF) % int(_tda18272hnm_regs.rf_filter_cap) % int(_tda18272hnm_regs.rf_filter_band) % int(_tda18272hnm_regs.gain_taper) - << std::endl; + ; send_reg(0x2c, 0x2f); } void tvrx2::soft_calibration(void){ - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Software Calibration: Initialize Tuner, Calibrate and Standby\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Software Calibration: Initialize Tuner, Calibrate and Standby\n") % (get_subdev_name()) ; _tda18272hnm_regs.sm = tda18272hnm_regs_t::SM_NORMAL; _tda18272hnm_regs.sm_lna = tda18272hnm_regs_t::SM_LNA_ON; @@ -1515,12 +1515,12 @@ void tvrx2::test_rf_filter_robustness(void){ } std::stringstream robustness_message; - robustness_message << boost::format("TVRX2 (%s): RF Filter Robustness Results:") % (get_subdev_name()) << std::endl; + robustness_message << boost::format("TVRX2 (%s): RF Filter Robustness Results:") % (get_subdev_name()); for(const std::string &name: uhd::sorted(_filter_ratings.keys())){ - robustness_message << boost::format("\t%s:\tMargin = %0.2f,\tRobustness = %c") % name % (_filter_margins[name]) % (_filter_ratings[name]) << std::endl; + robustness_message << boost::format("\t%s:\tMargin = %0.2f,\tRobustness = %c") % name % (_filter_margins[name]) % (_filter_ratings[name]); } - UHD_LOGV(often) << robustness_message.str(); + UHD_LOGGER_DEBUG("TVRX") << robustness_message.str(); } /*********************************************************************** @@ -1528,8 +1528,8 @@ void tvrx2::test_rf_filter_robustness(void){ **********************************************************************/ void tvrx2::transition_0(void){ //Transition 0: Initialize Tuner and place in standby - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Transition 0: Initialize Tuner, Calibrate and Standby\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Transition 0: Initialize Tuner, Calibrate and Standby\n") % (get_subdev_name()) ; //Check for Power-On Reset, if reset, initialze tuner if (get_power_reset()) { @@ -1582,8 +1582,8 @@ void tvrx2::transition_0(void){ void tvrx2::transition_1(void){ //Transition 1: Select TV Standard - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Transition 1: Select TV Standard\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Transition 1: Select TV Standard\n") % (get_subdev_name()) ; //send magic xtal_cal_dac setting send_reg(0x65, 0x65); @@ -1613,8 +1613,8 @@ void tvrx2::transition_1(void){ void tvrx2::transition_2(int rf_freq){ //Transition 2: Select RF Frequency after changing TV Standard - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Transition 2: Select RF Frequency after changing TV Standard\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Transition 2: Select RF Frequency after changing TV Standard\n") % (get_subdev_name()) ; //send magic xtal_cal_dac setting send_reg(0x65, 0x65); @@ -1651,8 +1651,8 @@ void tvrx2::transition_2(int rf_freq){ void tvrx2::transition_3(void){ //Transition 3: Standby Mode - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Transition 3: Standby Mode\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Transition 3: Standby Mode\n") % (get_subdev_name()) ; //send magic xtal_cal_dac setting send_reg(0x65, 0x65); @@ -1670,8 +1670,8 @@ void tvrx2::transition_3(void){ void tvrx2::transition_4(int rf_freq){ //Transition 4: Change RF Frequency without changing TV Standard - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Transition 4: Change RF Frequency without changing TV Standard\n") % (get_subdev_name()) << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Transition 4: Change RF Frequency without changing TV Standard\n") % (get_subdev_name()) ; //send magic xtal_cal_dac setting send_reg(0x65, 0x65); @@ -1699,8 +1699,8 @@ void tvrx2::wait_irq(void){ int timeout = 20; //irq waiting timeout in milliseconds //int irq = (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & int(tvrx2_sd_name_to_irq_io[get_subdev_name()])); bool irq = get_irq(); - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Waiting on IRQ, subdev = %d, mask = 0x%x, Status: 0x%x\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Waiting on IRQ, subdev = %d, mask = 0x%x, Status: 0x%x\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq ; while (not irq and timeout > 0) { //irq = (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & tvrx2_sd_name_to_irq_io[get_subdev_name()]); @@ -1709,13 +1709,13 @@ void tvrx2::wait_irq(void){ timeout -= 1; } - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): IRQ Raised, subdev = %d, mask = 0x%x, Status: 0x%x, Timeout: %d\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq % timeout << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): IRQ Raised, subdev = %d, mask = 0x%x, Status: 0x%x, Timeout: %d\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq % timeout ; read_reg(0xA, 0xB); //UHD_ASSERT_THROW(timeout > 0); - if(timeout <= 0) UHD_MSG(warning) << boost::format( - "\nTVRX2 (%s): Timeout waiting on IRQ\n") % (get_subdev_name()) << std::endl; + if(timeout <= 0) UHD_LOGGER_WARNING("TVRX") << boost::format( + "\nTVRX2 (%s): Timeout waiting on IRQ\n") % (get_subdev_name()) ; _tda18272hnm_regs.irq_clear = tda18272hnm_regs_t::IRQ_CLEAR_TRUE; send_reg(0xA, 0xA); @@ -1723,8 +1723,8 @@ void tvrx2::wait_irq(void){ irq = (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & tvrx2_sd_name_to_irq_io[get_subdev_name()]) > 0; - UHD_LOGV(often) << boost::format( - "\nTVRX2 (%s): Cleared IRQ, subdev = %d, mask = 0x%x, Status: 0x%x\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq << std::endl; + UHD_LOGGER_DEBUG("TVRX") << boost::format( + "\nTVRX2 (%s): Cleared IRQ, subdev = %d, mask = 0x%x, Status: 0x%x\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq ; } @@ -1748,20 +1748,20 @@ double tvrx2::set_lo_freq(double target_freq){ _lo_freq = get_scaled_rf_freq() + get_scaled_if_freq(); // - _bandwidth/2; //debug output of calculated variables - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "\nTVRX2 (%s): LO Frequency\n" "\tRequested: \t%f\n" "\tComputed: \t%f\n" "\tReadback: \t%f\n" - "\tIF Frequency: \t%f\n") % (get_subdev_name()) % target_freq % double(int(target_freq/1e3)*1e3) % get_scaled_rf_freq() % get_scaled_if_freq() << std::endl; + "\tIF Frequency: \t%f\n") % (get_subdev_name()) % target_freq % double(int(target_freq/1e3)*1e3) % get_scaled_rf_freq() % get_scaled_if_freq() ; get_locked(); test_rf_filter_robustness(); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "\nTVRX2 (%s): RSSI = %f dBm\n" - ) % (get_subdev_name()) % (get_rssi().to_real()) << std::endl; + ) % (get_subdev_name()) % (get_rssi().to_real()) ; return _lo_freq; } @@ -1783,9 +1783,9 @@ static double gain_to_if_gain_dac(double &gain){ //calculate the voltage for the aux dac double dac_volts = gain*slope + min_volts; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 IF Gain: %f dB, dac_volts: %f V" - ) % gain % dac_volts << std::endl; + ) % gain % dac_volts ; //the actual gain setting gain = (dac_volts - min_volts)/slope; @@ -1847,9 +1847,9 @@ double tvrx2::set_bandwidth(double bandwidth){ //update register send_reg(0x13, 0x13); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("TVRX") << boost::format( "TVRX2 (%s) Bandwidth (lp_fc): %f Hz, reg: %d" - ) % (get_subdev_name()) % _bandwidth % (int(_tda18272hnm_regs.lp_fc)) << std::endl; + ) % (get_subdev_name()) % _bandwidth % (int(_tda18272hnm_regs.lp_fc)) ; return _bandwidth; } diff --git a/host/lib/usrp/dboard/db_ubx.cpp b/host/lib/usrp/dboard/db_ubx.cpp index 2f3c1ebe7..b52234947 100644 --- a/host/lib/usrp/dboard/db_ubx.cpp +++ b/host/lib/usrp/dboard/db_ubx.cpp @@ -27,7 +27,7 @@ #include <uhd/usrp/dboard_manager.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/static.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/assign/list_of.hpp> @@ -749,7 +749,7 @@ private: _ubx_tx_atten_val = ((attn_code & 0x3F) << 10); set_gpio_field(TX_GAIN, attn_code); write_gpio(); - UHD_LOGV(rarely) << boost::format("UBX TX Gain: %f dB, Code: %d, IO Bits 0x%04x") % gain % attn_code % _ubx_tx_atten_val << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX TX Gain: %f dB, Code: %d, IO Bits 0x%04x") % gain % attn_code % _ubx_tx_atten_val ; _tx_gain = gain; return gain; } @@ -762,7 +762,7 @@ private: _ubx_rx_atten_val = ((attn_code & 0x3F) << 10); set_gpio_field(RX_GAIN, attn_code); write_gpio(); - UHD_LOGV(rarely) << boost::format("UBX RX Gain: %f dB, Code: %d, IO Bits 0x%04x") % gain % attn_code % _ubx_rx_atten_val << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX RX Gain: %f dB, Code: %d, IO Bits 0x%04x") % gain % attn_code % _ubx_rx_atten_val ; _rx_gain = gain; return gain; } @@ -786,18 +786,18 @@ private: property_tree::sptr subtree = this->get_tx_subtree(); device_addr_t tune_args = subtree->access<device_addr_t>("tune_args").get(); is_int_n = boost::iequals(tune_args.get("mode_n",""), "integer"); - UHD_LOGV(rarely) << boost::format("UBX TX: the requested frequency is %f MHz") % (freq/1e6) << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX TX: the requested frequency is %f MHz") % (freq/1e6) ; double target_pfd_freq = _tx_target_pfd_freq; if (is_int_n and tune_args.has_key("int_n_step")) { target_pfd_freq = tune_args.cast<double>("int_n_step", _tx_target_pfd_freq); if (target_pfd_freq > _tx_target_pfd_freq) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("UBX") << boost::format("Requested int_n_step of %f MHz too large, clipping to %f MHz") % (target_pfd_freq/1e6) % (_tx_target_pfd_freq/1e6) - << std::endl; + ; target_pfd_freq = _tx_target_pfd_freq; } } @@ -925,7 +925,7 @@ private: _txlo1_freq = freq_lo1; _txlo2_freq = freq_lo2; - UHD_LOGV(rarely) << boost::format("UBX TX: the actual frequency is %f MHz") % (_tx_freq/1e6) << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX TX: the actual frequency is %f MHz") % (_tx_freq/1e6) ; return _tx_freq; } @@ -938,7 +938,7 @@ private: double ref_freq = _iface->get_clock_rate(dboard_iface::UNIT_RX); bool is_int_n = false; - UHD_LOGV(rarely) << boost::format("UBX RX: the requested frequency is %f MHz") % (freq/1e6) << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX RX: the requested frequency is %f MHz") % (freq/1e6) ; property_tree::sptr subtree = this->get_rx_subtree(); device_addr_t tune_args = subtree->access<device_addr_t>("tune_args").get(); @@ -949,11 +949,11 @@ private: target_pfd_freq = tune_args.cast<double>("int_n_step", _rx_target_pfd_freq); if (target_pfd_freq > _rx_target_pfd_freq) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("UBX") << boost::format("Requested int_n_step of %f Mhz too large, clipping to %f MHz") % (target_pfd_freq/1e6) % (_rx_target_pfd_freq/1e6) - << std::endl; + ; target_pfd_freq = _rx_target_pfd_freq; } } @@ -1121,7 +1121,7 @@ private: _rxlo1_freq = freq_lo1; _rxlo2_freq = freq_lo2; - UHD_LOGV(rarely) << boost::format("UBX RX: the actual frequency is %f MHz") % (_rx_freq/1e6) << std::endl; + UHD_LOGGER_DEBUG("UBX") << boost::format("UBX RX: the actual frequency is %f MHz") % (_rx_freq/1e6) ; return _rx_freq; } diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp index 7e1c20a9e..1a63c9233 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -18,7 +18,7 @@ #include <uhd/types/ranges.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <boost/assign/list_of.hpp> @@ -48,7 +48,7 @@ static void warn_if_old_rfx(const dboard_id_t &dboard_id, const std::string &xx) if ( (xx == "RX" and rx_id == dboard_id) or (xx == "TX" and tx_id == dboard_id) - ) UHD_MSG(warning) << boost::format( + ) UHD_LOGGER_WARNING("unknown_db") << boost::format( "Detected %s daughterboard %s\n" "This board requires modification to use.\n" "See the daughterboard application notes.\n" diff --git a/host/lib/usrp/dboard/db_wbx_common.cpp b/host/lib/usrp/dboard/db_wbx_common.cpp index 1ad6ad45b..383daf15b 100644 --- a/host/lib/usrp/dboard/db_wbx_common.cpp +++ b/host/lib/usrp/dboard/db_wbx_common.cpp @@ -21,7 +21,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd; using namespace uhd::usrp; @@ -42,9 +42,9 @@ static int rx_pga0_gain_to_iobits(double &gain){ int attn_code = boost::math::iround(attn*2); int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX RX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK << std::endl; + ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK ; //the actual gain setting gain = wbx_rx_gain_ranges["PGA0"].stop() - double(attn_code)/2; diff --git a/host/lib/usrp/dboard/db_wbx_version2.cpp b/host/lib/usrp/dboard/db_wbx_version2.cpp index 319434c3a..134626928 100644 --- a/host/lib/usrp/dboard/db_wbx_version2.cpp +++ b/host/lib/usrp/dboard/db_wbx_version2.cpp @@ -23,7 +23,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/usrp/dboard_base.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -58,9 +58,9 @@ static double tx_pga0_gain_to_dac_volts(double &gain){ //calculate the voltage for the aux dac double dac_volts = gain*slope + min_volts; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX TX Gain: %f dB, dac_volts: %f V" - ) % gain % dac_volts << std::endl; + ) % gain % dac_volts ; //the actual gain setting gain = (dac_volts - min_volts)/slope; @@ -165,9 +165,9 @@ double wbx_base::wbx_version2::set_lo_freq(dboard_iface::unit_t unit, double tar //clip to tuning range target_freq = wbx_v2_freq_range.clip(target_freq); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; /* * If the user sets 'mode_n=integer' in the tuning args, the user wishes to diff --git a/host/lib/usrp/dboard/db_wbx_version3.cpp b/host/lib/usrp/dboard/db_wbx_version3.cpp index cb7616e26..5365a55e5 100644 --- a/host/lib/usrp/dboard/db_wbx_version3.cpp +++ b/host/lib/usrp/dboard/db_wbx_version3.cpp @@ -22,7 +22,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/usrp/dboard_base.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -63,9 +63,9 @@ static int tx_pga0_gain_to_iobits(double &gain){ (attn_code & 1 ? 0 : TX_ATTN_1) ) & TX_ATTN_MASK; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX TX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK << std::endl; + ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK ; //the actual gain setting gain = wbx_v3_tx_gain_ranges["PGA0"].stop() - double(attn_code); @@ -196,9 +196,9 @@ double wbx_base::wbx_version3::set_lo_freq(dboard_iface::unit_t unit, double tar //clip to tuning range target_freq = wbx_v3_freq_range.clip(target_freq); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; /* * If the user sets 'mode_n=integer' in the tuning args, the user wishes to diff --git a/host/lib/usrp/dboard/db_wbx_version4.cpp b/host/lib/usrp/dboard/db_wbx_version4.cpp index 8db03b961..f08504f09 100644 --- a/host/lib/usrp/dboard/db_wbx_version4.cpp +++ b/host/lib/usrp/dboard/db_wbx_version4.cpp @@ -22,7 +22,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/usrp/dboard_base.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -64,9 +64,9 @@ static int tx_pga0_gain_to_iobits(double &gain){ (attn_code & 1 ? 0 : TX_ATTN_1) ) & TX_ATTN_MASK; - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX TX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK << std::endl; + ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK ; //the actual gain setting gain = wbx_v4_tx_gain_ranges["PGA0"].stop() - double(attn_code); @@ -204,9 +204,9 @@ double wbx_base::wbx_version4::set_lo_freq(dboard_iface::unit_t unit, double tar //clip to tuning range target_freq = wbx_v4_freq_range.clip(target_freq); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("WBX") << boost::format( "WBX tune: target frequency %f MHz" - ) % (target_freq/1e6) << std::endl; + ) % (target_freq/1e6) ; /* * If the user sets 'mode_n=integer' in the tuning args, the user wishes to diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 63053e326..9d8ef63f2 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -135,9 +135,9 @@ private: void spi_reset(void); void send_reg(uint8_t addr){ uint32_t value = _max2829_regs.get_reg(addr); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("XCVR2450") << boost::format( "XCVR2450: send reg 0x%02x, value 0x%05x" - ) % int(addr) % value << std::endl; + ) % int(addr) % value ; this->get_iface()->write_spi( dboard_iface::UNIT_RX, spi_config_t::EDGE_RISE, @@ -391,20 +391,20 @@ double xcvr2450::set_lo_freq_core(double target_freq){ double N = double(intdiv) + double(fracdiv)/double(1 << 16); _lo_freq = (N*ref_freq)/(scaler*R*_ad9515div); - UHD_LOGV(often) + UHD_LOGGER_DEBUG("XCVR2450") << boost::format("XCVR2450 tune:\n") << boost::format(" R=%d, N=%f, ad9515=%d, scaler=%f\n") % R % N % _ad9515div % scaler << boost::format(" Ref Freq=%fMHz\n") % (ref_freq/1e6) << boost::format(" Target Freq=%fMHz\n") % (target_freq/1e6) << boost::format(" Actual Freq=%fMHz\n") % (_lo_freq/1e6) - << std::endl; + ; //high-high band or low-high band? if(_lo_freq > (5.35e9 + 5.47e9)/2.0){ - UHD_LOGV(often) << "XCVR2450 tune: Using high-high band" << std::endl; + UHD_LOGGER_DEBUG("XCVR2450") << "XCVR2450 tune: Using high-high band" ; _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_5_47GHZ_TO_5_875GHZ; }else{ - UHD_LOGV(often) << "XCVR2450 tune: Using low-high band" << std::endl; + UHD_LOGGER_DEBUG("XCVR2450") << "XCVR2450 tune: Using low-high band" ; _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_4_9GHZ_TO_5_35GHZ; } @@ -655,9 +655,9 @@ double xcvr2450::set_rx_bandwidth(double bandwidth){ //update register send_reg(0x7); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("XCVR2450") << boost::format( "XCVR2450 RX Bandwidth (lp_fc): %f Hz, coarse reg: %d, fine reg: %d" - ) % _rx_bandwidth % (int(_max2829_regs.rx_lpf_coarse_adj)) % (int(_max2829_regs.rx_lpf_fine_adj)) << std::endl; + ) % _rx_bandwidth % (int(_max2829_regs.rx_lpf_coarse_adj)) % (int(_max2829_regs.rx_lpf_fine_adj)) ; return 2.0*_rx_bandwidth; } @@ -675,9 +675,9 @@ double xcvr2450::set_tx_bandwidth(double bandwidth){ //update register send_reg(0x7); - UHD_LOGV(often) << boost::format( + UHD_LOGGER_DEBUG("XCVR2450") << boost::format( "XCVR2450 TX Bandwidth (lp_fc): %f Hz, coarse reg: %d" - ) % _tx_bandwidth % (int(_max2829_regs.tx_lpf_coarse_adj)) << std::endl; + ) % _tx_bandwidth % (int(_max2829_regs.tx_lpf_coarse_adj)) ; //convert lowpass back to complex bandpass bandwidth return 2.0*_tx_bandwidth; diff --git a/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp b/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp index 3b41972da..1a66e8fe7 100644 --- a/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp +++ b/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp @@ -18,6 +18,7 @@ #include "twinrx_experts.hpp" #include "twinrx_gain_tables.hpp" #include <uhd/utils/math.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/types/dict.hpp> #include <uhd/types/ranges.hpp> @@ -481,7 +482,7 @@ void twinrx_ant_gain_expert::resolve() (_ch0_preamp2 != _ch1_preamp2) or (_ch0_lb_preamp_presel != _ch1_lb_preamp_presel)) { - UHD_MSG(warning) << "incompatible gain settings for antenna sharing. temporarily using Ch0 settings for Ch1."; + UHD_LOGGER_WARNING("TWINRX") << "incompatible gain settings for antenna sharing. temporarily using Ch0 settings for Ch1."; } _ant0_input_atten = _ch0_input_atten; _ant0_preamp1 = _ch0_preamp1; @@ -499,7 +500,7 @@ void twinrx_ant_gain_expert::resolve() (_ch0_preamp2 != _ch1_preamp2) or (_ch0_lb_preamp_presel != _ch1_lb_preamp_presel)) { - UHD_MSG(warning) << "incompatible gain settings for antenna sharing. temporarily using Ch0 settings for Ch1."; + UHD_LOGGER_WARNING("TWINRX") << "incompatible gain settings for antenna sharing. temporarily using Ch0 settings for Ch1."; } _ant1_input_atten = _ch0_input_atten; _ant1_preamp1 = _ch0_preamp1; diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index 0136e1fcb..900d28e80 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -67,7 +67,7 @@ static uint8_t checksum(const byte_vector_t &bytes){ for (size_t i = 0; i < std::min(bytes.size(), size_t(DB_EEPROM_CHKSUM)); i++){ sum -= int(bytes.at(i)); } - UHD_LOGV(often) << boost::format("sum: 0x%02x") % sum << std::endl; + UHD_LOG_DEBUG("DB_EEPROM", boost::format("byte sum: 0x%02x") % sum) return uint8_t(sum); } @@ -81,11 +81,8 @@ void dboard_eeprom_t::load(i2c_iface &iface, uint8_t addr){ std::ostringstream ss; for (size_t i = 0; i < bytes.size(); i++){ - ss << boost::format( - "eeprom byte[0x%02x] = 0x%02x") % i % int(bytes.at(i) - ) << std::endl; + UHD_LOG_TRACE("DB_EEPROM",boost::format("eeprom byte[0x%02x] = 0x%02x") % i % int(bytes.at(i))) } - UHD_LOGV(often) << ss.str() << std::endl; try{ UHD_ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 698799fbc..532f5593b 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -17,7 +17,7 @@ #include "dboard_ctor_args.hpp" #include <uhd/usrp/dboard_manager.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/utils/static.hpp> @@ -96,7 +96,7 @@ static void register_dboard_key( const std::vector<std::string> &subdev_names, dboard_manager::dboard_ctor_t db_container_ctor ){ - UHD_LOGV(always) << "registering: " << name << std::endl; + UHD_LOGGER_TRACE("DBMGR") << "registering: " << name; if (get_id_to_args_map().has_key(dboard_key)){ if (dboard_key.is_xcvr()) throw uhd::key_error(str(boost::format( @@ -247,11 +247,11 @@ dboard_manager_impl::dboard_manager_impl( this->init(rx_dboard_id, tx_dboard_id, subtree, defer_db_init); } catch(const std::exception &e){ - UHD_MSG(error) << boost::format( + UHD_LOGGER_ERROR("DBMGR") << boost::format( "The daughterboard manager encountered a recoverable error in init.\n" "Loading the \"unknown\" daughterboard implementations to continue.\n" "The daughterboard cannot operate until this error is resolved.\n" - ) << e.what() << std::endl; + ) << e.what() ; //clean up the stuff added by the call above if (subtree->exists("rx_frontends")) subtree->remove("rx_frontends"); if (subtree->exists("tx_frontends")) subtree->remove("tx_frontends"); @@ -279,7 +279,7 @@ void dboard_manager_impl::init( //warn for invalid dboard id xcvr combinations if (not xcvr_dboard_key.is_xcvr() and (rx_dboard_key.is_xcvr() or tx_dboard_key.is_xcvr())){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("DBMGR") << boost::format( "Unknown transceiver board ID combination.\n" "Is your daughter-board mounted properly?\n" "RX dboard ID: %s\n" diff --git a/host/lib/usrp/device3/device3_impl.cpp b/host/lib/usrp/device3/device3_impl.cpp index 84b11ee51..f680e5a74 100644 --- a/host/lib/usrp/device3/device3_impl.cpp +++ b/host/lib/usrp/device3/device3_impl.cpp @@ -18,12 +18,12 @@ #include "device3_impl.hpp" #include "graph_impl.hpp" #include "ctrl_iface.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> #include <boost/make_shared.hpp> #include <algorithm> -#define UHD_DEVICE3_LOG() UHD_LOGV(never) +#define UHD_DEVICE3_LOG() UHD_LOGGER_TRACE("DEVICE3") using namespace uhd::usrp; @@ -119,7 +119,7 @@ void device3_impl::enumerate_rfnoc_blocks( // TODO: Clear out all the old block control classes // 3) Create new block controllers for (size_t i = 0; i < n_blocks; i++) { - UHD_DEVICE3_LOG() << "[RFNOC] ------- Block Setup -----------" << std::endl; + UHD_DEVICE3_LOG() << "[RFNOC] ------- Block Setup -----------" ; // First, make a transport for port number zero, because we always need that: ctrl_sid.set_dst_xbarport(base_port + i); ctrl_sid.set_dst_blockport(0); @@ -136,13 +136,13 @@ void device3_impl::enumerate_rfnoc_blocks( xport.send_sid, str(boost::format("CE_%02d_Port_%02X") % i % ctrl_sid.get_dst_endpoint()) ); - UHD_DEVICE3_LOG() << "OK" << std::endl; + UHD_DEVICE3_LOG() << "OK" ; uint64_t noc_id = ctrl->peek64(uhd::rfnoc::SR_READBACK_REG_ID); - UHD_DEVICE3_LOG() << str(boost::format("Port %d: Found NoC-Block with ID %016X.") % int(ctrl_sid.get_dst_endpoint()) % noc_id) << std::endl; + UHD_DEVICE3_LOG() << str(boost::format("Port %d: Found NoC-Block with ID %016X.") % int(ctrl_sid.get_dst_endpoint()) % noc_id) ; uhd::rfnoc::make_args_t make_args; uhd::rfnoc::blockdef::sptr block_def = uhd::rfnoc::blockdef::make_from_noc_id(noc_id); if (not block_def) { - UHD_DEVICE3_LOG() << "Using default block configuration." << std::endl; + UHD_DEVICE3_LOG() << "Using default block configuration." ; block_def = uhd::rfnoc::blockdef::make_from_noc_id(uhd::rfnoc::DEFAULT_NOC_ID); } UHD_ASSERT_THROW(block_def); @@ -165,7 +165,7 @@ void device3_impl::enumerate_rfnoc_blocks( xport1.send_sid, str(boost::format("CE_%02d_Port_%02d") % i % ctrl_sid.get_dst_endpoint()) ); - UHD_DEVICE3_LOG() << "OK" << std::endl; + UHD_DEVICE3_LOG() << "OK" ; make_args.ctrl_ifaces[port_number] = ctrl1; } diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp index 996399815..8a42fe148 100644 --- a/host/lib/usrp/device3/device3_io_impl.cpp +++ b/host/lib/usrp/device3/device3_io_impl.cpp @@ -23,7 +23,7 @@ #include <uhd/rfnoc/sink_block_ctrl_base.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include "../common/async_packet_handler.hpp" #include "../../transport/super_recv_packet_handler.hpp" #include "../../transport/super_send_packet_handler.hpp" @@ -32,7 +32,8 @@ #include <uhd/rfnoc/rate_node_ctrl.hpp> #include <uhd/rfnoc/radio_ctrl.hpp> -#define UHD_STREAMER_LOG() UHD_LOGV(never) +#define UHD_TX_STREAMER_LOG() UHD_LOGGER_TRACE("STREAMER") +#define UHD_RX_STREAMER_LOG() UHD_LOGGER_TRACE("STREAMER") using namespace uhd; using namespace uhd::usrp; @@ -249,7 +250,7 @@ static void handle_rx_flowctrl( // Super-verbose mode: //static size_t fc_pkt_count = 0; - //UHD_MSG(status) << "sending flow ctrl packet " << fc_pkt_count++ << ", acking " << str(boost::format("%04d\tseq_sw==0x%08x") % last_seq % seq32) << std::endl; + //UHD_LOGGER_INFO("STREAMER") << "sending flow ctrl packet " << fc_pkt_count++ << ", acking " << str(boost::format("%04d\tseq_sw==0x%08x") % last_seq % seq32) ; //load packet info vrt::if_packet_info_t packet_info; @@ -404,7 +405,7 @@ static void handle_tx_async_msgs( } catch(const std::exception &ex) { - UHD_MSG(error) << "Error parsing async message packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("STREAMER") << "Error parsing async message packet: " << ex.what() ; return; } @@ -460,7 +461,7 @@ bool device3_impl::recv_async_msg( void device3_impl::update_rx_streamers(double /* rate */) { for(const std::string &block_id: _rx_streamers.keys()) { - UHD_STREAMER_LOG() << "[Device3] updating RX streamer to " << block_id << std::endl; + UHD_RX_STREAMER_LOG() << "updating RX streamer to " << block_id; boost::shared_ptr<sph::recv_packet_streamer> my_streamer = boost::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[block_id].lock()); if (my_streamer) { @@ -477,7 +478,7 @@ void device3_impl::update_rx_streamers(double /* rate */) if (scaling == rfnoc::scalar_node_ctrl::SCALE_UNDEFINED) { scaling = 1/32767.; } - UHD_STREAMER_LOG() << " New tick_rate == " << tick_rate << " New samp_rate == " << samp_rate << " New scaling == " << scaling << std::endl; + UHD_RX_STREAMER_LOG() << " New tick_rate == " << tick_rate << " New samp_rate == " << samp_rate << " New scaling == " << scaling ; my_streamer->set_tick_rate(tick_rate); my_streamer->set_samp_rate(samp_rate); @@ -506,7 +507,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) for (size_t stream_i = 0; stream_i < chan_list.size(); stream_i++) { // Get block ID and mb index uhd::rfnoc::block_id_t block_id = chan_list[stream_i]; - UHD_STREAMER_LOG() << "[RX Streamer] chan " << stream_i << " connecting to " << block_id << std::endl; + UHD_RX_STREAMER_LOG() << "chan " << stream_i << " connecting to " << block_id ; // Update args so args.args is always valid for this particular channel: args.args = chan_args[stream_i]; size_t mb_index = block_id.get_device_no(); @@ -534,19 +535,19 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) //allocate sid and create transport uhd::sid_t stream_address = blk_ctrl->get_address(block_port); - UHD_STREAMER_LOG() << "[RX Streamer] creating rx stream " << rx_hints.to_string() << std::endl; + UHD_RX_STREAMER_LOG() << "creating rx stream " << rx_hints.to_string() ; both_xports_t xport = make_transport(stream_address, RX_DATA, rx_hints); - UHD_STREAMER_LOG() << std::hex << "[RX Streamer] data_sid = " << xport.send_sid << std::dec << " actual recv_buff_size = " << xport.recv_buff_size << std::endl; + UHD_RX_STREAMER_LOG() << std::hex << "data_sid = " << xport.send_sid << std::dec << " actual recv_buff_size = " << xport.recv_buff_size ; // Configure the block blk_ctrl->set_destination(xport.send_sid.get_src(), block_port); blk_ctrl->sr_write(uhd::rfnoc::SR_RESP_OUT_DST_SID, xport.send_sid.get_src(), block_port); - UHD_STREAMER_LOG() << "[RX Streamer] resp_out_dst_sid == " << xport.send_sid.get_src() << std::endl; + UHD_RX_STREAMER_LOG() << "resp_out_dst_sid == " << xport.send_sid.get_src() ; // Find all upstream radio nodes and set their response in SID to the host std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > upstream_radio_nodes = blk_ctrl->find_upstream_node<uhd::rfnoc::radio_ctrl>(); - UHD_STREAMER_LOG() << "[RX Streamer] Number of upstream radio nodes: " << upstream_radio_nodes.size() << std::endl; + UHD_RX_STREAMER_LOG() << "Number of upstream radio nodes: " << upstream_radio_nodes.size(); for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node: upstream_radio_nodes) { node->sr_write(uhd::rfnoc::SR_RESP_OUT_DST_SID, xport.send_sid.get_src(), block_port); } @@ -556,7 +557,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) const size_t bpp = xport.recv->get_recv_frame_size() - stream_options.rx_max_len_hdr; // bytes per packet const size_t bpi = convert::get_bytes_per_item(args.otw_format); // bytes per item const size_t spp = std::min(args.args.cast<size_t>("spp", bpp/bpi), bpp/bpi); // samples per packet - UHD_STREAMER_LOG() << "[RX Streamer] spp == " << spp << std::endl; + UHD_RX_STREAMER_LOG() << "spp == " << spp ; //make the new streamer given the samples per packet if (not my_streamer) @@ -585,7 +586,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) const size_t pkt_size = spp * bpi + stream_options.rx_max_len_hdr; const size_t fc_window = get_rx_flow_control_window(pkt_size, xport.recv_buff_size, rx_hints); const size_t fc_handle_window = std::max<size_t>(1, fc_window / stream_options.rx_fc_request_freq); - UHD_STREAMER_LOG()<< "[RX Streamer] Flow Control Window (minus one) = " << fc_window-1 << ", Flow Control Handler Window = " << fc_handle_window << std::endl; + UHD_RX_STREAMER_LOG()<< "Flow Control Window (minus one) = " << fc_window-1 << ", Flow Control Handler Window = " << fc_handle_window ; blk_ctrl->configure_flow_control_out( fc_window-1, // Leave one space for overrun packets TODO make this obsolete block_port @@ -662,7 +663,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) void device3_impl::update_tx_streamers(double /* rate */) { for(const std::string &block_id: _tx_streamers.keys()) { - UHD_STREAMER_LOG() << "[Device3] updating TX streamer: " << block_id << std::endl; + UHD_TX_STREAMER_LOG() << "updating TX streamer: " << block_id; boost::shared_ptr<sph::send_packet_streamer> my_streamer = boost::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[block_id].lock()); if (my_streamer) { @@ -678,7 +679,7 @@ void device3_impl::update_tx_streamers(double /* rate */) if (scaling == rfnoc::scalar_node_ctrl::SCALE_UNDEFINED) { scaling = 32767.; } - UHD_STREAMER_LOG() << " New tick_rate == " << tick_rate << " New samp_rate == " << samp_rate << " New scaling == " << scaling << std::endl; + UHD_TX_STREAMER_LOG() << "New tick_rate == " << tick_rate << " New samp_rate == " << samp_rate << " New scaling == " << scaling ; my_streamer->set_tick_rate(tick_rate); my_streamer->set_samp_rate(samp_rate); my_streamer->set_scale_factor(scaling); @@ -737,16 +738,16 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) //allocate sid and create transport uhd::sid_t stream_address = blk_ctrl->get_address(block_port); - UHD_STREAMER_LOG() << "[TX Streamer] creating tx stream " << tx_hints.to_string() << std::endl; + UHD_TX_STREAMER_LOG() << "creating tx stream " << tx_hints.to_string() ; both_xports_t xport = make_transport(stream_address, TX_DATA, tx_hints); - UHD_STREAMER_LOG() << std::hex << "[TX Streamer] data_sid = " << xport.send_sid << std::dec << std::endl; + UHD_TX_STREAMER_LOG() << std::hex << "data_sid = " << xport.send_sid << std::dec ; // To calculate the max number of samples per packet, we assume the maximum header length // to avoid fragmentation should the entire header be used. const size_t bpp = tx_hints.cast<size_t>("bpp", xport.send->get_send_frame_size()) - stream_options.tx_max_len_hdr; const size_t bpi = convert::get_bytes_per_item(args.otw_format); // bytes per item const size_t spp = std::min(args.args.cast<size_t>("spp", bpp/bpi), bpp/bpi); // samples per packet - UHD_STREAMER_LOG() << "[TX Streamer] spp == " << spp << std::endl; + UHD_TX_STREAMER_LOG() << "spp == " << spp ; //make the new streamer given the samples per packet if (not my_streamer) @@ -780,7 +781,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) tx_hints // This can override the value reported by the block! ); const size_t fc_handle_window = std::max<size_t>(1, fc_window / stream_options.tx_fc_response_freq); - UHD_STREAMER_LOG() << "[TX Streamer] Flow Control Window = " << fc_window << ", Flow Control Handler Window = " << fc_handle_window << std::endl; + UHD_TX_STREAMER_LOG() << "Flow Control Window = " << fc_window << ", Flow Control Handler Window = " << fc_handle_window ; blk_ctrl->configure_flow_control_in( stream_options.tx_fc_response_cycles, fc_handle_window, /*pkts*/ @@ -810,7 +811,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) blk_ctrl->sr_write(uhd::rfnoc::SR_CLEAR_RX_FC, 0xc1ea12, block_port); blk_ctrl->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.recv_sid.get_dst(), block_port); - UHD_STREAMER_LOG() << "[TX Streamer] resp_in_dst_sid == " << boost::format("0x%04X") % xport.recv_sid.get_dst() << std::endl; + UHD_TX_STREAMER_LOG() << "resp_in_dst_sid == " << boost::format("0x%04X") % xport.recv_sid.get_dst() ; // FIXME: Once there is a better way to map the radio block and port // to the channel or another way to receive asynchronous messages that @@ -821,7 +822,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) uhd::rfnoc::block_id_t radio_id(args.args["radio_id"]); size_t radio_port = args.args.cast<size_t>("radio_port", 0); std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > downstream_radio_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::radio_ctrl>(); - UHD_STREAMER_LOG() << "[TX Streamer] Number of downstream radio nodes: " << downstream_radio_nodes.size() << std::endl; + UHD_TX_STREAMER_LOG() << "Number of downstream radio nodes: " << downstream_radio_nodes.size(); for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node: downstream_radio_nodes) { if (node->get_block_id() == radio_id) { node->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.send_sid.get_src(), radio_port); @@ -835,7 +836,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) // soon as possible. // Find all downstream radio nodes and set their response SID to the host std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > downstream_radio_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::radio_ctrl>(); - UHD_STREAMER_LOG() << "[TX Streamer] Number of downstream radio nodes: " << downstream_radio_nodes.size() << std::endl; + UHD_TX_STREAMER_LOG() << "Number of downstream radio nodes: " << downstream_radio_nodes.size(); for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node: downstream_radio_nodes) { node->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.send_sid.get_src(), block_port); } diff --git a/host/lib/usrp/e100/clock_ctrl.cpp b/host/lib/usrp/e100/clock_ctrl.cpp index b49b30a6a..567a4b8fb 100644 --- a/host/lib/usrp/e100/clock_ctrl.cpp +++ b/host/lib/usrp/e100/clock_ctrl.cpp @@ -17,7 +17,7 @@ #include "clock_ctrl.hpp" #include "ad9522_regs.hpp" -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/assert_has.hpp> #include <stdint.h> @@ -136,11 +136,11 @@ static clock_settings_type get_clock_settings(double rate){ cs.chan_divider /= cs.vco_divider; } - UHD_LOGV(always) - << "gcd " << gcd << std::endl - << "X " << X << std::endl - << "Y " << Y << std::endl - << cs.to_pp_string() << std::endl + UHD_LOGGER_DEBUG("E100") + << "gcd: " << gcd + << " X: " << X + << " Y: " << Y + << cs.to_pp_string() ; //filter limits on the counters @@ -154,7 +154,7 @@ static clock_settings_type get_clock_settings(double rate){ if (cs.get_vco_rate() < 1400e6 + vco_bound_pad) continue; if (cs.get_out_rate() != rate) continue; - UHD_MSG(status) << "USRP-E100 clock control: " << i << std::endl << cs.to_pp_string() << std::endl; + UHD_LOGGER_INFO("E100") << "USRP-E100 clock control: " << i << cs.to_pp_string() ; return cs; } } @@ -194,7 +194,7 @@ public: this->use_internal_ref(); //initialize the FPGA clock rate - UHD_MSG(status) << boost::format("Initializing FPGA clock to %fMHz...") % (master_clock_rate/1e6) << std::endl; + UHD_LOGGER_INFO("E100") << boost::format("Initializing FPGA clock to %fMHz...") % (master_clock_rate/1e6) ; this->set_fpga_clock_rate(master_clock_rate); this->enable_test_clock(ENABLE_THE_TEST_OUT); @@ -459,7 +459,7 @@ private: void send_reg(uint16_t addr){ uint32_t reg = _ad9522_regs.get_write_reg(addr); - UHD_LOGV(often) << "clock control write reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("E100") << "clock control write reg: " << std::hex << reg ; _iface->write_spi( UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, @@ -486,7 +486,7 @@ private: _ad9522_regs.set_reg(addr, reg); if (_ad9522_regs.vco_calibration_finished) goto wait_for_ld; } - UHD_MSG(error) << "USRP-E100 clock control: VCO calibration timeout" << std::endl; + UHD_LOGGER_ERROR("E100") << "USRP-E100 clock control: VCO calibration timeout" ; wait_for_ld: //wait for digital lock detect: for (size_t ms10 = 0; ms10 < 100; ms10++){ @@ -498,7 +498,7 @@ private: _ad9522_regs.set_reg(addr, reg); if (_ad9522_regs.digital_lock_detect) return; } - UHD_MSG(error) << "USRP-E100 clock control: lock detection timeout" << std::endl; + UHD_LOGGER_ERROR("E100") << "USRP-E100 clock control: lock detection timeout" ; } void soft_sync(void){ diff --git a/host/lib/usrp/e100/codec_ctrl.cpp b/host/lib/usrp/e100/codec_ctrl.cpp index 7dce01e46..ee26c1990 100644 --- a/host/lib/usrp/e100/codec_ctrl.cpp +++ b/host/lib/usrp/e100/codec_ctrl.cpp @@ -260,7 +260,7 @@ void e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){ **********************************************************************/ void e100_codec_ctrl_impl::send_reg(uint8_t addr){ uint32_t reg = _ad9862_regs.get_write_reg(addr); - UHD_LOGV(often) << "codec control write reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("E100") << "codec control write reg: " << std::hex << reg ; _iface->write_spi( UE_SPI_SS_AD9862, spi_config_t::EDGE_RISE, @@ -270,13 +270,13 @@ void e100_codec_ctrl_impl::send_reg(uint8_t addr){ void e100_codec_ctrl_impl::recv_reg(uint8_t addr){ uint32_t reg = _ad9862_regs.get_read_reg(addr); - UHD_LOGV(often) << "codec control read reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("E100") << "codec control read reg: " << std::hex << reg ; uint32_t ret = _iface->read_spi( UE_SPI_SS_AD9862, spi_config_t::EDGE_RISE, reg, 16 ); - UHD_LOGV(often) << "codec control read ret: " << std::hex << ret << std::endl; + UHD_LOGGER_DEBUG("E100") << "codec control read ret: " << std::hex << ret ; _ad9862_regs.set_reg(addr, uint16_t(ret)); } diff --git a/host/lib/usrp/e100/e100_ctrl.cpp b/host/lib/usrp/e100/e100_ctrl.cpp index 777d1b5d5..41525300c 100644 --- a/host/lib/usrp/e100/e100_ctrl.cpp +++ b/host/lib/usrp/e100/e100_ctrl.cpp @@ -19,7 +19,7 @@ #include "e100_regs.hpp" #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <sys/ioctl.h> //ioctl #include <fcntl.h> //open, close #include <linux/usrp_e.h> //ioctl structures and constants @@ -218,7 +218,7 @@ public: void write_uart(const std::string &buf){ const ssize_t ret = ::write(_node_fd, buf.c_str(), buf.size()); - if (size_t(ret) != buf.size()) UHD_LOG << ret; + if (size_t(ret) != buf.size()) UHD_LOGGER_DEBUG("E100")<< ret; } std::string read_uart(double timeout){ @@ -329,7 +329,7 @@ public: * Structors ******************************************************************/ e100_ctrl_impl(const std::string &node){ - UHD_MSG(status) << "Opening device node " << node << "..." << std::endl; + UHD_LOGGER_INFO("E100") << "Opening device node " << node << "..." ; //open the device node and check file descriptor if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ @@ -349,7 +349,7 @@ public: edge_file << "rising" << std::endl << std::flush; edge_file.close(); _irq_fd = ::open("/sys/class/gpio/gpio147/value", O_RDONLY); - if (_irq_fd < 0) UHD_MSG(error) << "Unable to open GPIO for IRQ\n"; + if (_irq_fd < 0) UHD_LOGGER_ERROR("E100") << "Unable to open GPIO for IRQ\n"; } ~e100_ctrl_impl(void){ diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 41ba24d8f..ddb21fc35 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -18,7 +18,7 @@ #include "apply_corrections.hpp" #include "e100_impl.hpp" #include "e100_regs.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/paths.hpp> @@ -140,7 +140,7 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ e100_fpga_image = find_image_path(device_addr.get("fpga", default_fpga_file_name)); } catch(...){ - UHD_MSG(error) << boost::format("Could not find FPGA image. %s\n") % print_utility_error("uhd_images_downloader.py"); + UHD_LOGGER_ERROR("E100") << boost::format("Could not find FPGA image. %s") % print_utility_error("uhd_images_downloader.py"); throw; } e100_load_fpga(e100_fpga_image); @@ -151,10 +151,10 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ bool dboard_clocks_diff = true; if (mb_eeprom.get("revision", "0") == "3") dboard_clocks_diff = false; else if (mb_eeprom.get("revision", "0") == "4") dboard_clocks_diff = true; - else UHD_MSG(warning) + else UHD_LOGGER_WARNING("E100") << "Unknown E1XX revision number!\n" << "defaulting to differential dboard clocks to be safe.\n" - << std::endl; + ; const double master_clock_rate = device_addr.cast<double>("master_clock_rate", E100_DEFAULT_CLOCK_RATE); _aux_spi_iface = e100_ctrl::make_aux_spi_iface(); _clock_ctrl = e100_clock_ctrl::make(_aux_spi_iface, master_clock_rate, dboard_clocks_diff); @@ -179,7 +179,7 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //Perform wishbone readback tests, these tests also write the hash bool test_fail = false; - UHD_MSG(status) << "Performing control readback test... " << std::flush; + UHD_LOGGER_INFO("E100") << "Performing control readback test... "; size_t hash = time(NULL); for (size_t i = 0; i < 100; i++){ boost::hash_combine(hash, i); @@ -187,12 +187,12 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ test_fail = _fifo_ctrl->peek32(REG_RB_CONFIG0) != uint32_t(hash); if (test_fail) break; //exit loop on any failure } - UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl; + UHD_LOGGER_INFO("E100") << "Control readback test " << ((test_fail)? "failed" : "passed"); - if (test_fail) UHD_MSG(error) << boost::format( - "The FPGA is either clocked improperly\n" - "or the FPGA build is not compatible.\n" - "Subsequent errors may follow...\n" + if (test_fail) UHD_LOGGER_ERROR("E100") << boost::format( + "The FPGA is either clocked improperly " + "or the FPGA build is not compatible. " + "Subsequent errors may follow..." ); //check that the compatibility is correct @@ -260,12 +260,12 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ static const fs::path GPSDO_VOLATILE_PATH("/media/ram/e100_internal_gpsdo.cache"); if (not fs::exists(GPSDO_VOLATILE_PATH)) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("E100") << "Detecting internal GPSDO.... "; try{ _gps = gps_ctrl::make(e100_ctrl::make_gps_uart_iface(E100_UART_DEV_NODE)); } catch(std::exception &e){ - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("E100") << "An error occurred making GPSDO control: " << e.what(); } if (_gps and _gps->gps_detected()) { @@ -475,10 +475,10 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //GPS installed: use external ref, time, and init time spec if (_gps and _gps->gps_detected()){ _time64->enable_gpsdo(); - UHD_MSG(status) << "Setting references to the internal GPSDO" << std::endl; + UHD_LOGGER_INFO("E100") << "Setting references to the internal GPSDO"; _tree->access<std::string>(mb_path / "time_source/value").set("gpsdo"); _tree->access<std::string>(mb_path / "clock_source/value").set("gpsdo"); - UHD_MSG(status) << "Initializing time to the internal GPSDO" << std::endl; + UHD_LOGGER_INFO("E100") << "Initializing time to the internal GPSDO"; _time64->set_time_next_pps(time_spec_t(time_t(_gps->get_sensor("gps_time").to_int()+1))); } diff --git a/host/lib/usrp/e100/e100_mmap_zero_copy.cpp b/host/lib/usrp/e100/e100_mmap_zero_copy.cpp index 57e4e32d9..4e698eae9 100644 --- a/host/lib/usrp/e100/e100_mmap_zero_copy.cpp +++ b/host/lib/usrp/e100/e100_mmap_zero_copy.cpp @@ -42,14 +42,14 @@ public: _mem(mem), _info(info) { /* NOP */ } void release(void){ - if (fp_verbose) UHD_LOGV(always) << "recv buff: release" << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << "recv buff: release" ; _info->flags = RB_KERNEL; //release the frame } UHD_INLINE bool ready(void){return _info->flags & RB_USER;} UHD_INLINE sptr get_new(void){ - if (fp_verbose) UHD_LOGV(always) << " make_recv_buff: " << _info->len << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << " make_recv_buff: " << _info->len ; _info->flags = RB_USER_PROCESS; //claim the frame return make(this, _mem, _info->len); } @@ -69,18 +69,18 @@ public: _mem(mem), _info(info), _len(len), _fd(fd) { /* NOP */ } void release(void){ - if (fp_verbose) UHD_LOGV(always) << "send buff: commit " << size() << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << "send buff: commit " << size() ; _info->len = _len;//size(); _info->flags = RB_USER; //release the frame if (::write(_fd, NULL, 0) < 0){ //notifies the kernel - UHD_LOGV(rarely) << UHD_THROW_SITE_INFO("write error") << std::endl; + UHD_LOGGER_ERROR("E100") << UHD_THROW_SITE_INFO("write error") ; } } UHD_INLINE bool ready(void){return _info->flags & RB_KERNEL;} UHD_INLINE sptr get_new(void){ - if (fp_verbose) UHD_LOGV(always) << " make_send_buff: " << _len << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << " make_send_buff: " << _len ; _info->flags = RB_USER_PROCESS; //claim the frame return make(this, _mem, _len); } @@ -112,13 +112,13 @@ public: //print sizes summary UHD_LOG - << "page_size: " << page_size << std::endl - << "frame_size: " << _frame_size << std::endl - << "num_pages_rx_flags: " << _rb_size.num_pages_rx_flags << std::endl - << "num_rx_frames: " << _rb_size.num_rx_frames << std::endl - << "num_pages_tx_flags: " << _rb_size.num_pages_tx_flags << std::endl - << "num_tx_frames: " << _rb_size.num_tx_frames << std::endl - << "map_size: " << _map_size << std::endl + << "page_size: " << page_size + << "frame_size: " << _frame_size + << "num_pages_rx_flags: " << _rb_size.num_pages_rx_flags + << "num_rx_frames: " << _rb_size.num_rx_frames + << "num_pages_tx_flags: " << _rb_size.num_pages_tx_flags + << "num_tx_frames: " << _rb_size.num_tx_frames + << "map_size: " << _map_size ; //call mmap to get the memory @@ -135,10 +135,10 @@ public: //print offset summary UHD_LOG - << "recv_info_off: " << recv_info_off << std::endl - << "recv_buff_off: " << recv_buff_off << std::endl - << "send_info_off: " << send_info_off << std::endl - << "send_buff_off: " << send_buff_off << std::endl + << "recv_info_off: " << recv_info_off + << "recv_buff_off: " << recv_buff_off + << "send_info_off: " << send_info_off + << "send_buff_off: " << send_buff_off ; //pointers to sections in the mapped memory @@ -170,12 +170,12 @@ public: } ~e100_mmap_zero_copy_impl(void){ - UHD_LOG << "cleanup: munmap" << std::endl; + UHD_LOGGER_DEBUG("E100")<< "cleanup: munmap" ; ::munmap(_mapped_mem, _map_size); } managed_recv_buffer::sptr get_recv_buff(double timeout){ - if (fp_verbose) UHD_LOGV(always) << "get_recv_buff: " << _recv_index << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << "get_recv_buff: " << _recv_index ; e100_mmap_zero_copy_mrb &mrb = *_mrb_pool[_recv_index]; //poll/wait for a ready frame @@ -185,7 +185,7 @@ public: pfd.fd = _fd; pfd.events = POLLIN; ssize_t poll_ret = ::poll(&pfd, 1, size_t(timeout*1e3/poll_breakout)); - if (fp_verbose) UHD_LOGV(always) << " POLLIN: " << poll_ret << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << " POLLIN: " << poll_ret ; if (poll_ret > 0) goto found_user_frame; //good poll, continue on } return managed_recv_buffer::sptr(); //timed-out for real @@ -207,7 +207,7 @@ public: } managed_send_buffer::sptr get_send_buff(double timeout){ - if (fp_verbose) UHD_LOGV(always) << "get_send_buff: " << _send_index << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << "get_send_buff: " << _send_index ; e100_mmap_zero_copy_msb &msb = *_msb_pool[_send_index]; //poll/wait for a ready frame @@ -216,7 +216,7 @@ public: pfd.fd = _fd; pfd.events = POLLOUT; ssize_t poll_ret = ::poll(&pfd, 1, size_t(timeout*1e3)); - if (fp_verbose) UHD_LOGV(always) << " POLLOUT: " << poll_ret << std::endl; + if (fp_verbose) UHD_LOGGER_DEBUG("E100") << " POLLOUT: " << poll_ret ; if (poll_ret <= 0) return managed_send_buffer::sptr(); } diff --git a/host/lib/usrp/e100/fpga_downloader.cpp b/host/lib/usrp/e100/fpga_downloader.cpp index 9abde32f7..bfb207f39 100644 --- a/host/lib/usrp/e100/fpga_downloader.cpp +++ b/host/lib/usrp/e100/fpga_downloader.cpp @@ -23,18 +23,13 @@ #include <uhd/device.hpp> #include <uhd/image_loader.hpp> #include <uhd/types/device_addr.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/static.hpp> #include "e100_impl.hpp" #else //special case when this file is externally included #include <stdexcept> #include <iostream> -#define UHD_MSG(type) std::cout -namespace uhd{ - typedef std::runtime_error os_error; - typedef std::runtime_error io_error; -} #endif #include <sstream> @@ -246,7 +241,7 @@ static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &d throw uhd::os_error("INIT_B went high, error occured."); if (!done.get_value()) - UHD_MSG(status) << "Configuration complete." << std::endl; + UHD_LOGGER_INFO("E100") << "Configuration complete."; } while (bitstream.gcount() == BUF_SIZE); } @@ -260,20 +255,20 @@ void e100_load_fpga(const std::string &bin_file){ gpio gpio_init_b(INIT_B, IN); gpio gpio_done (DONE, IN); - UHD_MSG(status) << "Loading FPGA image: " << bin_file << "... " << std::flush; + UHD_LOGGER_INFO("E100") << "Loading FPGA image: " << bin_file << "... "; // if(std::system("/sbin/rmmod usrp_e") != 0){ -// UHD_MSG(warning) << "USRP-E100 FPGA downloader: could not unload usrp_e module" << std::endl; +// UHD_LOGGER_WARNING("E100") << "USRP-E100 FPGA downloader: could not unload usrp_e module" ; // } prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); - UHD_MSG(status) << "done = " << gpio_done.get_value() << std::endl; + UHD_LOGGER_INFO("E100") << "done = " << gpio_done.get_value(); send_file_to_fpga(bin_file, gpio_init_b, gpio_done); // if(std::system("/sbin/modprobe usrp_e") != 0){ -// UHD_MSG(warning) << "USRP-E100 FPGA downloader: could not load usrp_e module" << std::endl; +// UHD_LOGGER_WARNING("E100") << "USRP-E100 FPGA downloader: could not load usrp_e module" ; // } } diff --git a/host/lib/usrp/e100/io_impl.cpp b/host/lib/usrp/e100/io_impl.cpp index aedf79d5f..acd14f17b 100644 --- a/host/lib/usrp/e100/io_impl.cpp +++ b/host/lib/usrp/e100/io_impl.cpp @@ -20,7 +20,7 @@ #include "../../transport/super_recv_packet_handler.hpp" #include "../../transport/super_send_packet_handler.hpp" #include "e100_impl.hpp" -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <boost/bind.hpp> diff --git a/host/lib/usrp/e300/e300_common.cpp b/host/lib/usrp/e300/e300_common.cpp index 20cd4109f..61da3a2a2 100644 --- a/host/lib/usrp/e300/e300_common.cpp +++ b/host/lib/usrp/e300/e300_common.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // #include <uhd/image_loader.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/static.hpp> @@ -40,7 +40,7 @@ void load_fpga_image(const std::string &path) if (not boost::filesystem::exists("/dev/xdevcfg")) ::system("mknod /dev/xdevcfg c 259 0"); - UHD_MSG(status) << "Loading FPGA image: " << path << "..." << std::flush; + UHD_LOGGER_INFO("E300") << "Loading FPGA image: " << path << "..."; std::ifstream fpga_file(path.c_str(), std::ios_base::binary); UHD_ASSERT_THROW(fpga_file.good()); @@ -58,7 +58,7 @@ void load_fpga_image(const std::string &path) fpga_file.close(); std::fclose(wfile); - UHD_MSG(status) << " done" << std::endl; + UHD_LOGGER_INFO("E300") << "FPGA image loaded"; } static bool e300_image_loader(const image_loader::image_loader_args_t &image_loader_args) { diff --git a/host/lib/usrp/e300/e300_fifo_config.cpp b/host/lib/usrp/e300/e300_fifo_config.cpp index 4138bb581..b51896d82 100644 --- a/host/lib/usrp/e300/e300_fifo_config.cpp +++ b/host/lib/usrp/e300/e300_fifo_config.cpp @@ -81,7 +81,7 @@ static UHD_INLINE size_t ZF_STREAM_OFF(const size_t which) #include <fcntl.h> //open, close #include <poll.h> //poll #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <boost/format.hpp> #include <boost/thread/thread.hpp> //sleep #include <uhd/types/time_spec.hpp> //timeout @@ -202,9 +202,9 @@ public: _index(0), _waiter(waiter) { - //UHD_MSG(status) << boost::format("phys 0x%x") % addrs.phys << std::endl; - //UHD_MSG(status) << boost::format("data 0x%x") % addrs.data << std::endl; - //UHD_MSG(status) << boost::format("ctrl 0x%x") % addrs.ctrl << std::endl; + //UHD_LOGGER_INFO("E300") << boost::format("phys 0x%x") % addrs.phys ; + //UHD_LOGGER_INFO("E300") << boost::format("data 0x%x") % addrs.data ; + //UHD_LOGGER_INFO("E300") << boost::format("ctrl 0x%x") % addrs.ctrl ; const uint32_t sig = zf_peek32(_addrs.ctrl + ARBITER_RD_SIG); UHD_ASSERT_THROW((sig >> 16) == 0xACE0); @@ -341,7 +341,7 @@ public: virtual ~e300_fifo_interface_impl(void) { delete _waiter; - UHD_LOG << "cleanup: munmap" << std::endl; + UHD_LOGGER_DEBUG("E300")<< "cleanup: munmap" ; ::munmap(_buff, _config.ctrl_length + _config.buff_length); ::close(_fd); } diff --git a/host/lib/usrp/e300/e300_impl.cpp b/host/lib/usrp/e300/e300_impl.cpp index 64422a82b..ea326878e 100644 --- a/host/lib/usrp/e300/e300_impl.cpp +++ b/host/lib/usrp/e300/e300_impl.cpp @@ -25,7 +25,7 @@ #include "e300_common.hpp" #include "e300_remote_codec_ctrl.hpp" -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/paths.hpp> @@ -75,11 +75,11 @@ static std::vector<std::string> discover_ip_addrs( try { udp_bcast_xport = uhd::transport::udp_simple::make_broadcast(addr_hint, port); } catch(const std::exception &e) { - UHD_MSG(error) << boost::format("Cannot open UDP transport on %s for discovery\n%s") - % addr_hint % e.what() << std::endl; + UHD_LOGGER_ERROR("E300") << boost::format("Cannot open UDP transport on %s for discovery%s") + % addr_hint % e.what() ; return addrs; } catch(...) { - UHD_MSG(error) << "E300 Network discovery unknown error" << std::endl; + UHD_LOGGER_ERROR("E300") << "E300 Network discovery unknown error"; return addrs; } @@ -95,10 +95,10 @@ static std::vector<std::string> discover_ip_addrs( try { udp_bcast_xport->send(boost::asio::buffer(&req, sizeof(req))); } catch (const std::exception &ex) { - UHD_MSG(error) << "E300 Network discovery error " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "E300 Network discovery error " << ex.what(); return addrs; } catch(...) { - UHD_MSG(error) << "E300 Network discovery unknown error" << std::endl; + UHD_LOGGER_ERROR("E300") << "E300 Network discovery unknown error"; return addrs; } @@ -260,7 +260,7 @@ device_addrs_t e300_find(const device_addr_t &multi_dev_hint) **********************************************************************/ static device::sptr e300_make(const device_addr_t &device_addr) { - UHD_LOG << "e300_make with args " << device_addr.to_pp_string() << std::endl; + UHD_LOGGER_DEBUG("E300")<< "e300_make with args " << device_addr.to_pp_string() ; if(device_addr.has_key("server")) throw uhd::runtime_error( str(boost::format("Please run the server executable \"%s\"") @@ -295,8 +295,8 @@ void get_e3x0_fpga_images(const uhd::device_addr_t &device_addr, break; case e300_eeprom_manager::UNKNOWN: default: - UHD_MSG(warning) << "Unknown motherboard type, loading e300 image." - << std::endl; + UHD_LOGGER_WARNING("E300") << "Unknown motherboard type, loading e300 image." + ; fpga_image = device_addr.cast<std::string>("fpga", find_image_path(E300_FPGA_FILE_NAME)); idle_image = find_image_path(E3XX_SG1_FPGA_IDLE_FILE_NAME); @@ -405,14 +405,14 @@ e300_impl::e300_impl(const uhd::device_addr_t &device_addr) _codec_mgr = ad936x_manager::make(_codec_ctrl, fpga::NUM_RADIOS); #ifdef E300_GPSD - UHD_MSG(status) << "Detecting internal GPSDO " << std::flush; + UHD_LOGGER_INFO("E300") << "Detecting internal GPSDO "; try { if (_xport_path == AXI) _gps = gpsd_iface::make("localhost", 2947); else _gps = gpsd_iface::make(device_addr["addr"], 2947); } catch (std::exception &e) { - UHD_MSG(error) << "An error occured making GPSDd interface: " << e.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "An error occured making GPSDd interface: " << e.what(); } if (_gps) { @@ -426,12 +426,12 @@ e300_impl::e300_impl(const uhd::device_addr_t &device_addr) break; } } - UHD_MSG(status) << (_gps->gps_detected() ? "found" : "not found") << std::endl; + UHD_LOGGER_INFO("E300") << "GPSDO " << (_gps->gps_detected() ? "found" : "not found"); } #endif // Verify we can talk to the e300 core control registers ... - UHD_MSG(status) << "Initializing core control..." << std::endl; + UHD_LOGGER_INFO("E300") << "Initializing core control..."; this->_register_loopback_self_test(_global_regs); // Verify fpga compatibility version matches at least for the major @@ -692,9 +692,9 @@ void e300_impl::_enforce_tick_rate_limits( double e300_impl::_set_tick_rate(const double rate) { - UHD_MSG(status) << "Asking for clock rate " << rate/1e6 << " MHz\n"; + UHD_LOGGER_INFO("E300") << "Asking for clock rate " << rate/1e6 << " MHz\n"; _tick_rate = _codec_ctrl->set_clock_rate(rate); - UHD_MSG(status) << "Actually got clock rate " << _tick_rate/1e6 << " MHz\n"; + UHD_LOGGER_INFO("E300") << "Actually got clock rate " << _tick_rate/1e6 << " MHz\n"; for(radio_perifs_t &perif: _radio_perifs) { @@ -707,7 +707,7 @@ double e300_impl::_set_tick_rate(const double rate) void e300_impl::_register_loopback_self_test(wb_iface::sptr iface) { bool test_fail = false; - UHD_MSG(status) << "Performing register loopback test... " << std::flush; + UHD_LOGGER_INFO("E300") << "Performing register loopback test... "; size_t hash = size_t(time(NULL)); for (size_t i = 0; i < 100; i++) { @@ -716,7 +716,7 @@ void e300_impl::_register_loopback_self_test(wb_iface::sptr iface) test_fail = iface->peek32(radio::RB32_TEST) != uint32_t(hash); if (test_fail) break; //exit loop on any failure } - UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl; + UHD_LOGGER_INFO("E300") << "Register loopback test " << ((test_fail)? " failed" : "passed"); } uint32_t e300_impl::_get_version(compat_t which) @@ -753,13 +753,13 @@ uint32_t e300_impl::_allocate_sid(const sid_config_t &config) | (config.router_addr_there << 8) | (stream << 0) ; - UHD_LOG << std::hex + UHD_LOGGER_DEBUG("E300")<< std::hex << " sid 0x" << sid << " framer 0x" << _sid_framer << " stream 0x" << stream << " router_dst_there 0x" << int(config.router_dst_there) << " router_addr_there 0x" << int(config.router_addr_there) - << std::dec << std::endl; + << std::dec ; // Program the E300 to recognize it's own local address. _global_regs->poke32(global_regs::SR_CORE_XB_LOCAL, config.router_addr_there); @@ -775,9 +775,9 @@ uint32_t e300_impl::_allocate_sid(const sid_config_t &config) _global_regs->poke32(XB_ADDR(E300_DEVICE_HERE), config.router_dst_here); - UHD_LOG << std::hex + UHD_LOGGER_DEBUG("E300") << std::hex << "done router config for sid 0x" << sid - << std::dec << std::endl; + << std::dec ; //increment for next setup _sid_framer++; @@ -787,14 +787,14 @@ uint32_t e300_impl::_allocate_sid(const sid_config_t &config) void e300_impl::_setup_dest_mapping(const uint32_t sid, const size_t which_stream) { - UHD_LOG << boost::format("Setting up dest map for 0x%lx to be stream %d") - % (sid & 0xff) % which_stream << std::endl; + UHD_LOGGER_DEBUG("E300") << boost::format("Setting up dest map for 0x%lx to be stream %d") + % (sid & 0xff) % which_stream ; _global_regs->poke32(DST_ADDR(sid & 0xff), which_stream); } void e300_impl::_update_time_source(const std::string &source) { - UHD_MSG(status) << boost::format("Setting time source to %s") % source << std::endl; + UHD_LOGGER_INFO("E300") << boost::format("Setting time source to %s") % source; if (source == "none" or source == "internal") { _misc.pps_sel = global_regs::PPS_INT; #ifdef E300_GPSD diff --git a/host/lib/usrp/e300/e300_io_impl.cpp b/host/lib/usrp/e300/e300_io_impl.cpp index bcdb8077b..4490afa21 100644 --- a/host/lib/usrp/e300/e300_io_impl.cpp +++ b/host/lib/usrp/e300/e300_io_impl.cpp @@ -335,7 +335,7 @@ static void handle_tx_async_msgs(boost::shared_ptr<e300_tx_fc_cache_t> fc_cache, } catch(const std::exception &ex) { - UHD_MSG(error) << "Error parsing async message packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "Error parsing async message packet: " << ex.what() ; return; } @@ -482,9 +482,9 @@ rx_streamer::sptr e300_impl::get_rx_stream(const uhd::stream_args_t &args_) E300_RX_SW_BUFF_FULLNESS); const size_t fc_handle_window = std::max<size_t>(1, fc_window / E300_RX_FC_REQUEST_FREQ); - UHD_LOG << "RX Flow Control Window = " << fc_window + UHD_LOGGER_DEBUG("E300") << "RX Flow Control Window = " << fc_window << ", RX Flow Control Handler Window = " - << fc_handle_window << std::endl; + << fc_handle_window ; perif.framer->configure_flow_control(fc_window); boost::shared_ptr<e300_rx_fc_cache_t> fc_cache(new e300_rx_fc_cache_t()); @@ -590,9 +590,9 @@ tx_streamer::sptr e300_impl::get_tx_stream(const uhd::stream_args_t &args_) const size_t fc_window = data_xports.send->get_num_send_frames(); const size_t fc_handle_window = std::max<size_t>(1, fc_window/E300_TX_FC_RESPONSE_FREQ); - UHD_LOG << "TX Flow Control Window = " << fc_window + UHD_LOGGER_DEBUG("E300") << "TX Flow Control Window = " << fc_window << ", TX Flow Control Handler Window = " - << fc_handle_window << std::endl; + << fc_handle_window ; perif.deframer->configure_flow_control(0/*cycs off*/, fc_handle_window/*pkts*/); boost::shared_ptr<e300_tx_fc_cache_t> fc_cache(new e300_tx_fc_cache_t()); diff --git a/host/lib/usrp/e300/e300_network.cpp b/host/lib/usrp/e300/e300_network.cpp index e68f2a54d..f3045eb2d 100644 --- a/host/lib/usrp/e300/e300_network.cpp +++ b/host/lib/usrp/e300/e300_network.cpp @@ -31,7 +31,7 @@ #include "e300_common.hpp" #include "e300_remote_codec_ctrl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/paths.hpp> @@ -88,7 +88,7 @@ static void e300_recv_tunnel( //step 1 - get the buffer managed_recv_buffer::sptr buff = recver->get_recv_buff(); if (not buff) continue; - if (E300_NETWORK_DEBUG) UHD_MSG(status) << name << " got " << buff->size() << std::endl; + if (E300_NETWORK_DEBUG) UHD_LOGGER_INFO("E300") << name << " got " << buff->size(); //step 1.5 -- update endpoint { @@ -102,13 +102,13 @@ static void e300_recv_tunnel( } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_recv_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_recv_tunnel exit " << name << " " << ex.what(); } catch(...) { - UHD_MSG(error) << "e300_recv_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_recv_tunnel exit " << name ; } - UHD_MSG(status) << "e300_recv_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_recv_tunnel exit " << name; *running = false; } @@ -136,7 +136,7 @@ static void e300_send_tunnel( while (not wait_for_recv_ready(recver->native(), 100) and *running){} if (not *running) break; const size_t num_bytes = recver->receive_from(asio::buffer(buff->cast<void *>(), buff->size()), _rx_endpoint); - if (E300_NETWORK_DEBUG) UHD_MSG(status) << name << " got " << num_bytes << std::endl; + if (E300_NETWORK_DEBUG) UHD_LOGGER_INFO("E300") << name << " got " << num_bytes; //step 2.5 -- update endpoint { @@ -150,13 +150,13 @@ static void e300_send_tunnel( } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_send_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_send_tunnel exit " << name << " " << ex.what() ; } catch(...) { - UHD_MSG(error) << "e300_send_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_send_tunnel exit " << name ; } - UHD_MSG(status) << "e300_send_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_send_tunnel exit " << name; *running = false; } @@ -252,7 +252,7 @@ static void e300_codec_ctrl_tunnel( out->bw = _codec_ctrl->set_bw_filter(which_str, in->bw); break; default: - UHD_MSG(status) << "Got unknown request?!" << std::endl; + UHD_LOGGER_INFO("E300") << "Got unknown request?!"; //Zero out actions to fail this request on client out->action = uhd::htonx<uint32_t>(0); } @@ -262,13 +262,13 @@ static void e300_codec_ctrl_tunnel( } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_ctrl_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_ctrl_tunnel exit " << name << " " << ex.what() ; } catch(...) { - UHD_MSG(error) << "e300_ctrl_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_ctrl_tunnel exit " << name ; } - UHD_MSG(status) << "e300_ctrl_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_ctrl_tunnel exit " << name; *running = false; } @@ -309,13 +309,13 @@ static void e300_global_regs_tunnel( } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_gregs_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_gregs_tunnel exit " << name << " " << ex.what() ; } catch(...) { - UHD_MSG(error) << "e300_gregs_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_gregs_tunnel exit " << name ; } - UHD_MSG(status) << "e300_gregs_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_gregs_tunnel exit " << name; *running = false; } @@ -353,20 +353,20 @@ static void e300_sensor_tunnel( in->value = uhd::htonx<uint32_t>( sensor_manager->get_ref_lock().to_bool() ? 1 : 0); } else - UHD_MSG(status) << "Got unknown request?!" << std::endl; + UHD_LOGGER_INFO("E300") << "Got unknown request?!"; socket->send_to(asio::buffer(in_buff, sizeof(sensor_transaction_t)), *endpoint); } } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_sensor_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_sensor_tunnel exit " << name << " " << ex.what() ; } catch(...) { - UHD_MSG(error) << "e300_sensor_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_sensor_tunnel exit " << name ; } - UHD_MSG(status) << "e300_sensor_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_sensor_tunnel exit " << name; *running = false; } @@ -419,19 +419,19 @@ static void e300_i2c_tunnel( } } else { - UHD_MSG(error) << "e300_i2c_tunnel could not handle message." << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_i2c_tunnel could not handle message." ; } } } catch(const std::exception &ex) { - UHD_MSG(error) << "e300_i2c_tunnel exit " << name << " " << ex.what() << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_i2c_tunnel exit " << name << " " << ex.what() ; } catch(...) { - UHD_MSG(error) << "e300_i2c_tunnel exit " << name << std::endl; + UHD_LOGGER_ERROR("E300") << "e300_i2c_tunnel exit " << name ; } - UHD_MSG(status) << "e300_i2c_tunnel exit " << name << std::endl; + UHD_LOGGER_INFO("E300") << "e300_i2c_tunnel exit " << name; *running = false; } @@ -491,7 +491,7 @@ void network_server_impl::_run_server( //boost::shared_ptr<asio::ip::udp::acceptor> acceptor(new asio::ip::udp::acceptor(io_service, endpoint)); while (not boost::this_thread::interruption_requested()) { - UHD_MSG(status) << "e300 run server on port " << port << " for " << what << std::endl; + UHD_LOGGER_INFO("E300") << "e300 run server on port " << port << " for " << what; try { //while (not wait_for_recv_ready(acceptor->native(), 100)) @@ -501,7 +501,7 @@ void network_server_impl::_run_server( boost::shared_ptr<asio::ip::udp::socket> socket; socket.reset(new asio::ip::udp::socket(io_service, endpoint)); //acceptor->accept(*socket); - UHD_MSG(status) << "e300 socket accept on port " << port << " for " << what << std::endl; + UHD_LOGGER_INFO("E300") << "e300 socket accept on port " << port << " for " << what; //asio::ip::udp::no_delay option(true); //socket->set_option(option); boost::thread_group tg; @@ -586,8 +586,8 @@ network_server_impl::network_server_impl(const uhd::device_addr_t &device_addr) break; case e300_eeprom_manager::UNKNOWN: default: - UHD_MSG(warning) << "Unknown motherboard type, loading e300 image." - << std::endl; + UHD_LOGGER_WARNING("E300") << "Unknown motherboard type, loading e300 image." + ; fpga_image = find_image_path(E300_FPGA_FILE_NAME); break; } diff --git a/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp b/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp index b7c46c17d..d970d7221 100644 --- a/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp +++ b/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp @@ -242,7 +242,7 @@ public: //! Write back a filter void set_filter(const std::string &, const std::string &, const filter_info_base::sptr) { - UHD_MSG(warning) << "Attempting to set filter on E300 in network mode." << std::endl; + UHD_LOGGER_WARNING("E300") << "Attempting to set filter on E300 in network mode." ; } void output_digital_test_tone(UHD_UNUSED(bool enb)) diff --git a/host/lib/usrp/e300/e300_sysfs_hooks.cpp b/host/lib/usrp/e300/e300_sysfs_hooks.cpp index 7bd1d6d7e..bcfca8b92 100644 --- a/host/lib/usrp/e300/e300_sysfs_hooks.cpp +++ b/host/lib/usrp/e300/e300_sysfs_hooks.cpp @@ -32,7 +32,7 @@ #include <boost/format.hpp> #include <boost/lexical_cast.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> static const std::string E300_AXI_FPGA_SYSFS = "40000000.axi-fpga"; diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index b4b4ffa0f..cc3e1b8e3 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -16,7 +16,7 @@ // #include <uhd/usrp/gps_ctrl.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/types/sensors.hpp> @@ -91,7 +91,7 @@ private: sentences[which].get<2>() = true; } } catch(std::exception &e) { - UHD_LOGV(often) << "get_sentence: " << e.what(); + UHD_LOGGER_DEBUG("GPS") << "get_sentence: " << e.what(); } if (not sentence.empty() or now > exit_time) @@ -158,7 +158,7 @@ private: if (msg.length() < 6) { - UHD_LOGV(regularly) << __FUNCTION__ << ": Short GPSDO string: " << msg << std::endl; + UHD_LOGGER_WARNING("GPS") << __FUNCTION__ << ": Short GPSDO string: " << msg ; continue; } @@ -173,7 +173,7 @@ private: } else { - UHD_LOGV(regularly) << __FUNCTION__ << ": Malformed GPSDO string: " << msg << std::endl; + UHD_LOGGER_WARNING("GPS") << __FUNCTION__ << ": Malformed GPSDO string: " << msg ; } } @@ -233,7 +233,7 @@ public: if(i_heard_some_nmea) { _gps_type = GPS_TYPE_GENERIC_NMEA; } else if(i_heard_something_weird) { - UHD_MSG(error) << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl; + UHD_LOGGER_ERROR("GPS") << "GPS invalid reply \"" << reply << "\", assuming none available"; } } @@ -241,17 +241,17 @@ public: case GPS_TYPE_INTERNAL_GPSDO: erase_all(reply, "\r"); erase_all(reply, "\n"); - UHD_MSG(status) << "Found an internal GPSDO: " << reply << std::endl; + UHD_LOGGER_INFO("GPS") << "Found an internal GPSDO: " << reply; init_gpsdo(); break; case GPS_TYPE_GENERIC_NMEA: - UHD_MSG(status) << "Found a generic NMEA GPS device" << std::endl; + UHD_LOGGER_INFO("GPS") << "Found a generic NMEA GPS device"; break; case GPS_TYPE_NONE: default: - UHD_MSG(status) << "No GPSDO found" << std::endl; + UHD_LOGGER_INFO("GPS") << "No GPSDO found"; break; } @@ -361,7 +361,7 @@ private: return gps_time; } catch(std::exception &e) { - UHD_LOGV(often) << "get_time: " << e.what(); + UHD_LOGGER_DEBUG("GPS") << "get_time: " << e.what(); error_cnt++; } } @@ -388,7 +388,7 @@ private: else return (get_token(reply, 6) != "0"); } catch(std::exception &e) { - UHD_LOGV(often) << "locked: " << e.what(); + UHD_LOGGER_DEBUG("GPS") << "locked: " << e.what(); error_cnt++; } } diff --git a/host/lib/usrp/gpsd_iface.cpp b/host/lib/usrp/gpsd_iface.cpp index 98b359135..c5d4a1745 100644 --- a/host/lib/usrp/gpsd_iface.cpp +++ b/host/lib/usrp/gpsd_iface.cpp @@ -31,7 +31,7 @@ #include <uhd/exception.hpp> #include <uhd/usrp/gps_ctrl.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/dict.hpp> #include "gpsd_iface.hpp" diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index a86d05945..d64ff8ebd 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -17,7 +17,7 @@ #include <uhd/property_tree.hpp> #include <uhd/usrp/multi_usrp.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> #include <uhd/utils/math.hpp> @@ -65,7 +65,7 @@ static void do_samp_rate_warning_message( ){ static const double max_allowed_error = 1.0; //Sps if (std::abs(target_rate - actual_rate) > max_allowed_error){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("MULTI_USRP") << boost::format( "The hardware does not support the requested %s sample rate:\n" "Target sample rate: %f MSps\n" "Actual sample rate: %f MSps\n" @@ -96,7 +96,7 @@ static void do_samp_rate_warning_message( if(requested_freq_success and target_freq_success and rf_lo_tune_success and dsp_tune_success) { - UHD_MSG(status) << boost::format( + UHD_LOGGER_INFO("MULTI_USRP") << boost::format( "Successfully tuned to %f MHz\n\n") % (actual_freq / 1e6); } else { @@ -119,7 +119,7 @@ static void do_samp_rate_warning_message( results_string += rf_lo_message.str(); - UHD_MSG(status) << results_string; + UHD_LOGGER_INFO("MULTI_USRP") << results_string; return; } @@ -173,7 +173,7 @@ static void do_samp_rate_warning_message( results_string += failure_message.str(); } - UHD_MSG(warning) << results_string << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << results_string ; } }*/ @@ -458,7 +458,7 @@ public: if (_tree->exists(mb_root(mboard) / "auto_tick_rate") and _tree->access<bool>(mb_root(mboard) / "auto_tick_rate").get()) { _tree->access<bool>(mb_root(mboard) / "auto_tick_rate").set(false); - UHD_MSG(status) << "Setting master clock rate selection to 'manual'." << std::endl; + UHD_LOGGER_INFO("MULTI_USRP") << "Setting master clock rate selection to 'manual'."; } _tree->access<double>(mb_root(mboard) / "tick_rate").set(rate); return; @@ -556,7 +556,7 @@ public: } void set_time_unknown_pps(const time_spec_t &time_spec){ - UHD_MSG(status) << " 1) catch time transition at pps edge" << std::endl; + UHD_LOGGER_INFO("MULTI_USRP") << " 1) catch time transition at pps edge"; boost::system_time end_time = boost::get_system_time() + boost::posix_time::milliseconds(1100); time_spec_t time_start_last_pps = get_time_last_pps(); while (time_start_last_pps == get_time_last_pps()) @@ -572,7 +572,7 @@ public: boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } - UHD_MSG(status) << " 2) set times next pps (synchronously)" << std::endl; + UHD_LOGGER_INFO("MULTI_USRP") << " 2) set times next pps (synchronously)"; set_time_next_pps(time_spec, ALL_MBOARDS); boost::this_thread::sleep(boost::posix_time::seconds(1)); @@ -581,7 +581,7 @@ public: time_spec_t time_0 = this->get_time_now(0); time_spec_t time_i = this->get_time_now(m); if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)){ //10 ms: greater than RTT but not too big - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("MULTI_USRP") << boost::format( "Detected time deviation between board %d and board 0.\n" "Board 0 time is %f seconds.\n" "Board %d time is %f seconds.\n" @@ -796,7 +796,7 @@ public: { throw uhd::index_error(str(boost::format("multi_usrp::get_rx_subdev_spec(%u) failed to make default spec - %s") % mboard % e.what())); } - UHD_MSG(status) << "Selecting default RX front end spec: " << spec.to_pp_string() << std::endl; + UHD_LOGGER_INFO("MULTI_USRP") << "Selecting default RX front end spec: " << spec.to_pp_string(); } return spec; } @@ -1040,7 +1040,7 @@ public: if (_tree->exists(rx_rf_fe_root(chan) / "gain" / "agc")) { bool agc = _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").get(); if(agc) { - UHD_MSG(warning) << "AGC enabled for this channel. Setting will be ignored." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "AGC enabled for this channel. Setting will be ignored." ; } } } else { @@ -1048,7 +1048,7 @@ public: if (_tree->exists(rx_rf_fe_root(c) / "gain" / "agc")) { bool agc = _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").get(); if(agc) { - UHD_MSG(warning) << "AGC enabled for this channel. Setting will be ignored." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "AGC enabled for this channel. Setting will be ignored." ; } } } @@ -1078,7 +1078,7 @@ public: if (_tree->exists(rx_rf_fe_root(chan) / "gain" / "agc" / "enable")) { _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").set(enable); } else { - UHD_MSG(warning) << "AGC is not available on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "AGC is not available on this device." ; } return; } @@ -1167,7 +1167,7 @@ public: /*For B2xx devices the dc-offset correction is implemented in the rf front-end*/ _tree->access<bool>(rx_rf_fe_root(chan) / "dc_offset" / "enable").set(enb); } else { - UHD_MSG(warning) << "Setting DC offset compensation is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting DC offset compensation is not possible on this device." ; } return; } @@ -1181,7 +1181,7 @@ public: if (_tree->exists(rx_fe_root(chan) / "dc_offset" / "value")) { _tree->access<std::complex<double> >(rx_fe_root(chan) / "dc_offset" / "value").set(offset); } else { - UHD_MSG(warning) << "Setting DC offset is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting DC offset is not possible on this device." ; } return; } @@ -1195,7 +1195,7 @@ public: if (_tree->exists(rx_rf_fe_root(chan) / "iq_balance" / "enable")) { _tree->access<bool>(rx_rf_fe_root(chan) / "iq_balance" / "enable").set(enb); } else { - UHD_MSG(warning) << "Setting IQ imbalance compensation is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting IQ imbalance compensation is not possible on this device." ; } return; } @@ -1209,7 +1209,7 @@ public: if (_tree->exists(rx_fe_root(chan) / "iq_balance" / "value")) { _tree->access<std::complex<double> >(rx_fe_root(chan) / "iq_balance" / "value").set(offset); } else { - UHD_MSG(warning) << "Setting IQ balance is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting IQ balance is not possible on this device." ; } return; } @@ -1336,7 +1336,7 @@ public: { throw uhd::index_error(str(boost::format("multi_usrp::get_tx_subdev_spec(%u) failed to make default spec - %s") % mboard % e.what())); } - UHD_MSG(status) << "Selecting default TX front end spec: " << spec.to_pp_string() << std::endl; + UHD_LOGGER_INFO("MULTI_USRP") << "Selecting default TX front end spec: " << spec.to_pp_string(); } return spec; } @@ -1504,7 +1504,7 @@ public: if (_tree->exists(tx_fe_root(chan) / "dc_offset" / "value")) { _tree->access<std::complex<double> >(tx_fe_root(chan) / "dc_offset" / "value").set(offset); } else { - UHD_MSG(warning) << "Setting DC offset is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting DC offset is not possible on this device." ; } return; } @@ -1518,7 +1518,7 @@ public: if (_tree->exists(tx_fe_root(chan) / "iq_balance" / "value")) { _tree->access<std::complex<double> >(tx_fe_root(chan) / "iq_balance" / "value").set(offset); } else { - UHD_MSG(warning) << "Setting IQ balance is not possible on this device." << std::endl; + UHD_LOGGER_WARNING("MULTI_USRP") << "Setting IQ balance is not possible on this device." ; } return; } @@ -1918,10 +1918,10 @@ private: } sum_rate /= get_num_mboards(); if (max_link_rate > 0 and (max_link_rate / bytes_per_sample) < sum_rate) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("MULTI_USRP") << boost::format( "The total sum of rates (%f MSps on %u channels) exceeds the maximum capacity of the connection.\n" "This can cause %s." - ) % (sum_rate/1e6) % args.channels.size() % (is_tx ? "underruns (U)" : "overflows (O)") << std::endl; + ) % (sum_rate/1e6) % args.channels.size() % (is_tx ? "underruns (U)" : "overflows (O)") ; link_rate_is_ok = false; } @@ -1937,6 +1937,6 @@ multi_usrp::~multi_usrp(void){ * The Make Function **********************************************************************/ multi_usrp::sptr multi_usrp::make(const device_addr_t &dev_addr){ - UHD_LOG << "multi_usrp::make with args " << dev_addr.to_pp_string() << std::endl; + UHD_LOGGER_DEBUG("MULTI_USRP") << "multi_usrp::make with args " << dev_addr.to_pp_string() ; return sptr(new multi_usrp_impl(dev_addr)); } diff --git a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp index ff4289922..372325fbe 100644 --- a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp +++ b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp @@ -17,7 +17,7 @@ #include "n230_clk_pps_ctrl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <stdint.h> #include <boost/format.hpp> @@ -55,9 +55,9 @@ public: double set_tick_rate(const double rate) { - UHD_MSG(status) << "Configuring a tick rate of " << rate/1e6 << " MHz... "; + UHD_LOGGER_INFO("N230") << "Configuring a tick rate of " << rate/1e6 << " MHz... "; _tick_rate = _codec_ctrl->set_clock_rate(rate); - UHD_MSG(status) << "got " << _tick_rate/1e6 << " MHz\n"; + UHD_LOGGER_INFO("N230") << "got " << _tick_rate/1e6 << " MHz\n"; for(time_core_3000::sptr& time_core: _time_cores) { time_core->set_tick_rate(_tick_rate); diff --git a/host/lib/usrp/n230/n230_eeprom_manager.cpp b/host/lib/usrp/n230/n230_eeprom_manager.cpp index d9d02c58c..c21eb9ddb 100644 --- a/host/lib/usrp/n230/n230_eeprom_manager.cpp +++ b/host/lib/usrp/n230/n230_eeprom_manager.cpp @@ -17,7 +17,7 @@ #include "n230_eeprom.h" #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/types/mac_addr.hpp> #include <boost/format.hpp> diff --git a/host/lib/usrp/n230/n230_frontend_ctrl.cpp b/host/lib/usrp/n230/n230_frontend_ctrl.cpp index 3d81721ec..80f1232b1 100644 --- a/host/lib/usrp/n230/n230_frontend_ctrl.cpp +++ b/host/lib/usrp/n230/n230_frontend_ctrl.cpp @@ -17,7 +17,7 @@ #include "n230_frontend_ctrl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <uhd/types/dict.hpp> #include <boost/format.hpp> diff --git a/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp b/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp index 68fad3035..07f9bb7d6 100644 --- a/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp +++ b/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp @@ -18,7 +18,7 @@ #include "n230_fw_ctrl_iface.hpp" #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/asio.hpp> //used for htonl and ntohl @@ -74,7 +74,7 @@ void n230_fw_ctrl_iface::poke32(const wb_addr_type addr, const uint32_t data) } catch(const std::exception &ex) { const std::string error_msg = str(boost::format( "udp fw poke32 failure #%u\n%s") % i % ex.what()); - if (_verbose) UHD_MSG(warning) << error_msg << std::endl; + if (_verbose) UHD_LOGGER_WARNING("N230") << error_msg ; if (i == NUM_RETRIES) throw uhd::io_error(error_msg); } } @@ -90,7 +90,7 @@ uint32_t n230_fw_ctrl_iface::peek32(const wb_addr_type addr) } catch(const std::exception &ex) { const std::string error_msg = str(boost::format( "udp fw peek32 failure #%u\n%s") % i % ex.what()); - if (_verbose) UHD_MSG(warning) << error_msg << std::endl; + if (_verbose) UHD_LOGGER_WARNING("N230") << error_msg ; if (i == NUM_RETRIES) throw uhd::io_error(error_msg); } } @@ -182,8 +182,8 @@ std::vector<std::string> n230_fw_ctrl_iface::discover_devices( try { udp_bcast_xport = uhd::transport::udp_simple::make_broadcast(addr_hint, port); } catch(const std::exception &e) { - UHD_MSG(error) << boost::format("Cannot open UDP transport on %s for discovery\n%s") - % addr_hint % e.what() << std::endl; + UHD_LOGGER_ERROR("N230") << boost::format("Cannot open UDP transport on %s for discovery\n%s") + % addr_hint % e.what() ; return addrs; } diff --git a/host/lib/usrp/n230/n230_impl.cpp b/host/lib/usrp/n230/n230_impl.cpp index 817868ef0..63971fb34 100644 --- a/host/lib/usrp/n230/n230_impl.cpp +++ b/host/lib/usrp/n230/n230_impl.cpp @@ -25,7 +25,7 @@ #include <uhd/usrp/subdev_spec.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/types/sensors.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/direction.hpp> @@ -190,7 +190,7 @@ device::sptr n230_impl::n230_make(const device_addr_t &device_addr) **********************************************************************/ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr) { - UHD_MSG(status) << "N230 initialization sequence..." << std::endl; + UHD_LOGGER_INFO("N230") << "N230 initialization sequence..."; _dev_args.parse(dev_addr); _tree = uhd::property_tree::make(); @@ -208,9 +208,9 @@ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr) const mboard_eeprom_t& mb_eeprom = _eeprom_mgr->get_mb_eeprom(); bool recover_mb_eeprom = dev_addr.has_key("recover_mb_eeprom"); if (recover_mb_eeprom) { - UHD_MSG(warning) << "UHD is operating in EEPROM Recovery Mode which disables hardware version " + UHD_LOGGER_WARNING("N230") << "UHD is operating in EEPROM Recovery Mode which disables hardware version " "checks.\nOperating in this mode may cause hardware damage and unstable " - "radio performance!"<< std::endl; + "radio performance!"; } uint16_t hw_rev = boost::lexical_cast<uint16_t>(mb_eeprom["revision"]); uint16_t hw_rev_compat = boost::lexical_cast<uint16_t>(mb_eeprom["revision_compat"]); @@ -232,11 +232,11 @@ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr) //Debug loopback mode switch(_dev_args.get_loopback_mode()) { case n230_device_args_t::LOOPBACK_RADIO: - UHD_MSG(status) << "DEBUG: Running in TX->RX Radio loopback mode.\n"; + UHD_LOGGER_INFO("N230") << "DEBUG: Running in TX->RX Radio loopback mode."; _resource_mgr->get_frontend_ctrl().set_self_test_mode(LOOPBACK_RADIO); break; case n230_device_args_t::LOOPBACK_CODEC: - UHD_MSG(status) << "DEBUG: Running in TX->RX CODEC loopback mode.\n"; + UHD_LOGGER_INFO("N230") << "DEBUG: Running in TX->RX CODEC loopback mode."; _resource_mgr->get_frontend_ctrl().set_self_test_mode(LOOPBACK_CODEC); break; default: diff --git a/host/lib/usrp/n230/n230_resource_manager.cpp b/host/lib/usrp/n230/n230_resource_manager.cpp index c5617bbf7..4de5f77ec 100644 --- a/host/lib/usrp/n230/n230_resource_manager.cpp +++ b/host/lib/usrp/n230/n230_resource_manager.cpp @@ -21,7 +21,7 @@ #include <uhd/transport/if_addrs.hpp> #include <uhd/transport/udp_zero_copy.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/platform.hpp> #include <uhd/utils/paths.hpp> #include <boost/format.hpp> @@ -80,8 +80,8 @@ n230_resource_manager::n230_resource_manager( _safe_mode(safe_mode), _last_host_enpoint(0) { - if (_safe_mode) UHD_MSG(warning) << "Initializing device in safe mode\n"; - UHD_MSG(status) << "Setup basic communication...\n"; + if (_safe_mode) UHD_LOGGER_WARNING("N230") << "Initializing device in safe mode\n"; + UHD_LOGGER_INFO("N230") << "Setup basic communication..."; //Discover ethernet interfaces bool dual_eth_expected = (ip_addrs.size() > 1); @@ -145,7 +145,7 @@ n230_resource_manager::n230_resource_manager( } _check_fpga_compat(); - UHD_MSG(status) << boost::format("Version signatures... Firmware:%s FPGA:%s...\n") + UHD_LOGGER_INFO("N230") << boost::format("Version signatures... Firmware:%s FPGA:%s...") % _fw_version.get_hash_str() % _fpga_version.get_hash_str(); _core_radio_ctrl_reg.initialize(*_core_ctrl, true /*flush*/); @@ -160,7 +160,7 @@ n230_resource_manager::n230_resource_manager( } //Create AD9361 interface - UHD_MSG(status) << "Initializing CODEC...\n"; + UHD_LOGGER_INFO("N230") << "Initializing CODEC..."; _codec_ctrl = ad9361_ctrl::make_spi( boost::make_shared<n230_ad9361_client_t>(), _core_spi_ctrl, fpga::AD9361_SPI_SLAVE_NUM); if (_codec_ctrl.get() == NULL) { @@ -210,7 +210,7 @@ n230_resource_manager::n230_resource_manager( //Create GPSDO interface if (_core_status_reg.read(fpga::core_status_reg_t::GPSDO_STATUS) != fpga::GPSDO_ST_ABSENT) { - UHD_MSG(status) << "Detecting GPSDO.... " << std::flush; + UHD_LOGGER_INFO("N230") << "Detecting GPSDO.... "; try { const sid_t gps_uart_sid = _generate_sid(GPS_UART, _get_conn(PRI_ETH).type); transport::zero_copy_if::sptr gps_uart_xport = @@ -221,7 +221,7 @@ n230_resource_manager::n230_resource_manager( boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for a little propagation _gps_ctrl = gps_ctrl::make(_gps_uart); } catch(std::exception &e) { - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("N230") << "An error occurred making GPSDO control: " << e.what() ; } if (not is_gpsdo_present()) { _core_ctrl->poke32(fpga::sr_addr(fpga::SR_CORE_GPSDO_ST), fpga::GPSDO_ST_ABSENT); @@ -488,7 +488,7 @@ bool n230_resource_manager::_radio_data_loopback_self_test(wb_iface::sptr iface) const uint32_t rb_rx = uint32_t(rb_word64 & 0xffffffff); test_fail = word32 != rb_tx or word32 != rb_rx; if (test_fail){ - UHD_MSG(fastpath) << boost::format("mismatch (exp:%x, got:%x and %x)... ") % word32 % rb_tx % rb_rx; + UHD_LOG_FASTPATH(boost::format("mismatch (exp:%x, got:%x and %x)... ") % word32 % rb_tx % rb_rx) break; //exit loop on any failure } } diff --git a/host/lib/usrp/n230/n230_stream_manager.cpp b/host/lib/usrp/n230/n230_stream_manager.cpp index 7c936a184..95da2752e 100644 --- a/host/lib/usrp/n230/n230_stream_manager.cpp +++ b/host/lib/usrp/n230/n230_stream_manager.cpp @@ -477,7 +477,7 @@ void n230_stream_manager::_handle_tx_async_msgs( _cvita_hdr_unpack(packet_buff, if_packet_info); endian_conv = uhd::ntohx; } catch(const std::exception &ex) { - UHD_MSG(error) << "Error parsing async message packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("N230") << "Error parsing async message packet: " << ex.what() ; return; } diff --git a/host/lib/usrp/n230/n230_uart.cpp b/host/lib/usrp/n230/n230_uart.cpp index 7291a7276..7330dff4a 100644 --- a/host/lib/usrp/n230/n230_uart.cpp +++ b/host/lib/usrp/n230/n230_uart.cpp @@ -20,7 +20,7 @@ #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/vrt_if_packet.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/exception.hpp> diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index 4c811d5e2..73b97aa13 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -277,9 +277,9 @@ void usrp1_codec_ctrl_impl::send_reg(uint8_t addr) { uint32_t reg = _ad9862_regs.get_write_reg(addr); - UHD_LOGV(often) + UHD_LOGGER_DEBUG("USRP1") << "codec control write reg: 0x" - << std::setw(8) << std::hex << reg << std::endl + << std::setw(8) << std::hex << reg ; _iface->write_spi(_spi_slave, spi_config_t::EDGE_RISE, reg, 16); @@ -289,17 +289,17 @@ void usrp1_codec_ctrl_impl::recv_reg(uint8_t addr) { uint32_t reg = _ad9862_regs.get_read_reg(addr); - UHD_LOGV(often) + UHD_LOGGER_DEBUG("USRP1") << "codec control read reg: 0x" - << std::setw(8) << std::hex << reg << std::endl + << std::setw(8) << std::hex << reg ; uint32_t ret = _iface->read_spi(_spi_slave, spi_config_t::EDGE_RISE, reg, 16); - UHD_LOGV(often) + UHD_LOGGER_DEBUG("USRP1") << "codec control read ret: 0x" - << std::setw(8) << std::hex << ret << std::endl + << std::setw(8) << std::hex << ret ; _ad9862_regs.set_reg(addr, uint16_t(ret)); @@ -389,13 +389,13 @@ void usrp1_codec_ctrl_impl::set_duc_freq(double freq, double rate) double coarse_freq = coarse_tune(codec_rate, freq); double fine_freq = fine_tune(codec_rate / 4, freq - coarse_freq); - UHD_LOG - << "ad9862 tuning result:" << std::endl - << " requested: " << freq << std::endl - << " actual: " << coarse_freq + fine_freq << std::endl - << " coarse freq: " << coarse_freq << std::endl - << " fine freq: " << fine_freq << std::endl - << " codec rate: " << codec_rate << std::endl + UHD_LOGGER_DEBUG("USRP1") + << "ad9862 tuning result:" + << " requested: " << freq + << " actual: " << coarse_freq + fine_freq + << " coarse freq: " << coarse_freq + << " fine freq: " << fine_freq + << " codec rate: " << codec_rate ; this->send_reg(20); diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 3e0b23973..7ed1d8671 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -22,7 +22,7 @@ #include "../../transport/super_send_packet_handler.hpp" #include "usrp1_calc_mux.hpp" #include "usrp1_impl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/bounded_buffer.hpp> @@ -305,19 +305,19 @@ void usrp1_impl::vandal_conquest_loop(void){ if (_tx_enabled and underflow){ async_metadata.time_spec = _soft_time_ctrl->get_time(); _soft_time_ctrl->get_async_queue().push_with_pop_on_full(async_metadata); - UHD_MSG(fastpath) << "U"; + UHD_LOG_FASTPATH("U") } if (_rx_enabled and overflow){ inline_metadata.time_spec = _soft_time_ctrl->get_time(); _soft_time_ctrl->get_inline_queue().push_with_pop_on_full(inline_metadata); - UHD_MSG(fastpath) << "O"; + UHD_LOG_FASTPATH("O") } boost::this_thread::sleep(boost::posix_time::milliseconds(50)); }} catch(const boost::thread_interrupted &){} //normal exit condition catch(const std::exception &e){ - UHD_MSG(error) << "The vandal caught an unexpected exception " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP1") << "The vandal caught an unexpected exception " << e.what() ; } } @@ -500,11 +500,11 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){ const size_t div = this->has_rx_halfband()? 2 : 1; const size_t rate = boost::math::iround(_master_clock_rate/this->get_rx_dsp_host_rates().clip(samp_rate, true)); - if (rate < 8 and this->has_rx_halfband()) UHD_MSG(warning) << + if (rate < 8 and this->has_rx_halfband()) UHD_LOGGER_WARNING("USRP1") << "USRP1 cannot achieve decimations below 8 when the half-band filter is present.\n" "The usrp1_fpga_4rx.rbf file is a special FPGA image without RX half-band filters.\n" "To load this image, set the device address key/value pair: fpga=usrp1_fpga_4rx.rbf\n" - << std::endl; + ; if (dspno == 0){ //only care if dsp0 is set since its homogeneous bool s = this->disable_rx(); diff --git a/host/lib/usrp/usrp1/usrp1_calc_mux.hpp b/host/lib/usrp/usrp1/usrp1_calc_mux.hpp index 0ae1c822f..293d9c37c 100644 --- a/host/lib/usrp/usrp1/usrp1_calc_mux.hpp +++ b/host/lib/usrp/usrp1/usrp1_calc_mux.hpp @@ -83,7 +83,7 @@ static uint32_t calc_rx_mux(const std::vector<mapping_pair_t> &mapping){ // for all quadrature sources: Z = 0 // for mixed sources: warning + Z = 0 int Z = (num_quads > 0)? 0 : 1; - if (num_quads != 0 and num_reals != 0) UHD_MSG(warning) << boost::format( + if (num_quads != 0 and num_reals != 0) UHD_LOGGER_WARNING("USRP1") << boost::format( "Mixing real and quadrature rx subdevices is not supported.\n" "The Q input to the real source(s) will be non-zero.\n" ); diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index b65f8fa2f..2d28ad542 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -49,10 +49,10 @@ public: { uint32_t swapped = uhd::htonx(value); - UHD_LOGV(always) + UHD_LOGGER_DEBUG("USRP1") << "poke32(" << std::dec << std::setw(2) << addr << ", 0x" - << std::hex << std::setw(8) << value << ")" << std::endl + << std::hex << std::setw(8) << value << ")" ; uint8_t w_index_h = SPI_ENABLE_FPGA & 0xff; @@ -70,9 +70,9 @@ public: uint32_t peek32(const uint32_t addr) { - UHD_LOGV(always) + UHD_LOGGER_DEBUG("USRP1") << "peek32(" - << std::dec << std::setw(2) << addr << ")" << std::endl + << std::dec << std::setw(2) << addr << ")" ; uint32_t value_out; @@ -129,12 +129,12 @@ public: size_t num_bits, bool readback) { - UHD_LOGV(always) - << "transact_spi: " << std::endl - << " slave: " << which_slave << std::endl - << " bits: " << bits << std::endl - << " num_bits: " << num_bits << std::endl - << " readback: " << readback << std::endl + UHD_LOGGER_DEBUG("USRP1") + << "transact_spi: " + << " slave: " << which_slave + << " bits: " << bits + << " num_bits: " << num_bits + << " readback: " << readback ; UHD_ASSERT_THROW((num_bits <= 32) && !(num_bits % 8)); size_t num_bytes = num_bits / 8; diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 8dee9b7e6..7c479a447 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -19,7 +19,7 @@ #include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/usb_control.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> @@ -83,9 +83,9 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) usrp1_fw_image = find_image_path(hint.get("fw", "usrp1_fw.ihx")); } catch(...){ - UHD_MSG(warning) << boost::format("Could not locate USRP1 firmware. %s") % print_utility_error("uhd_images_downloader.py"); + UHD_LOGGER_WARNING("USRP1") << boost::format("Could not locate USRP1 firmware. %s") % print_utility_error("uhd_images_downloader.py"); } - UHD_LOG << "USRP1 firmware image: " << usrp1_fw_image << std::endl; + UHD_LOGGER_DEBUG("USRP1") << "USRP1 firmware image: " << usrp1_fw_image ; usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -144,14 +144,14 @@ UHD_STATIC_BLOCK(register_usrp1_device){ * Structors **********************************************************************/ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ - UHD_MSG(status) << "Opening a USRP1 device..." << std::endl; + UHD_LOGGER_INFO("USRP1") << "Opening a USRP1 device..."; _type = device::USRP; //extract the FPGA path for the USRP1 std::string usrp1_fpga_image = find_image_path( device_addr.get("fpga", "usrp1_fpga.rbf") ); - UHD_LOG << "USRP1 FPGA image: " << usrp1_fpga_image << std::endl; + UHD_LOGGER_DEBUG("USRP1") << "USRP1 FPGA image: " << usrp1_fpga_image ; //try to match the given device address with something on the USB bus std::vector<usb_device_handle::sptr> device_list = @@ -190,12 +190,12 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _iface->poke32(FR_MODE, 0x00000000); _iface->poke32(FR_DEBUG_EN, 0x00000000); - UHD_LOG - << "USRP1 Capabilities" << std::endl - << " number of duc's: " << get_num_ddcs() << std::endl - << " number of ddc's: " << get_num_ducs() << std::endl - << " rx halfband: " << has_rx_halfband() << std::endl - << " tx halfband: " << has_tx_halfband() << std::endl + UHD_LOGGER_DEBUG("USRP1") + << "USRP1 Capabilities" + << " number of duc's: " << get_num_ddcs() + << " number of ddc's: " << get_num_ducs() + << " rx halfband: " << has_rx_halfband() + << " tx halfband: " << has_tx_halfband() ; //////////////////////////////////////////////////////////////////// @@ -232,7 +232,7 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _master_clock_rate = boost::lexical_cast<double>(device_addr["mcr"]); } catch(const std::exception &e){ - UHD_MSG(error) << "Error parsing FPGA clock rate from device address: " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP1") << "Error parsing FPGA clock rate from device address: " << e.what() ; } } else if (not mb_eeprom["mcr"].empty()){ @@ -240,10 +240,10 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _master_clock_rate = boost::lexical_cast<double>(mb_eeprom["mcr"]); } catch(const std::exception &e){ - UHD_MSG(error) << "Error parsing FPGA clock rate from EEPROM: " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP1") << "Error parsing FPGA clock rate from EEPROM: " << e.what() ; } } - UHD_MSG(status) << boost::format("Using FPGA clock rate of %fMHz...") % (_master_clock_rate/1e6) << std::endl; + UHD_LOGGER_INFO("USRP1") << boost::format("Using FPGA clock rate of %fMHz...") % (_master_clock_rate/1e6) ; _tree->create<double>(mb_path / "tick_rate") .add_coerced_subscriber(boost::bind(&usrp1_impl::update_tick_rate, this, _1)) .set(_master_clock_rate); diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp index 043564727..15bcce4bf 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.cpp +++ b/host/lib/usrp/usrp2/codec_ctrl.cpp @@ -197,7 +197,7 @@ private: void send_ad9777_reg(uint8_t addr){ uint16_t reg = _ad9777_regs.get_write_reg(addr); - UHD_LOGV(always) << "send_ad9777_reg: " << std::hex << reg << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "send_ad9777_reg: " << std::hex << reg; _spiface->write_spi( SPI_SS_AD9777, spi_config_t::EDGE_RISE, reg, 16 diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 3c10c6e79..992d70835 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -23,7 +23,7 @@ #include "usrp2_regs.hpp" #include "fw_common.h" #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/tasks.hpp> #include <uhd/exception.hpp> #include <uhd/utils/byteswap.hpp> @@ -209,7 +209,7 @@ void usrp2_impl::io_impl::recv_pirate_loop( fc_mon.update_fc_condition(uhd::ntohx(fc_word32)); continue; } - //else UHD_MSG(often) << "metadata.event_code " << metadata.event_code << std::endl; + //else UHD_LOGGER_DEBUG("USRP2") << "metadata.event_code " << metadata.event_code; async_msg_fifo.push_with_pop_on_full(metadata); standard_async_msg_prints(metadata); @@ -218,7 +218,7 @@ void usrp2_impl::io_impl::recv_pirate_loop( //TODO unknown received packet, may want to print error... } }catch(const std::exception &e){ - UHD_MSG(error) << "Error in recv pirate loop: " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << "Error in recv pirate loop: " << e.what() ; } } } @@ -375,10 +375,10 @@ void usrp2_impl::program_stream_dest( //user has provided an alternative address and port for destination if (args.args.has_key("addr") and args.args.has_key("port")){ - UHD_MSG(status) << boost::format( - "Programming streaming destination for custom address.\n" - "IPv4 Address: %s, UDP Port: %s\n" - ) % args.args["addr"] % args.args["port"] << std::endl; + UHD_LOGGER_INFO("USRP2") << boost::format( + "Programming streaming destination for custom address. " + "IPv4 Address: %s, UDP Port: %s" + ) % args.args["addr"] % args.args["port"]; asio::io_service io_service; asio::ip::udp::resolver resolver(io_service); @@ -388,7 +388,7 @@ void usrp2_impl::program_stream_dest( stream_ctrl.udp_port = uhd::htonx(uint32_t(endpoint.port())); for (size_t i = 0; i < 3; i++){ - UHD_MSG(status) << "ARP attempt " << i << std::endl; + UHD_LOGGER_INFO("USRP2") << "ARP attempt " << i; managed_send_buffer::sptr send_buff = xport->get_send_buff(); std::memcpy(send_buff->cast<void *>(), &stream_ctrl, sizeof(stream_ctrl)); send_buff->commit(sizeof(stream_ctrl)); @@ -398,7 +398,7 @@ void usrp2_impl::program_stream_dest( if (recv_buff and recv_buff->size() >= sizeof(uint32_t)){ const uint32_t result = uhd::ntohx(recv_buff->cast<const uint32_t *>()[0]); if (result == 0){ - UHD_MSG(status) << "Success! " << std::endl; + UHD_LOGGER_INFO("USRP2") << "Success! "; return; } } diff --git a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp index 9cd3afc6c..cdd26bbc4 100644 --- a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp +++ b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp @@ -17,7 +17,7 @@ #include "usrp2_regs.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/vrt_if_packet.hpp> #include "usrp2_fifo_ctrl.hpp" diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 100cec867..ce547bad0 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -20,7 +20,7 @@ #include "fw_common.h" #include "usrp2_iface.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/paths.hpp> @@ -268,10 +268,10 @@ public: return ctrl_send_and_recv_internal(out_data, lo, hi, CTRL_RECV_TIMEOUT/CTRL_RECV_RETRIES); } catch(const timeout_error &e){ - UHD_MSG(error) + UHD_LOGGER_ERROR("USRP2") << "Control packet attempt " << i << ", sequence number " << _ctrl_seq_num - << ":\n" << e.what() << std::endl; + << ":\n" << e.what() ; } } throw uhd::runtime_error("link dead: timeout waiting for control packet ACK"); diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 24756f0ef..7d8f59fb8 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -19,7 +19,7 @@ #include "fw_common.h" #include "apply_corrections.hpp" #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/exception.hpp> #include <uhd/transport/if_addrs.hpp> #include <uhd/transport/udp_zero_copy.hpp> @@ -105,7 +105,7 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ udp_transport = udp_simple::make_broadcast(hint["addr"], BOOST_STRINGIZE(USRP2_UDP_CTRL_PORT)); } catch(const std::exception &e){ - UHD_MSG(error) << boost::format("Cannot open UDP transport on %s\n%s") % hint["addr"] % e.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << boost::format("Cannot open UDP transport on %s\n%s") % hint["addr"] % e.what() ; return usrp2_addrs; //dont throw, but return empty address so caller can insert } @@ -119,11 +119,11 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ } catch(const std::exception &ex) { - UHD_MSG(error) << "USRP2 Network discovery error " << ex.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << "USRP2 Network discovery error " << ex.what() ; } catch(...) { - UHD_MSG(error) << "USRP2 Network discovery unknown error " << std::endl; + UHD_LOGGER_ERROR("USRP2") << "USRP2 Network discovery unknown error " ; } //loop and recieve until the timeout @@ -318,7 +318,7 @@ static zero_copy_if::sptr make_xport( usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : device_addr(_device_addr) { - UHD_MSG(status) << "Opening a USRP2/N-Series device..." << std::endl; + UHD_LOGGER_INFO("USRP2") << "Opening a USRP2/N-Series device..."; //setup the dsp transport hints (default to a large recv buff) if (not device_addr.has_key("recv_buff_size")){ @@ -355,8 +355,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu); device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu); - UHD_MSG(status) << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; - UHD_MSG(status) << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + UHD_LOGGER_INFO("USRP2") << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu; + UHD_LOGGER_INFO("USRP2") << boost::format("Current send frame size: %d bytes") % mtu.send_mtu; } catch(const uhd::not_implemented_error &){ //just ignore this error, makes older fw work... @@ -411,7 +411,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : // handle case where the MB EEPROM is not programmed if (fpga_major == USRP2_FPGA_COMPAT_NUM or fpga_major == N200_FPGA_COMPAT_NUM) { - UHD_MSG(warning) << "Unable to identify device - assuming USRP2/N-Series device" << std::endl; + UHD_LOGGER_WARNING("USRP2") << "Unable to identify device - assuming USRP2/N-Series device" ; expected_fpga_compat_num = fpga_major; } } @@ -432,19 +432,19 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //////////////////////////////////////////////////////////////// // construct transports for RX and TX DSPs //////////////////////////////////////////////////////////////// - UHD_LOG << "Making transport for RX DSP0..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for RX DSP0..." ; _mbc[mb].rx_dsp_xports.push_back(make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_RX_DSP0_PORT), device_args_i, "recv" )); - UHD_LOG << "Making transport for RX DSP1..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for RX DSP1..." ; _mbc[mb].rx_dsp_xports.push_back(make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_RX_DSP1_PORT), device_args_i, "recv" )); - UHD_LOG << "Making transport for TX DSP0..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for TX DSP0..." ; _mbc[mb].tx_dsp_xport = make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_TX_DSP0_PORT), device_args_i, "send" ); - UHD_LOG << "Making transport for Control..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for Control..." ; _mbc[mb].fifo_ctrl_xport = make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_FIFO_CRTL_PORT), device_addr_t(), "" ); @@ -535,14 +535,14 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //otherwise if not disabled, look for the internal GPSDO if (_mbc[mb].iface->peekfw(U2_FW_REG_HAS_GPSDO) != dont_look_for_gpsdo) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("USRP2") << "Detecting internal GPSDO.... "; try{ _mbc[mb].gps = gps_ctrl::make(udp_simple::make_uart(udp_simple::make_connected( addr, BOOST_STRINGIZE(USRP2_UDP_UART_GPS_PORT) ))); } catch(std::exception &e){ - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << "An error occurred making GPSDO control: " << e.what() ; } if (_mbc[mb].gps and _mbc[mb].gps->gps_detected()) { @@ -777,7 +777,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //GPS installed: use external ref, time, and init time spec if (_mbc[mb].gps and _mbc[mb].gps->gps_detected()){ _mbc[mb].time64->enable_gpsdo(); - UHD_MSG(status) << "Setting references to the internal GPSDO" << std::endl; + UHD_LOGGER_INFO("USRP2") << "Setting references to the internal GPSDO" ; _tree->access<std::string>(root / "time_source/value").set("gpsdo"); _tree->access<std::string>(root / "clock_source/value").set("gpsdo"); } diff --git a/host/lib/usrp/x300/x300_adc_dac_utils.cpp b/host/lib/usrp/x300/x300_adc_dac_utils.cpp index 6fd0ca50b..fda0bb6c9 100644 --- a/host/lib/usrp/x300/x300_adc_dac_utils.cpp +++ b/host/lib/usrp/x300/x300_adc_dac_utils.cpp @@ -147,7 +147,7 @@ void x300_impl::self_test_adcs(mboard_members_t& mb, uint32_t ramp_time_ms) { void x300_impl::extended_adc_test(mboard_members_t& mb, double duration_s) { static const size_t SECS_PER_ITER = 5; - UHD_MSG(status) << boost::format("Running Extended ADC Self-Test (Duration=%.0fs, %ds/iteration)...\n") + UHD_LOGGER_INFO("X300") << boost::format("Running Extended ADC Self-Test (Duration=%.0fs, %ds/iteration)...") % duration_s % SECS_PER_ITER; size_t num_iters = static_cast<size_t>(ceil(duration_s/SECS_PER_ITER)); @@ -159,18 +159,18 @@ void x300_impl::extended_adc_test(mboard_members_t& mb, double duration_s) time_strm.imbue(std::locale(std::locale::classic(), facet)); time_strm << boost::posix_time::second_clock::local_time(); //Run self-test - UHD_MSG(status) << boost::format("-- [%s] Iteration %06d... ") % time_strm.str() % (iter+1); + UHD_LOGGER_INFO("X300") << boost::format("Running ADC Test Iteration %06d... ") % (iter+1); try { self_test_adcs(mb, SECS_PER_ITER*1000); - UHD_MSG(status) << "passed" << std::endl; + UHD_LOGGER_INFO("X300") << boost::format("ADC Test Iteration %06d passed") % (iter+1); } catch(std::exception &e) { num_failures++; - UHD_MSG(status) << e.what() << std::endl; + UHD_LOGGER_ERROR("X300") << e.what(); } } if (num_failures == 0) { - UHD_MSG(status) << "Extended ADC Self-Test PASSED\n"; + UHD_LOGGER_INFO("X300") << "Extended ADC Self-Test PASSED"; } else { throw uhd::runtime_error( (boost::format("Extended ADC Self-Test FAILED!!! (%d/%d failures)\n") % num_failures % num_iters).str()); @@ -184,7 +184,7 @@ void x300_impl::extended_adc_test(mboard_members_t& mb, double duration_s) void x300_impl::self_cal_adc_capture_delay(mboard_members_t& mb, const size_t radio_i, bool print_status) { radio_perifs_t& perif = mb.radio_perifs[radio_i]; - if (print_status) UHD_MSG(status) << "Running ADC capture delay self-cal..." << std::flush; + if (print_status) UHD_LOGGER_INFO("X300") << "Running ADC capture delay self-cal..."; static const uint32_t NUM_DELAY_STEPS = 32; //The IDELAYE2 element has 32 steps static const uint32_t NUM_RETRIES = 2; //Retry self-cal if it fails in warmup situations @@ -247,7 +247,7 @@ void x300_impl::self_cal_adc_capture_delay(mboard_members_t& mb, const size_t ra } } } - //UHD_MSG(status) << (boost::format("CapTap=%d, Error=%d\n") % dly_tap % err_code); + //UHD_LOGGER_INFO("X300") << (boost::format("CapTap=%d, Error=%d") % dly_tap % err_code); } //Retry the self-cal if it fails @@ -277,13 +277,13 @@ void x300_impl::self_cal_adc_capture_delay(mboard_members_t& mb, const size_t ra if (print_status) { double tap_delay = (1.0e12 / mb.clock->get_master_clock_rate()) / (2*32); //in ps - UHD_MSG(status) << boost::format(" done (Tap=%d, Window=%d, TapDelay=%.3fps, Iter=%d)\n") % ideal_tap % (win_stop-win_start) % tap_delay % iter; + UHD_LOGGER_INFO("X300") << boost::format(" ADC capture delay self-cal done (Tap=%d, Window=%d, TapDelay=%.3fps, Iter=%d)") % ideal_tap % (win_stop-win_start) % tap_delay % iter; } } double x300_impl::self_cal_adc_xfer_delay(mboard_members_t& mb, bool apply_delay) { - UHD_MSG(status) << "Running ADC transfer delay self-cal: " << std::flush; + UHD_LOGGER_INFO("X300") << "Running ADC transfer delay self-cal: "; //Effective resolution of the self-cal. static const size_t NUM_DELAY_STEPS = 100; @@ -293,7 +293,6 @@ double x300_impl::self_cal_adc_xfer_delay(mboard_members_t& mb, bool apply_delay double delay_range = 2 * master_clk_period; double delay_incr = delay_range / NUM_DELAY_STEPS; - UHD_MSG(status) << "Measuring..." << std::flush; double cached_clk_delay = mb.clock->get_clock_delay(X300_CLOCK_WHICH_ADC0); double fpga_clk_delay = mb.clock->get_clock_delay(X300_CLOCK_WHICH_FPGA); @@ -339,7 +338,7 @@ double x300_impl::self_cal_adc_xfer_delay(mboard_members_t& mb, bool apply_delay err_code += 100; //Increment error code by 100 to indicate no lock } } - //UHD_MSG(status) << (boost::format("XferDelay=%fns, Error=%d\n") % delay % err_code); + //UHD_LOGGER_INFO("X300") << (boost::format("XferDelay=%fns, Error=%d") % delay % err_code); results.push_back(std::pair<double,bool>(delay, err_code==0)); } @@ -391,7 +390,6 @@ double x300_impl::self_cal_adc_xfer_delay(mboard_members_t& mb, bool apply_delay } if (apply_delay) { - UHD_MSG(status) << "Validating..." << std::flush; //Apply delay win_center = mb.clock->set_clock_delay(X300_CLOCK_WHICH_ADC0, win_center); //Sets ADC0 and ADC1 wait_for_clk_locked(mb, fw_regmap_t::clk_status_reg_t::LMK_LOCK, 0.1); @@ -407,7 +405,7 @@ double x300_impl::self_cal_adc_xfer_delay(mboard_members_t& mb, bool apply_delay mb.radio_perifs[r].adc->set_test_word("normal", "normal"); mb.radio_perifs[r].regmap->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 0); } - UHD_MSG(status) << (boost::format(" done (FPGA->ADC=%.3fns%s, Window=%.3fns)\n") % + UHD_LOGGER_INFO("X300") << (boost::format("ADC transfer delay self-cal done (FPGA->ADC=%.3fns%s, Window=%.3fns)") % (win_center-fpga_clk_delay) % (cycle_slip?" +cyc":"") % win_length); return win_center; diff --git a/host/lib/usrp/x300/x300_clock_ctrl.cpp b/host/lib/usrp/x300/x300_clock_ctrl.cpp index b8b100ceb..7307bcc66 100644 --- a/host/lib/usrp/x300/x300_clock_ctrl.cpp +++ b/host/lib/usrp/x300/x300_clock_ctrl.cpp @@ -303,9 +303,8 @@ public: //be close to what the client requested. } - UHD_LOGV(often) - << boost::format("x300_clock_ctrl::set_clock_delay: Which=%d, Requested=%f, Digital Taps=%d, Half Shift=%d, Analog Delay=%d (%s), Coerced Delay=%fns" - ) % which % delay_ns % ddly_value % (half_shift_en?"ON":"OFF") % ((int)adly_value) % (adly_en?"ON":"OFF") % coerced_delay << std::endl; + UHD_LOG_DEBUG("X300", boost::format("x300_clock_ctrl::set_clock_delay: Which=%d, Requested=%f, Digital Taps=%d, Half Shift=%d, Analog Delay=%d (%s), Coerced Delay=%fns" + ) % which % delay_ns % ddly_value % (half_shift_en?"ON":"OFF") % ((int)adly_value) % (adly_en?"ON":"OFF") % coerced_delay) //Apply settings switch (which) diff --git a/host/lib/usrp/x300/x300_dac_ctrl.cpp b/host/lib/usrp/x300/x300_dac_ctrl.cpp index eb36f0798..51b93662c 100644 --- a/host/lib/usrp/x300/x300_dac_ctrl.cpp +++ b/host/lib/usrp/x300/x300_dac_ctrl.cpp @@ -18,10 +18,10 @@ #include "x300_dac_ctrl.hpp" #include "x300_regs.hpp" #include <uhd/types/time_spec.hpp> -#include <uhd/utils/msg.hpp> #include <uhd/utils/log.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/exception.hpp> +#include <boost/format.hpp> #include <boost/thread/thread.hpp> //sleep #define X300_DAC_FRONTEND_SYNC_FAILURE_FATAL @@ -242,7 +242,7 @@ public: if (failure_is_fatal) { throw uhd::runtime_error(msg); } else { - UHD_MSG(warning) << msg; + UHD_LOGGER_WARNING("X300") << msg; } } } diff --git a/host/lib/usrp/x300/x300_fw_ctrl.cpp b/host/lib/usrp/x300/x300_fw_ctrl.cpp index 080d235a4..1df0fa611 100644 --- a/host/lib/usrp/x300/x300_fw_ctrl.cpp +++ b/host/lib/usrp/x300/x300_fw_ctrl.cpp @@ -19,7 +19,7 @@ #include "x300_fw_common.h" #include <uhd/transport/udp_simple.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/thread/mutex.hpp> @@ -61,7 +61,7 @@ public: { std::string error_msg = str(boost::format( "x300 fw communication failure #%u\n%s") % i % ex.what()); - if (errors) UHD_MSG(error) << error_msg << std::endl; + if (errors) UHD_LOGGER_ERROR("X300") << error_msg ; if (i == num_retries) throw uhd::io_error(error_msg); } } @@ -81,7 +81,7 @@ public: { std::string error_msg = str(boost::format( "x300 fw communication failure #%u\n%s") % i % ex.what()); - if (errors) UHD_MSG(error) << error_msg << std::endl; + if (errors) UHD_LOGGER_ERROR("X300") << error_msg ; if (i == num_retries) throw uhd::io_error(error_msg); } } diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp index 593873569..83a564997 100644 --- a/host/lib/usrp/x300/x300_fw_uart.cpp +++ b/host/lib/usrp/x300/x300_fw_uart.cpp @@ -18,7 +18,7 @@ #include "x300_impl.hpp" #include <uhd/types/wb_iface.hpp> #include "x300_regs.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/serial.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 13d1d6adc..07b0582d0 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -23,7 +23,7 @@ #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/usrp/subdev_spec.hpp> @@ -309,11 +309,11 @@ device_addrs_t x300_find(const device_addr_t &hint_) } catch(const std::exception &ex) { - UHD_MSG(error) << "X300 Network discovery error " << ex.what() << std::endl; + UHD_LOGGER_ERROR("X300") << "X300 Network discovery error " << ex.what() ; } catch(...) { - UHD_MSG(error) << "X300 Network discovery unknown error " << std::endl; + UHD_LOGGER_ERROR("X300") << "X300 Network discovery unknown error " ; } return reply_addrs; } @@ -357,7 +357,7 @@ UHD_STATIC_BLOCK(register_x300_device) static void x300_load_fw(wb_iface::sptr fw_reg_ctrl, const std::string &file_name) { - UHD_MSG(status) << "Loading firmware " << file_name << std::flush; + UHD_LOGGER_INFO("X300") << "Loading firmware " << file_name; //load file into memory std::ifstream fw_file(file_name.c_str()); @@ -372,45 +372,18 @@ static void x300_load_fw(wb_iface::sptr fw_reg_ctrl, const std::string &file_nam //@TODO: FIXME: Since x300_ctrl_iface acks each write and traps exceptions, the first try for the last word // written will print an error because it triggers a FW reload and fails to reply. fw_reg_ctrl->poke32(SR_ADDR(BOOT_LDR_BASE, BL_DATA), uhd::byteswap(fw_file_buff[i/sizeof(uint32_t)])); - if ((i & 0x1fff) == 0) UHD_MSG(status) << "." << std::flush; } //Wait for fimrware to reboot. 3s is an upper bound boost::this_thread::sleep(boost::posix_time::milliseconds(3000)); - UHD_MSG(status) << " done!" << std::endl; -} - -static const std::string thread_final_msg = "Finished multi-threaded initialization\n"; - -static void thread_msg_handler(uhd::msg::type_t type, const std::string &msg) -{ - static boost::mutex msg_mutex; - boost::mutex::scoped_lock lock(msg_mutex); - - typedef std::pair<uhd::msg::type_t, std::string> msg_pair_t; - typedef std::map<boost::thread::id, std::vector<msg_pair_t> > thread_map_t; - - static thread_map_t thread_list; - thread_list[boost::this_thread::get_id()].push_back(msg_pair_t(type, msg)); - - if (msg == thread_final_msg) - { - for(const thread_map_t::value_type &thread_pair: thread_list) - { - for(const msg_pair_t &msg_pair: thread_pair.second) - { - // Forward the message to the default handler - uhd::msg::default_msg_handler(msg_pair.first, msg_pair.second); - } - } - } + UHD_LOGGER_INFO("X300") << "Firmware loaded!" ; } x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) : device3_impl() , _sid_framer(0) { - UHD_MSG(status) << "X300 initialization sequence..." << std::endl; + UHD_LOGGER_INFO("X300") << "X300 initialization sequence..."; _ignore_cal_file = dev_addr.has_key("ignore-cal-file"); _tree->create<std::string>("/name").set("X-Series Device"); @@ -426,9 +399,6 @@ x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) return; } - // Setup a custom messenger handler - uhd::msg::handler_t current_handler = uhd::msg::get_handler(); - uhd::msg::register_handler(&thread_msg_handler); // Initialize groups of USRPs in parallel size_t total_usrps = device_args.size(); @@ -448,9 +418,6 @@ x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) num_usrps += init_usrps; } - // restore the original message handler - UHD_MSG(status) << thread_final_msg; - uhd::msg::register_handler(current_handler); } void x300_impl::mboard_members_t::discover_eth( @@ -468,7 +435,7 @@ void x300_impl::mboard_members_t::discover_eth( // Show a warning if there exists duplicate addresses in the mboard eeprom if (std::find(mb_eeprom_addrs.begin(), mb_eeprom_addrs.end(), mb_eeprom[key]) != mb_eeprom_addrs.end()) { - UHD_MSG(warning) << str(boost::format( + UHD_LOGGER_WARNING("X300") << str(boost::format( "Duplicate IP address %s found in mboard EEPROM. " "Device may not function properly.\nView and reprogram the values " "using the usrp_burn_mb_eeprom utility.\n") % mb_eeprom[key]); @@ -498,7 +465,7 @@ void x300_impl::mboard_members_t::discover_eth( // Check default IP addresses if we couldn't // determine the IP from the mboard eeprom if (conn_iface.type == X300_IFACE_NONE) { - UHD_MSG(warning) << str(boost::format( + UHD_LOGGER_WARNING("X300") << str(boost::format( "Address %s not found in mboard EEPROM. Address may be wrong or " "the EEPROM may be corrupt.\n Attempting to continue with default " "IP addresses.\n") % conn_iface.addr @@ -568,8 +535,6 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) "Thread ID " + thread_id + " for motherboard " + boost::lexical_cast<std::string>(mb_i) ); - UHD_MSG(status) << std::endl; - UHD_MSG(status) << thread_msg << std::endl; std::vector<std::string> eth_addrs; // Not choosing eth0 based on resource might cause user issues @@ -602,7 +567,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) if (dev_addr.has_key("niusrpriorpc_port")) { rpc_port_name = dev_addr["niusrpriorpc_port"]; } - UHD_MSG(status) << boost::format("Connecting to niusrpriorpc at localhost:%s...\n") % rpc_port_name; + UHD_LOGGER_INFO("X300") << boost::format("Connecting to niusrpriorpc at localhost:%s...") % rpc_port_name; //Instantiate the correct lvbitx object nifpga_lvbitx::sptr lvbitx; @@ -619,7 +584,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) drivers have loaded successfully."); } //Load the lvbitx onto the device - UHD_MSG(status) << boost::format("Using LVBITX bitfile %s...\n") % lvbitx->get_bitfile_path(); + UHD_LOGGER_INFO("X300") << boost::format("Using LVBITX bitfile %s...") % lvbitx->get_bitfile_path(); mb.rio_fpga_interface.reset(new niusrprio_session(dev_addr["resource"], rpc_port_name)); nirio_status_chain(mb.rio_fpga_interface->open(lvbitx, dev_addr.has_key("download-fpga")), status); nirio_status_to_exception(status, "x300_impl: Could not initialize RIO session."); @@ -692,33 +657,33 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) ); } } catch(std::exception &e) { - UHD_MSG(error) << e.what() << std::endl; + UHD_LOGGER_ERROR("X300") << e.what() ; } if ((mb.recv_args.has_key("recv_frame_size")) && (req_max_frame_size.recv_frame_size > _max_frame_sizes.recv_frame_size)) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("X300") << boost::format("You requested a receive frame size of (%lu) but your NIC's max frame size is (%lu).") % req_max_frame_size.recv_frame_size % _max_frame_sizes.recv_frame_size - << std::endl + << boost::format("Please verify your NIC's MTU setting using '%s' or set the recv_frame_size argument appropriately.") - % mtu_tool << std::endl + % mtu_tool << "UHD will use the auto-detected max frame size for this connection." - << std::endl; + ; } if ((mb.recv_args.has_key("send_frame_size")) && (req_max_frame_size.send_frame_size > _max_frame_sizes.send_frame_size)) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("X300") << boost::format("You requested a send frame size of (%lu) but your NIC's max frame size is (%lu).") % req_max_frame_size.send_frame_size % _max_frame_sizes.send_frame_size - << std::endl + << boost::format("Please verify your NIC's MTU setting using '%s' or set the send_frame_size argument appropriately.") - % mtu_tool << std::endl + % mtu_tool << "UHD will use the auto-detected max frame size for this connection." - << std::endl; + ; } _tree->create<size_t>(mb_path / "mtu/recv").set(_max_frame_sizes.recv_frame_size); @@ -727,7 +692,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) } //create basic communication - UHD_MSG(status) << "Setup basic communication..." << std::endl; + UHD_LOGGER_INFO("X300") << "Setup basic communication..."; if (mb.xport_path == "nirio") { boost::mutex::scoped_lock(pcie_zpu_iface_registry_mutex); if (get_pcie_zpu_iface_registry().has_key(mb.get_pri_eth().addr)) { @@ -787,11 +752,10 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) const uint32_t nbor_addr = mb.zpu_ctrl->peek32(SR_ADDR(routes_addr, i*2+1)); if (node_addr != 0 and nbor_addr != 0) { - UHD_MSG(status) << boost::format("%u: %s -> %s") + UHD_LOGGER_INFO("X300") << boost::format("%u: %s -> %s") % i % asio::ip::address_v4(node_addr).to_string() - % asio::ip::address_v4(nbor_addr).to_string() - << std::endl; + % asio::ip::address_v4(nbor_addr).to_string(); } } */ @@ -799,11 +763,11 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) //////////////////////////////////////////////////////////////////// // setup the mboard eeprom //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Loading values from EEPROM..." << std::endl; + UHD_LOGGER_INFO("X300") << "Loading values from EEPROM..."; x300_mb_eeprom_iface::sptr eeprom16 = x300_mb_eeprom_iface::make(mb.zpu_ctrl, mb.zpu_i2c); if (dev_addr.has_key("blank_eeprom")) { - UHD_MSG(warning) << "Obliterating the motherboard EEPROM..." << std::endl; + UHD_LOGGER_WARNING("X300") << "Obliterating the motherboard EEPROM..." ; eeprom16->write_eeprom(0x50, 0, byte_vector_t(256, 0xff)); } const mboard_eeprom_t mb_eeprom(*eeprom16, "X300"); @@ -813,9 +777,9 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) bool recover_mb_eeprom = dev_addr.has_key("recover_mb_eeprom"); if (recover_mb_eeprom) { - UHD_MSG(warning) << "UHD is operating in EEPROM Recovery Mode which disables hardware version " + UHD_LOGGER_WARNING("X300") << "UHD is operating in EEPROM Recovery Mode which disables hardware version " "checks.\nOperating in this mode may cause hardware damage and unstable " - "radio performance!"<< std::endl; + "radio performance!"; } //////////////////////////////////////////////////////////////////// @@ -895,7 +859,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) //////////////////////////////////////////////////////////////////// // create clock control objects //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Setup RF frontend clocking..." << std::endl; + UHD_LOGGER_INFO("X300") << "Setup RF frontend clocking..."; //Initialize clock control registers. NOTE: This does not configure the LMK yet. mb.clock = x300_clock_ctrl::make(mb.zpu_spi, @@ -917,8 +881,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) .set_publisher(boost::bind(&x300_clock_ctrl::get_master_clock_rate, mb.clock)) ; - UHD_MSG(status) << "Radio 1x clock:" << (mb.clock->get_master_clock_rate()/1e6) - << std::endl; + UHD_LOGGER_INFO("X300") << "Radio 1x clock:" << (mb.clock->get_master_clock_rate()/1e6); //////////////////////////////////////////////////////////////////// // Create the GPSDO control @@ -928,14 +891,14 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) //otherwise if not disabled, look for the internal GPSDO if (mb.zpu_ctrl->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_GPSDO_STATUS)) != dont_look_for_gpsdo) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("X300") << "Detecting internal GPSDO.... "; try { mb.gps = gps_ctrl::make(x300_make_uart_iface(mb.zpu_ctrl)); } catch(std::exception &e) { - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("X300") << "An error occurred making GPSDO control: " << e.what() ; } if (mb.gps and mb.gps->gps_detected()) { @@ -1018,7 +981,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) find_blocks<rfnoc::x300_radio_ctrl_impl>(radio_blockid_hint); if (not radio_ids.empty()) { if (radio_ids.size() > 2) { - UHD_MSG(warning) << "Too many Radio Blocks found. Using only the first two." << std::endl; + UHD_LOGGER_WARNING("X300") << "Too many Radio Blocks found. Using only the first two." ; radio_ids.resize(2); } @@ -1060,7 +1023,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) } } else { - UHD_MSG(status) << "No Radio Block found. Assuming radio-less operation." << std::endl; + UHD_LOGGER_INFO("X300") << "No Radio Block found. Assuming radio-less operation."; } /* end of radio block(s) initialization */ mb.initialization_done = true; @@ -1103,8 +1066,8 @@ uint32_t x300_impl::mboard_members_t::allocate_pcie_dma_chan(const uhd::sid_t &t if (_dma_chan_pool.count(raw_sid) == 0) { _dma_chan_pool[raw_sid] = _dma_chan_pool.size() + FIRST_DATA_CHANNEL; - UHD_LOG << "[X300] Assigning PCIe DMA channel " << _dma_chan_pool[raw_sid] - << " to SID " << tx_sid.to_pp_string_hex() << std::endl; + UHD_LOGGER_DEBUG("X300") << "[X300] Assigning PCIe DMA channel " << _dma_chan_pool[raw_sid] + << " to SID " << tx_sid.to_pp_string_hex() ; } if (_dma_chan_pool.size() + FIRST_DATA_CHANNEL > X300_PCIE_MAX_CHANNELS) { @@ -1239,23 +1202,23 @@ uhd::both_xports_t x300_impl::make_transport( /* Print a warning if the system's max available frame size is less than the most optimal * frame size for this type of connection. */ if (_max_frame_sizes.send_frame_size < eth_data_rec_frame_size) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("X300") << boost::format("For this connection, UHD recommends a send frame size of at least %lu for best\nperformance, but your system's MTU will only allow %lu.") % eth_data_rec_frame_size % _max_frame_sizes.send_frame_size - << std::endl + << "This will negatively impact your maximum achievable sample rate." - << std::endl; + ; } if (_max_frame_sizes.recv_frame_size < eth_data_rec_frame_size) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("X300") << boost::format("For this connection, UHD recommends a receive frame size of at least %lu for best\nperformance, but your system's MTU will only allow %lu.") % eth_data_rec_frame_size % _max_frame_sizes.recv_frame_size - << std::endl + << "This will negatively impact your maximum achievable sample rate." - << std::endl; + ; } size_t system_max_send_frame_size = (size_t) _max_frame_sizes.send_frame_size; @@ -1313,8 +1276,8 @@ uhd::both_xports_t x300_impl::make_transport( //send a mini packet with SID into the ZPU //ZPU will reprogram the ethernet framer - UHD_LOG << "programming packet for new xport on " - << interface_addr << " sid " << xports.send_sid << std::endl; + UHD_LOGGER_DEBUG("X300") << "programming packet for new xport on " + << interface_addr << " sid " << xports.send_sid ; //YES, get a __send__ buffer from the __recv__ socket //-- this is the only way to program the framer for recv: managed_send_buffer::sptr buff = xports.recv->get_send_buff(); @@ -1324,7 +1287,7 @@ uhd::both_xports_t x300_impl::make_transport( buff.reset(); //reprogram the ethernet dispatcher's udp port (should be safe to always set) - UHD_LOG << "reprogram the ethernet dispatcher's udp port" << std::endl; + UHD_LOGGER_DEBUG("X300") << "reprogram the ethernet dispatcher's udp port" ; mb.zpu_ctrl->poke32(SR_ADDR(SET0_BASE, (ZPU_SR_ETHINT0+8+3)), X300_VITA_UDP_PORT); mb.zpu_ctrl->poke32(SR_ADDR(SET0_BASE, (ZPU_SR_ETHINT1+8+3)), X300_VITA_UDP_PORT); @@ -1356,7 +1319,7 @@ uhd::sid_t x300_impl::allocate_sid( // This type of packet does not match the XB_LOCAL address and is looked up in the lower half of the CAM mb.zpu_ctrl->poke32(SR_ADDR(SETXB_BASE, 0 + src_addr), src_dst); - UHD_LOG << "done router config for sid " << sid << std::endl; + UHD_LOGGER_DEBUG("X300") << "done router config for sid " << sid ; //increment for next setup _sid_framer++; @@ -1413,8 +1376,8 @@ void x300_impl::update_clock_source(mboard_members_t &mb, const std::string &sou throw uhd::runtime_error((boost::format("Reference Clock PLL failed to lock to %s source.") % source).str()); } else { //TODO: Re-enable this warning when we figure out a reliable lock time - //UHD_MSG(warning) << "Reference clock failed to lock to " + source + " during device initialization. " << - // "Check for the lock before operation or ignore this warning if using another clock source." << std::endl; + //UHD_LOGGER_WARNING("X300") << "Reference clock failed to lock to " + source + " during device initialization. " << + // "Check for the lock before operation or ignore this warning if using another clock source." ; } } } @@ -1632,7 +1595,7 @@ x300_impl::frame_size_t x300_impl::determine_max_frame_size(const std::string &a size_t min_send_frame_size = sizeof(x300_mtu_t); size_t max_send_frame_size = std::min(user_frame_size.send_frame_size, X300_10GE_DATA_FRAME_MAX_SIZE) & size_t(~3); - UHD_MSG(status) << "Determining maximum frame size... "; + UHD_LOGGER_INFO("X300") << "Determining maximum frame size... "; while (min_recv_frame_size < max_recv_frame_size) { size_t test_frame_size = (max_recv_frame_size/2 + min_recv_frame_size/2 + 3) & ~3; @@ -1681,7 +1644,7 @@ x300_impl::frame_size_t x300_impl::determine_max_frame_size(const std::string &a // of the recv and send frame sizes. frame_size.recv_frame_size = std::min(min_recv_frame_size, min_send_frame_size); frame_size.send_frame_size = std::min(min_recv_frame_size, min_send_frame_size); - UHD_MSG(status) << frame_size.send_frame_size << " bytes." << std::endl; + UHD_LOGGER_INFO("X300") << "Maximim frame size: " << frame_size.send_frame_size << " bytes."; return frame_size; } @@ -1862,7 +1825,7 @@ x300_impl::x300_mboard_t x300_impl::get_mb_type_from_eeprom(const uhd::usrp::mbo case X310_2955R_PCIE_SSID_ADC_18: mb_type = USRP_X310_MB; break; default: - UHD_MSG(warning) << "X300 unknown product code in EEPROM: " << product_num << std::endl; + UHD_LOGGER_WARNING("X300") << "X300 unknown product code in EEPROM: " << product_num ; mb_type = UNKNOWN; break; } } diff --git a/host/lib/usrp/x300/x300_io_impl.cpp b/host/lib/usrp/x300/x300_io_impl.cpp index 4dd9dce8a..eeff4091f 100644 --- a/host/lib/usrp/x300/x300_io_impl.cpp +++ b/host/lib/usrp/x300/x300_io_impl.cpp @@ -25,7 +25,6 @@ #include <boost/bind.hpp> #include <uhd/utils/tasks.hpp> #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> #include <boost/make_shared.hpp> using namespace uhd; @@ -82,7 +81,7 @@ void x300_impl::post_streamer_hooks(direction_t dir) std::vector<rfnoc::x300_radio_ctrl_impl::sptr> radio_ctrl_blks = streamer->get_terminator()->find_downstream_node<rfnoc::x300_radio_ctrl_impl>(); try { - //UHD_MSG(status) << "[X300] syncing " << radio_ctrl_blks.size() << " radios " << std::endl; + //UHD_LOGGER_INFO("X300") << "[X300] syncing " << radio_ctrl_blks.size() << " radios " ; rfnoc::x300_radio_ctrl_impl::synchronize_dacs(radio_ctrl_blks); } catch(const uhd::io_error &ex) { diff --git a/host/lib/usrp/x300/x300_mb_eeprom.cpp b/host/lib/usrp/x300/x300_mb_eeprom.cpp index e39b36af8..084685991 100644 --- a/host/lib/usrp/x300/x300_mb_eeprom.cpp +++ b/host/lib/usrp/x300/x300_mb_eeprom.cpp @@ -33,7 +33,7 @@ #include "x300_impl.hpp" #include <uhd/exception.hpp> #include <uhd/utils/platform.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/byteswap.hpp> #include <boost/thread.hpp> diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp index 31a977884..90cb20ce3 100644 --- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp +++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp @@ -22,7 +22,7 @@ #include "gpio_atr_3000.hpp" #include "apply_corrections.hpp" #include <uhd/usrp/dboard_eeprom.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/usrp/dboard_iface.hpp> #include <uhd/rfnoc/node_ctrl_base.hpp> #include <uhd/transport/chdr.hpp> @@ -44,7 +44,7 @@ static const size_t IO_MASTER_RADIO = 0; UHD_RFNOC_RADIO_BLOCK_CONSTRUCTOR(x300_radio_ctrl) , _ignore_cal_file(false) { - UHD_RFNOC_BLOCK_TRACE() << "x300_radio_ctrl_impl::ctor() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "x300_radio_ctrl_impl::ctor() " ; //////////////////////////////////////////////////////////////////// // Set up basic info @@ -171,7 +171,7 @@ double x300_radio_ctrl_impl::set_rate(double rate) { const double actual_rate = get_rate(); if (not uhd::math::frequencies_are_equal(rate, actual_rate)) { - UHD_MSG(warning) << "[X300 Radio] Requesting invalid sampling rate from device: " << rate/1e6 << " MHz. Actual rate is: " << actual_rate/1e6 << " MHz." << std::endl; + UHD_LOGGER_WARNING("X300 RADIO") << "Requesting invalid sampling rate from device: " << rate/1e6 << " MHz. Actual rate is: " << actual_rate/1e6 << " MHz." ; } // On X3x0, tick rate can't actually be changed at runtime return actual_rate; @@ -238,7 +238,7 @@ double x300_radio_ctrl_impl::set_tx_gain(const double gain, const size_t chan) radio_ctrl_impl::set_tx_gain(actual_gain, chan); return gain; } else { - UHD_MSG(warning) << "set_tx_gain: could not apply gain for this daughterboard."; + UHD_LOGGER_WARNING("X300 RADIO") << "set_tx_gain: could not apply gain for this daughterboard."; radio_ctrl_impl::set_tx_gain(0.0, chan); return 0.0; } @@ -254,7 +254,7 @@ double x300_radio_ctrl_impl::set_rx_gain(const double gain, const size_t chan) radio_ctrl_impl::set_rx_gain(actual_gain, chan); return gain; } else { - UHD_MSG(warning) << "set_rx_gain: could not apply gain for this daughterboard."; + UHD_LOGGER_WARNING("X300 RADIO") << "set_rx_gain: could not apply gain for this daughterboard."; radio_ctrl_impl::set_tx_gain(0.0, chan); return 0.0; } @@ -555,31 +555,26 @@ void x300_radio_ctrl_impl::self_test_adc(uint32_t ramp_time_ms) void x300_radio_ctrl_impl::extended_adc_test(const std::vector<x300_radio_ctrl_impl::sptr>& radios, double duration_s) { static const size_t SECS_PER_ITER = 5; - UHD_MSG(status) << boost::format("Running Extended ADC Self-Test (Duration=%.0fs, %ds/iteration)...\n") + UHD_LOGGER_INFO("X300 RADIO") << boost::format("Running Extended ADC Self-Test (Duration=%.0fs, %ds/iteration)...") % duration_s % SECS_PER_ITER; size_t num_iters = static_cast<size_t>(ceil(duration_s/SECS_PER_ITER)); size_t num_failures = 0; for (size_t iter = 0; iter < num_iters; iter++) { - //Print date and time - boost::posix_time::time_facet *facet = new boost::posix_time::time_facet("%d-%b-%Y %H:%M:%S"); - std::ostringstream time_strm; - time_strm.imbue(std::locale(std::locale::classic(), facet)); - time_strm << boost::posix_time::second_clock::local_time(); //Run self-test - UHD_MSG(status) << boost::format("-- [%s] Iteration %06d... ") % time_strm.str() % (iter+1); + UHD_LOGGER_INFO("X300 RADIO") << boost::format("Extended ADC Self-Test Iteration %06d... ") % (iter+1); try { for (size_t i = 0; i < radios.size(); i++) { radios[i]->self_test_adc((SECS_PER_ITER*1000)/radios.size()); } - UHD_MSG(status) << "passed" << std::endl; + UHD_LOGGER_INFO("X300 RADIO") << boost::format("Extended ADC Self-Test Iteration %06d passed ") % (iter+1); } catch(std::exception &e) { num_failures++; - UHD_MSG(status) << e.what() << std::endl; + UHD_LOGGER_ERROR("X300 RADIO") << e.what(); } } if (num_failures == 0) { - UHD_MSG(status) << "Extended ADC Self-Test PASSED\n"; + UHD_LOGGER_INFO("X300 RADIO") << "Extended ADC Self-Test PASSED"; } else { throw uhd::runtime_error( (boost::format("Extended ADC Self-Test FAILED!!! (%d/%d failures)\n") % num_failures % num_iters).str()); @@ -639,7 +634,7 @@ double x300_radio_ctrl_impl::self_cal_adc_xfer_delay( boost::function<void(double)> wait_for_clk_locked, bool apply_delay) { - UHD_MSG(status) << "Running ADC transfer delay self-cal: " << std::flush; + UHD_LOGGER_INFO("X300 RADIO") << "Running ADC transfer delay self-cal: "; //Effective resolution of the self-cal. static const size_t NUM_DELAY_STEPS = 100; @@ -649,7 +644,6 @@ double x300_radio_ctrl_impl::self_cal_adc_xfer_delay( double delay_range = 2 * master_clk_period; double delay_incr = delay_range / NUM_DELAY_STEPS; - UHD_MSG(status) << "Measuring..." << std::flush; double cached_clk_delay = clock->get_clock_delay(X300_CLOCK_WHICH_ADC0); double fpga_clk_delay = clock->get_clock_delay(X300_CLOCK_WHICH_FPGA); @@ -695,7 +689,7 @@ double x300_radio_ctrl_impl::self_cal_adc_xfer_delay( err_code += 100; //Increment error code by 100 to indicate no lock } } - //UHD_MSG(status) << (boost::format("XferDelay=%fns, Error=%d\n") % delay % err_code); + //UHD_LOGGER_INFO("X300 RADIO") << (boost::format("XferDelay=%fns, Error=%d") % delay % err_code); results.push_back(std::pair<double,bool>(delay, err_code==0)); } @@ -747,7 +741,6 @@ double x300_radio_ctrl_impl::self_cal_adc_xfer_delay( } if (apply_delay) { - UHD_MSG(status) << "Validating..." << std::flush; //Apply delay win_center = clock->set_clock_delay(X300_CLOCK_WHICH_ADC0, win_center); //Sets ADC0 and ADC1 wait_for_clk_locked(0.1); @@ -765,7 +758,7 @@ double x300_radio_ctrl_impl::self_cal_adc_xfer_delay( radios[r]->_adc->set_test_word("normal", "normal"); radios[r]->_regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 0); } - UHD_MSG(status) << (boost::format(" done (FPGA->ADC=%.3fns%s, Window=%.3fns)\n") % + UHD_LOGGER_INFO("X300 RADIO") << (boost::format("ADC transfer delay self-cal done (FPGA->ADC=%.3fns%s, Window=%.3fns)") % (win_center-fpga_clk_delay) % (cycle_slip?" +cyc":"") % win_length); return win_center; @@ -789,7 +782,7 @@ void x300_radio_ctrl_impl::_update_atr_leds(const std::string &rx_ant, const siz void x300_radio_ctrl_impl::_self_cal_adc_capture_delay(bool print_status) { - if (print_status) UHD_MSG(status) << "Running ADC capture delay self-cal..." << std::flush; + if (print_status) UHD_LOGGER_INFO("X300 RADIO") << "Running ADC capture delay self-cal..."; static const uint32_t NUM_DELAY_STEPS = 32; //The IDELAYE2 element has 32 steps static const uint32_t NUM_RETRIES = 2; //Retry self-cal if it fails in warmup situations @@ -852,7 +845,7 @@ void x300_radio_ctrl_impl::_self_cal_adc_capture_delay(bool print_status) } } } - //UHD_MSG(status) << (boost::format("CapTap=%d, Error=%d\n") % dly_tap % err_code); + //UHD_LOGGER_INFO("X300 RADIO") << (boost::format("CapTap=%d, Error=%d") % dly_tap % err_code); } //Retry the self-cal if it fails @@ -882,7 +875,7 @@ void x300_radio_ctrl_impl::_self_cal_adc_capture_delay(bool print_status) if (print_status) { double tap_delay = (1.0e12 / _radio_clk_rate) / (2*32); //in ps - UHD_MSG(status) << boost::format(" done (Tap=%d, Window=%d, TapDelay=%.3fps, Iter=%d)\n") % ideal_tap % (win_stop-win_start) % tap_delay % iter; + UHD_LOGGER_INFO("X300 RADIO") << boost::format("ADC capture delay self-cal done (Tap=%d, Window=%d, TapDelay=%.3fps, Iter=%d)") % ideal_tap % (win_stop-win_start) % tap_delay % iter; } } @@ -912,7 +905,7 @@ void x300_radio_ctrl_impl::_set_db_eeprom(i2c_iface::sptr i2c, const size_t addr ***************************************************************************/ bool x300_radio_ctrl_impl::check_radio_config() { - UHD_RFNOC_BLOCK_TRACE() << "x300_radio_ctrl_impl::check_radio_config() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "x300_radio_ctrl_impl::check_radio_config() " ; const fs_path rx_fe_path = fs_path("dboards" / _radio_slot / "rx_frontends"); for (size_t chan = 0; chan < _get_num_radios(); chan++) { if (_tree->exists(rx_fe_path / _rx_fe_map.at(chan).db_fe_name / "enabled")) { diff --git a/host/lib/usrp_clock/multi_usrp_clock.cpp b/host/lib/usrp_clock/multi_usrp_clock.cpp index 4477b045e..cc11e9f83 100644 --- a/host/lib/usrp_clock/multi_usrp_clock.cpp +++ b/host/lib/usrp_clock/multi_usrp_clock.cpp @@ -19,7 +19,7 @@ #include <uhd/usrp_clock/multi_usrp_clock.hpp> #include <uhd/usrp_clock/octoclock_eeprom.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> #include <boost/assign/list_of.hpp> @@ -91,6 +91,6 @@ multi_usrp_clock::~multi_usrp_clock(void){ * Multi USRP Clock factory function **********************************************************************/ multi_usrp_clock::sptr multi_usrp_clock::make(const device_addr_t &dev_addr){ - UHD_LOG << "multi_usrp_clock::make with args " << dev_addr.to_pp_string() << std::endl; + UHD_LOGGER_DEBUG("OCTOCLOCK") << "multi_usrp_clock::make with args " << dev_addr.to_pp_string() ; return sptr(new multi_usrp_clock_impl(dev_addr)); } diff --git a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp index 1bd798bae..4f2f44add 100644 --- a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp +++ b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp @@ -33,7 +33,7 @@ #include <uhd/usrp_clock/octoclock_eeprom.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/paths.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/static.hpp> @@ -117,10 +117,10 @@ device_addrs_t octoclock_find(const device_addr_t &hint){ udp_transport->send(boost::asio::buffer(&pkt_out, sizeof(pkt_out))); } catch(const std::exception &ex){ - UHD_MSG(error) << "OctoClock network discovery error - " << ex.what() << std::endl; + UHD_LOGGER_ERROR("OCTOCLOCK") << "OctoClock network discovery error - " << ex.what() ; } catch(...){ - UHD_MSG(error) << "OctoClock network discovery unknown error" << std::endl; + UHD_LOGGER_ERROR("OCTOCLOCK") << "OctoClock network discovery unknown error" ; } uint8_t octoclock_data[udp_simple::mtu]; @@ -186,7 +186,7 @@ UHD_STATIC_BLOCK(register_octoclock_device){ * Structors **********************************************************************/ octoclock_impl::octoclock_impl(const device_addr_t &_device_addr){ - UHD_MSG(status) << "Opening an OctoClock device..." << std::endl; + UHD_LOGGER_INFO("OCTOCLOCK") << "Opening an OctoClock device..."; _type = device::CLOCK; device_addrs_t device_args = separate_device_addr(_device_addr); // To avoid replicating sequence numbers between sessions @@ -264,9 +264,9 @@ octoclock_impl::octoclock_impl(const device_addr_t &_device_addr){ std::string asterisk = (device_args.size() > 1) ? " * " : ""; if(device_args.size() > 1){ - UHD_MSG(status) << std::endl << "Checking status of " << addr << ":" << std::endl; + UHD_LOGGER_INFO("OCTOCLOCK") << "Checking status of " << addr; } - UHD_MSG(status) << boost::format("%sDetecting internal GPSDO...") % asterisk << std::flush; + UHD_LOGGER_INFO("OCTOCLOCK") << boost::format("%sDetecting internal GPSDO...") % asterisk; _get_state(oc); if(_oc_dict[oc].state.gps_detected){ @@ -282,26 +282,23 @@ octoclock_impl::octoclock_impl(const device_addr_t &_device_addr){ else{ //If GPSDO communication failed, set gps_detected to false _oc_dict[oc].state.gps_detected = 0; - UHD_MSG(warning) << "Device reports that it has a GPSDO, but we cannot communicate with it." << std::endl; - std::cout << std::endl; + UHD_LOGGER_WARNING("OCTOCLOCK") << "Device reports that it has a GPSDO, but we cannot communicate with it."; } } catch(std::exception &e){ - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("OCTOCLOCK") << "An error occurred making GPSDO control: " << e.what(); } } - else UHD_MSG(status) << "No GPSDO found" << std::endl; - UHD_MSG(status) << boost::format("%sDetecting external reference...%s") % asterisk - % _ext_ref_detected(oc).value - << std::endl; - UHD_MSG(status) << boost::format("%sDetecting switch position...%s") % asterisk - % _switch_pos(oc).value - << std::endl; + else UHD_LOGGER_INFO("OCTOCLOCK") << "No GPSDO found"; + UHD_LOGGER_INFO("OCTOCLOCK") << boost::format("%sDetecting external reference...%s") % asterisk + % _ext_ref_detected(oc).value; + UHD_LOGGER_INFO("OCTOCLOCK") << boost::format("%sDetecting switch position...%s") % asterisk + % _switch_pos(oc).value; std::string ref = _which_ref(oc).value; - if(ref == "none") UHD_MSG(status) << boost::format("%sDevice is not using any reference") % asterisk << std::endl; - else UHD_MSG(status) << boost::format("%sDevice is using %s reference") % asterisk + if(ref == "none") UHD_LOGGER_INFO("OCTOCLOCK") << boost::format("%sDevice is not using any reference") % asterisk; + else UHD_LOGGER_INFO("OCTOCLOCK") << boost::format("%sDevice is using %s reference") % asterisk % _which_ref(oc).value - << std::endl; + ; } } diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 128d7c00a..f76c5763a 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -142,7 +142,6 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/ihex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/msg.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp ${CMAKE_CURRENT_SOURCE_DIR}/platform.cpp ${CMAKE_CURRENT_SOURCE_DIR}/static.cpp diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp index be5b55444..1a6c0407f 100644 --- a/host/lib/utils/gain_group.cpp +++ b/host/lib/utils/gain_group.cpp @@ -142,11 +142,11 @@ public: gain_bucket.at(i) += additional_gain; gain_left_to_distribute -= additional_gain; } - UHD_LOGV(often) << "gain_left_to_distribute " << gain_left_to_distribute << std::endl; + UHD_LOGGER_DEBUG("UHD") << "gain_left_to_distribute " << gain_left_to_distribute ; //now write the bucket out to the individual gain values for (size_t i = 0; i < gain_bucket.size(); i++){ - UHD_LOGV(often) << i << ": " << gain_bucket.at(i) << std::endl; + UHD_LOGGER_DEBUG("UHD") << i << ": " << gain_bucket.at(i) ; all_fcns.at(i).set_value(gain_bucket.at(i)); } } diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 4e58ce894..7fc28f122 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -16,11 +16,9 @@ // #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/paths.hpp> #include <boost/filesystem.hpp> -#include <boost/format.hpp> #include <boost/thread/mutex.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/thread/locks.hpp> @@ -37,59 +35,99 @@ namespace ip = boost::interprocess; **********************************************************************/ class log_resource_type{ public: - uhd::_log::verbosity_t level; + uhd::log::severity_level level; + uhd::log::severity_level file_level; + uhd::log::severity_level console_level; log_resource_type(void){ //file lock pointer must be null _file_lock = NULL; + //default to no file logging + this->file_logging = false; + //set the default log level - level = uhd::_log::never; + this->level = uhd::log::off; + this->file_level = uhd::log::off; + this->console_level = uhd::log::off; //allow override from macro definition - #ifdef UHD_LOG_LEVEL - _set_log_level(BOOST_STRINGIZE(UHD_LOG_LEVEL)); - #endif - - //allow override from environment variable +#ifdef UHD_LOG_MIN_LEVEL + this->level = _get_log_level(BOOST_STRINGIZE(UHD_LOG_MIN_LEVEL)); +#endif +#if defined(UHD_LOG_FILE_LEVEL) && defined(UHD_LOG_FILE_PATH) + this->file_level = _get_log_level(BOOST_STRINGIZE(UHD_LOG_FILE_LEVEL)); +#endif +#ifdef UHD_LOG_CONSOLE_LEVEL + this->console_level = _get_log_level(BOOST_STRINGIZE(UHD_LOG_CONSOLE_LEVEL)); +#endif +#ifdef UHD_LOG_FILE + this->log_file_target = BOOST_STRINGIZE(UHD_LOG_FILE); + this->file_logging = true; +#endif + + //allow override from environment variables const char * log_level_env = std::getenv("UHD_LOG_LEVEL"); - if (log_level_env != NULL) _set_log_level(log_level_env); + if (log_level_env != NULL && log_level_env[0] != '\0') this->level = _get_log_level(log_level_env); + + const char * log_file_level_env = std::getenv("UHD_LOG_FILE_LEVEL"); + if (log_file_level_env != NULL && log_file_level_env[0] != '\0') this->file_level = _get_log_level(log_file_level_env); + + const char * log_console_level_env = std::getenv("UHD_LOG_CONSOLE_LEVEL"); + if (log_console_level_env != NULL && log_console_level_env[0] != '\0') this->console_level = _get_log_level(log_console_level_env); + + const char* log_file_env = std::getenv("UHD_LOG_FILE"); + if ((log_file_env != NULL) && (log_file_env[0] != '\0')) { + this->log_file_target = log_file_env; + this->file_logging = true; + } } ~log_resource_type(void){ - boost::lock_guard<boost::mutex> lock(_mutex); - _file_stream.close(); - if (_file_lock != NULL) delete _file_lock; + if (this->file_logging){ + boost::lock_guard<boost::mutex> lock(_mutex); + _file_stream.close(); + if (_file_lock != NULL) delete _file_lock; + } } void log_to_file(const std::string &log_msg){ - boost::lock_guard<boost::mutex> lock(_mutex); - if (_file_lock == NULL){ - const std::string log_path = (fs::path(uhd::get_tmp_path()) / "uhd.log").string(); - _file_stream.open(log_path.c_str(), std::fstream::out | std::fstream::app); - _file_lock = new ip::file_lock(log_path.c_str()); + if ( this->file_logging ){ + boost::lock_guard<boost::mutex> lock(_mutex); + if (_file_lock == NULL){ + _file_stream.open(this->log_file_target.c_str(), std::fstream::out | std::fstream::app); + _file_lock = new ip::file_lock(this->log_file_target.c_str()); + } + _file_lock->lock(); + _file_stream << log_msg << std::flush; + _file_lock->unlock(); } - _file_lock->lock(); - _file_stream << log_msg << std::flush; - _file_lock->unlock(); } private: //! set the log level from a string that is either a digit or an enum name - void _set_log_level(const std::string &log_level_str){ - const uhd::_log::verbosity_t log_level_num = uhd::_log::verbosity_t(log_level_str[0]-'0'); - if (std::isdigit(log_level_str[0]) and log_level_num >= uhd::_log::always and log_level_num <= uhd::_log::never){ - this->level = log_level_num; - return; + bool file_logging; + std::string log_file_target; + uhd::log::severity_level _get_log_level(const std::string &log_level_str){ + if (std::isdigit(log_level_str[0])) { + const uhd::log::severity_level log_level_num = + uhd::log::severity_level(std::stoi(log_level_str)); + if (log_level_num >= uhd::log::trace and + log_level_num <= uhd::log::fatal) { + return log_level_num; + } } - #define if_lls_equal(name) else if(log_level_str == #name) this->level = uhd::_log::name - if_lls_equal(always); - if_lls_equal(often); - if_lls_equal(regularly); - if_lls_equal(rarely); - if_lls_equal(very_rarely); - if_lls_equal(never); + +#define if_loglevel_equal(name) \ + else if (log_level_str == #name) return uhd::log::name + if_loglevel_equal(trace); + if_loglevel_equal(debug); + if_loglevel_equal(info); + if_loglevel_equal(warning); + if_loglevel_equal(error); + if_loglevel_equal(fatal); + return uhd::log::off; } //file stream and lock: @@ -104,39 +142,55 @@ UHD_SINGLETON_FCN(log_resource_type, log_rs); * The logger object implementation **********************************************************************/ //! get the relative file path from the host directory -static std::string get_rel_file_path(const fs::path &file){ - fs::path abs_path = file.parent_path(); - fs::path rel_path = file.leaf(); - while (not abs_path.empty() and abs_path.leaf() != "host"){ - rel_path = abs_path.leaf() / rel_path; - abs_path = abs_path.parent_path(); - } - return rel_path.string(); -} +inline std::string path_to_filename(std::string path) +{ + return path.substr(path.find_last_of("/\\") + 1); +} uhd::_log::log::log( - const verbosity_t verbosity, + const uhd::log::severity_level verbosity, const std::string &file, const unsigned int line, - const std::string &function + const std::string &component, + const boost::thread::id id ) { _log_it = (verbosity >= log_rs().level); + _log_file =(verbosity >= log_rs().file_level); + _log_console = (verbosity >= log_rs().console_level); if (_log_it) { + if (_log_file){ const std::string time = pt::to_simple_string(pt::microsec_clock::local_time()); - const std::string header1 = str(boost::format("-- %s - level %d") % time % int(verbosity)); - const std::string header2 = str(boost::format("-- %s") % function).substr(0, 80); - const std::string header3 = str(boost::format("-- %s:%u") % get_rel_file_path(file) % line); - const std::string border = std::string(std::max(std::max(header1.size(), header2.size()), header3.size()), '-'); - _ss << std::endl - << border << std::endl - << header1 << std::endl - << header2 << std::endl - << header3 << std::endl - << border << std::endl + _file + << time << "," + << "0x" << id << "," + << path_to_filename(file) << ":" << line << "," + << verbosity << "," + << component << "," ; + } +#ifndef UHD_LOG_CONSOLE_DISABLE + if (_log_console){ +#ifdef UHD_LOG_CONSOLE_TIME + const std::string time = pt::to_simple_string(pt::microsec_clock::local_time()); +#endif + _console +#ifdef UHD_LOG_CONSOLE_TIME + << "[" << time << "] " +#endif +#ifdef UHD_LOG_CONSOLE_THREAD + << "[0x" << id << "] " +#endif +#ifdef UHD_LOG_CONSOLE_SRC + << "[" << path_to_filename(file) << ":" << line << "] " +#endif + << "[" << verbosity << "] " + << "[" << component << "] " + ; + } +#endif } } @@ -144,22 +198,44 @@ uhd::_log::log::~log(void) { if (not _log_it) return; - - _ss << std::endl; - try{ - log_rs().log_to_file(_ss.str()); - } - catch(const std::exception &e){ - /*! - * Critical behavior below. - * The following steps must happen in order to avoid a lock-up condition. - * This is because the message facility will call into the logging facility. - * Therefore we must disable the logger (level = never) before messaging. - */ - log_rs().level = never; - UHD_MSG(error) - << "Logging failed: " << e.what() << std::endl - << "Logging has been disabled for this process" << std::endl - ; +#ifndef UHD_LOG_CONSOLE_DISABLE + if ( _log_console ){ + std::clog << _console.str() << _ss.str() << std::endl; + } +#endif + if ( _log_file){ + _file << _ss.str() << std::endl; + try{ + log_rs().log_to_file(_file.str()); + } + catch(const std::exception &e){ + /*! + * Critical behavior below. + * The following steps must happen in order to avoid a lock-up condition. + * This is because the message facility will call into the logging facility. + * Therefore we must disable the logger (level = never) before messaging. + */ + log_rs().level = uhd::log::off; + std::cerr + << "Logging failed: " << e.what() << std::endl + << "Logging has been disabled for this process" << std::endl + ; + } + } } + +void +uhd::_log::log::set_log_level(uhd::log::severity_level level){ + log_rs().level = level; +} + +void +uhd::_log::log::set_console_level(uhd::log::severity_level level){ + log_rs().console_level = level; +} + +void +uhd::_log::log::set_file_level(uhd::log::severity_level level){ + log_rs().file_level = level; +} diff --git a/host/lib/utils/msg.cpp b/host/lib/utils/msg.cpp deleted file mode 100644 index 9a125515d..000000000 --- a/host/lib/utils/msg.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// -// Copyright 2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#include <uhd/utils/msg.hpp> -#include <uhd/utils/log.hpp> -#include <uhd/utils/static.hpp> -#include <boost/thread/mutex.hpp> -#include <boost/tokenizer.hpp> -#include <sstream> -#include <iostream> - -/*********************************************************************** - * Helper functions - **********************************************************************/ -#define tokenizer(inp, sep) \ - boost::tokenizer<boost::char_separator<char> > \ - (inp, boost::char_separator<char>(sep)) - -static void msg_to_cout(const std::string &msg){ - std::stringstream ss; - - static bool just_had_a_newline = true; - for(char ch: msg){ - if (just_had_a_newline){ - just_had_a_newline = false; - ss << "-- "; - } - if (ch == '\n'){ - just_had_a_newline = true; - } - ss << ch; - } - - std::cout << ss.str() << std::flush; -} - -static void msg_to_cerr(const std::string &title, const std::string &msg){ - std::stringstream ss; - - ss << std::endl << title << ":" << std::endl; - for(const std::string &line: tokenizer(msg, "\n")){ - ss << " " << line << std::endl; - } - - std::cerr << ss.str() << std::flush; -} - -/*********************************************************************** - * Global resources for the messenger - **********************************************************************/ -struct msg_resource_type{ - boost::mutex mutex; - uhd::msg::handler_t handler; -}; - -UHD_SINGLETON_FCN(msg_resource_type, msg_rs); - -/*********************************************************************** - * Setup the message handlers - **********************************************************************/ -void uhd::msg::register_handler(const handler_t &handler){ - boost::mutex::scoped_lock lock(msg_rs().mutex); - msg_rs().handler = handler; -} - -const uhd::msg::handler_t& uhd::msg::get_handler(){ - boost::mutex::scoped_lock lock(msg_rs().mutex); - return msg_rs().handler; -} - -void uhd::msg::default_msg_handler(uhd::msg::type_t type, const std::string &msg){ - static boost::mutex msg_mutex; - boost::mutex::scoped_lock lock(msg_mutex); - switch(type){ - case uhd::msg::fastpath: - std::cerr << msg << std::flush; - break; - - case uhd::msg::status: - msg_to_cout(msg); - UHD_LOG << "Status message" << std::endl << msg; - break; - - case uhd::msg::warning: - msg_to_cerr("UHD Warning", msg); - UHD_LOG << "Warning message" << std::endl << msg; - break; - - case uhd::msg::error: - msg_to_cerr("UHD Error", msg); - UHD_LOG << "Error message" << std::endl << msg; - break; - } -} - -UHD_STATIC_BLOCK(msg_register_default_handler){ - uhd::msg::register_handler(&uhd::msg::default_msg_handler); -} - -/*********************************************************************** - * The message object implementation - **********************************************************************/ -struct uhd::msg::_msg::impl{ - std::ostringstream ss; - type_t type; -}; - -uhd::msg::_msg::_msg(const type_t type){ - _impl = UHD_PIMPL_MAKE(impl, ()); - _impl->type = type; -} - -uhd::msg::_msg::~_msg(void){ - boost::mutex::scoped_lock lock(msg_rs().mutex); - msg_rs().handler(_impl->type, _impl->ss.str()); -} - -std::ostream & uhd::msg::_msg::operator()(void){ - return _impl->ss; -} diff --git a/host/lib/utils/tasks.cpp b/host/lib/utils/tasks.cpp index 1e8f50736..4cc28e48b 100644 --- a/host/lib/utils/tasks.cpp +++ b/host/lib/utils/tasks.cpp @@ -17,7 +17,7 @@ #include <uhd/utils/tasks.hpp> #include <uhd/utils/msg_task.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/thread/thread.hpp> #include <boost/thread/barrier.hpp> #include <exception> @@ -67,10 +67,10 @@ private: } void do_error_msg(const std::string &msg){ - UHD_MSG(error) - << "An unexpected exception was caught in a task loop." << std::endl - << "The task loop will now exit, things may not work." << std::endl - << msg << std::endl + UHD_LOGGER_ERROR("UHD") + << "An unexpected exception was caught in a task loop." + << "The task loop will now exit, things may not work." + << msg ; } @@ -162,10 +162,10 @@ private: } void do_error_msg(const std::string &msg){ - UHD_MSG(error) - << "An unexpected exception was caught in a task loop." << std::endl - << "The task loop will now exit, things may not work." << std::endl - << msg << std::endl + UHD_LOGGER_ERROR("UHD") + << "An unexpected exception was caught in a task loop." + << "The task loop will now exit, things may not work." + << msg ; } diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index 98023c5aa..084d023bf 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -16,7 +16,7 @@ // #include <uhd/utils/thread_priority.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <iostream> @@ -26,7 +26,7 @@ bool uhd::set_thread_priority_safe(float priority, bool realtime){ set_thread_priority(priority, realtime); return true; }catch(const std::exception &e){ - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("UHD") << boost::format( "Unable to set the thread priority. Performance may be negatively affected.\n" "Please see the general application notes in the manual for instructions.\n" "%s\n" diff --git a/host/lib/utils/thread_priority_c.cpp b/host/lib/utils/thread_priority_c.cpp index fe019e51d..b2de9970d 100644 --- a/host/lib/utils/thread_priority_c.cpp +++ b/host/lib/utils/thread_priority_c.cpp @@ -18,7 +18,7 @@ #include <uhd/error.h> #include <uhd/utils/thread_priority.h> #include <uhd/utils/thread_priority.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> #include <iostream> diff --git a/host/lib/version.cpp b/host/lib/version.cpp index 2b7125e55..2da261af0 100644 --- a/host/lib/version.cpp +++ b/host/lib/version.cpp @@ -17,17 +17,17 @@ #include <uhd/version.hpp> #include <uhd/utils/static.hpp> +#include <uhd/utils/log.hpp> #include <boost/version.hpp> #include <iostream> #ifndef UHD_DONT_PRINT_SYSTEM_INFO UHD_STATIC_BLOCK(print_system_info){ - std::cout + UHD_LOGGER_INFO("UHD") << BOOST_PLATFORM << "; " << BOOST_COMPILER << "; " << "Boost_" << BOOST_VERSION << "; " << "UHD_" << uhd::get_version_string() - << std::endl << std::endl ; } #endif diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index c691ce1fd..ebda2cf70 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -36,8 +36,8 @@ SET(test_sources fp_compare_delta_test.cpp fp_compare_epsilon_test.cpp gain_group_test.cpp + log_test.cpp math_test.cpp - msg_test.cpp property_test.cpp ranges_test.cpp sid_t_test.cpp diff --git a/host/tests/msg_test.cpp b/host/tests/log_test.cpp index 94b81268c..1973a83ff 100644 --- a/host/tests/msg_test.cpp +++ b/host/tests/log_test.cpp @@ -16,22 +16,21 @@ // #include <boost/test/unit_test.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <iostream> BOOST_AUTO_TEST_CASE(test_messages){ + uhd::log::set_log_level(uhd::log::info); + uhd::log::set_console_level(uhd::log::info); std::cerr << "---begin print test ---" << std::endl; - UHD_MSG(status) << - "This is a test print for a status message.\n" - "And this is the second line of the test print.\n" + UHD_LOGGER_INFO("logger_test") << + "This is a test print for a info log." ; - UHD_MSG(warning) << - "This is a test print for a warning message.\n" - "And this is the second line of the test print.\n" + UHD_LOGGER_WARNING("logger_test") << + "This is a test print for a warning log." ; - UHD_MSG(error) << - "This is a test print for an error message.\n" - "And this is the second line of the test print.\n" + UHD_LOGGER_ERROR("logger_test") << + "This is a test print for an error log." ; UHD_HERE(); const int x = 42; 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; diff --git a/tools/kitchen_sink/kitchen_sink.cpp b/tools/kitchen_sink/kitchen_sink.cpp index e17ee6437..818146927 100644 --- a/tools/kitchen_sink/kitchen_sink.cpp +++ b/tools/kitchen_sink/kitchen_sink.cpp @@ -35,7 +35,6 @@ #include <boost/thread/mutex.hpp> #include <boost/thread/condition_variable.hpp> #include <csignal> -#include <uhd/utils/msg.hpp> namespace po = boost::program_options; |