From 46ab07123d9a0fcf93855fc812afa331f849a303 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 31 Jul 2020 15:57:45 +0200 Subject: [PATCH] UHD: fix compatibility with 3.9.7 LTS --- lib/src/phy/rf/rf_uhd_generic.h | 12 ++++++++---- lib/src/phy/rf/rf_uhd_imp.cc | 13 ++++++------- lib/src/phy/rf/rf_uhd_rfnoc.h | 18 ++++++++++++++---- lib/src/phy/rf/rf_uhd_safe.h | 14 ++++++++++++-- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/lib/src/phy/rf/rf_uhd_generic.h b/lib/src/phy/rf/rf_uhd_generic.h index a013d10bd..c2766eceb 100644 --- a/lib/src/phy/rf/rf_uhd_generic.h +++ b/lib/src/phy/rf/rf_uhd_generic.h @@ -226,13 +226,17 @@ public: { UHD_SAFE_C_SAVE_ERROR(this, sensors = usrp->get_rx_sensor_names();) } - uhd_error get_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) override + uhd_error get_sensor(const std::string& sensor_name, double& sensor_value) override { - UHD_SAFE_C_SAVE_ERROR(this, sensor_value = usrp->get_mboard_sensor(sensor_name);) + UHD_SAFE_C_SAVE_ERROR(this, sensor_value = usrp->get_mboard_sensor(sensor_name).to_real();) } - uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) override + uhd_error get_sensor(const std::string& sensor_name, bool& sensor_value) override { - UHD_SAFE_C_SAVE_ERROR(this, sensor_value = usrp->get_rx_sensor(sensor_name);) + UHD_SAFE_C_SAVE_ERROR(this, sensor_value = usrp->get_mboard_sensor(sensor_name).to_bool();) + } + uhd_error get_rx_sensor(const std::string& sensor_name, bool& sensor_value) override + { + UHD_SAFE_C_SAVE_ERROR(this, sensor_value = usrp->get_rx_sensor(sensor_name).to_bool();) } uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) override { diff --git a/lib/src/phy/rf/rf_uhd_imp.cc b/lib/src/phy/rf/rf_uhd_imp.cc index 199ae3b57..a7bdcc297 100644 --- a/lib/src/phy/rf/rf_uhd_imp.cc +++ b/lib/src/phy/rf/rf_uhd_imp.cc @@ -358,14 +358,13 @@ static int set_time_to_gps_time(rf_uhd_handler_t* handler) } // Get actual sensor value - uhd::sensor_value_t sensor_value("w", "t", "f"); - if (handler->uhd->get_sensor(sensor_name, sensor_value) != UHD_ERROR_NONE) { + double frac_secs = 0.0; + if (handler->uhd->get_sensor(sensor_name, frac_secs) != UHD_ERROR_NONE) { print_usrp_error(handler); return SRSLTE_ERROR; } // Get time and set - double frac_secs = sensor_value.to_real(); printf("Setting USRP time to %fs\n", frac_secs); if (handler->uhd->set_time_unknown_pps(uhd::time_spec_t(frac_secs)) != UHD_ERROR_NONE) { print_usrp_error(handler); @@ -421,21 +420,19 @@ static int wait_sensor_locked(rf_uhd_handler_t* handler, do { // Get actual sensor value - uhd::sensor_value_t sensor_value("", true, "True", "False"); if (is_mboard) { - if (handler->uhd->get_sensor(sensor_name, sensor_value) != UHD_ERROR_NONE) { + if (handler->uhd->get_sensor(sensor_name, is_locked) != UHD_ERROR_NONE) { print_usrp_error(handler); return SRSLTE_ERROR; } } else { - if (handler->uhd->get_rx_sensor(sensor_name, sensor_value) != UHD_ERROR_NONE) { + if (handler->uhd->get_rx_sensor(sensor_name, is_locked) != UHD_ERROR_NONE) { print_usrp_error(handler); return SRSLTE_ERROR; } } // Read value and wait - is_locked = sensor_value.to_bool(); usleep(1000); // 1ms timeout -= 1; // 1ms } while (not is_locked and timeout > 0); @@ -600,6 +597,7 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) } // Logging level +#ifdef UHD_LOG_INFO uhd::log::severity_level severity_level = uhd::log::severity_level::info; if (device_addr.has_key("log_level")) { std::string log_level = device_addr.pop("log_level"); @@ -621,6 +619,7 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) } } uhd::log::set_console_level(severity_level); +#endif #if HAVE_ASYNC_THREAD bool start_async_thread = true; diff --git a/lib/src/phy/rf/rf_uhd_rfnoc.h b/lib/src/phy/rf/rf_uhd_rfnoc.h index 5fc890003..4670d2ed1 100644 --- a/lib/src/phy/rf/rf_uhd_rfnoc.h +++ b/lib/src/phy/rf/rf_uhd_rfnoc.h @@ -480,15 +480,25 @@ public: sensors = device3->get_tree()->list(TREE_RX_SENSORS); }) } - uhd_error get_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) override + uhd_error get_sensor(const std::string& sensor_name, double& sensor_value) override { UHD_SAFE_C_SAVE_ERROR( - this, sensor_value = device3->get_tree()->access(TREE_MBOARD_SENSORS / sensor_name).get();) + this, + sensor_value = + device3->get_tree()->access(TREE_MBOARD_SENSORS / sensor_name).get().to_real();) } - uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) override + uhd_error get_sensor(const std::string& sensor_name, bool& sensor_value) override { UHD_SAFE_C_SAVE_ERROR( - this, sensor_value = device3->get_tree()->access(TREE_RX_SENSORS / sensor_name).get();) + this, + sensor_value = + device3->get_tree()->access(TREE_MBOARD_SENSORS / sensor_name).get().to_bool();) + } + uhd_error get_rx_sensor(const std::string& sensor_name, bool& sensor_value) override + { + UHD_SAFE_C_SAVE_ERROR( + this, + sensor_value = device3->get_tree()->access(TREE_RX_SENSORS / sensor_name).get().to_bool();) } uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) override { diff --git a/lib/src/phy/rf/rf_uhd_safe.h b/lib/src/phy/rf/rf_uhd_safe.h index 3bd2b11ac..5c92fcd9c 100644 --- a/lib/src/phy/rf/rf_uhd_safe.h +++ b/lib/src/phy/rf/rf_uhd_safe.h @@ -21,11 +21,20 @@ #ifndef SRSLTE_RF_UHD_SAFE_H #define SRSLTE_RF_UHD_SAFE_H +#include #include + +#ifdef UHD_LOG_INFO #define Warning(message) UHD_LOG_WARNING("UHD RF", message) #define Info(message) UHD_LOG_INFO("UHD RF", message) #define Debug(message) UHD_LOG_DEBUG("UHD RF", message) #define Trace(message) UHD_LOG_TRACE("UHD RF", message) +#else +#define Warning(message) UHD_LOG << message +#define Info(message) UHD_LOG << message +#define Debug(message) UHD_LOG << message +#define Trace(message) UHD_LOG << message +#endif #ifdef ENABLE_UHD_X300_FW_RESET #include @@ -115,8 +124,9 @@ public: virtual uhd_error get_mboard_name(std::string& mboard_name) = 0; virtual uhd_error get_mboard_sensor_names(std::vector& sensors) = 0; virtual uhd_error get_rx_sensor_names(std::vector& sensors) = 0; - virtual uhd_error get_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) = 0; - virtual uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) = 0; + virtual uhd_error get_sensor(const std::string& sensor_name, double& sensor_value) = 0; + virtual uhd_error get_sensor(const std::string& sensor_name, bool& sensor_value) = 0; + virtual uhd_error get_rx_sensor(const std::string& sensor_name, bool& sensor_value) = 0; virtual uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) = 0; virtual uhd_error get_time_now(uhd::time_spec_t& timespec) = 0; uhd_error start_rx_stream(double delay)