UHD: fix compatibility with 3.9.7 LTS

master
Xavier Arteaga 5 years ago committed by Andre Puschmann
parent 0a01bd4e1b
commit 46ab07123d

@ -226,13 +226,17 @@ public:
{ {
UHD_SAFE_C_SAVE_ERROR(this, sensors = usrp->get_rx_sensor_names();) 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 uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) override
{ {

@ -358,14 +358,13 @@ static int set_time_to_gps_time(rf_uhd_handler_t* handler)
} }
// Get actual sensor value // Get actual sensor value
uhd::sensor_value_t sensor_value("w", "t", "f"); double frac_secs = 0.0;
if (handler->uhd->get_sensor(sensor_name, sensor_value) != UHD_ERROR_NONE) { if (handler->uhd->get_sensor(sensor_name, frac_secs) != UHD_ERROR_NONE) {
print_usrp_error(handler); print_usrp_error(handler);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
// Get time and set // Get time and set
double frac_secs = sensor_value.to_real();
printf("Setting USRP time to %fs\n", frac_secs); 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) { if (handler->uhd->set_time_unknown_pps(uhd::time_spec_t(frac_secs)) != UHD_ERROR_NONE) {
print_usrp_error(handler); print_usrp_error(handler);
@ -421,21 +420,19 @@ static int wait_sensor_locked(rf_uhd_handler_t* handler,
do { do {
// Get actual sensor value // Get actual sensor value
uhd::sensor_value_t sensor_value("", true, "True", "False");
if (is_mboard) { 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); print_usrp_error(handler);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} else { } 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); print_usrp_error(handler);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
// Read value and wait // Read value and wait
is_locked = sensor_value.to_bool();
usleep(1000); // 1ms usleep(1000); // 1ms
timeout -= 1; // 1ms timeout -= 1; // 1ms
} while (not is_locked and timeout > 0); } 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 // Logging level
#ifdef UHD_LOG_INFO
uhd::log::severity_level severity_level = uhd::log::severity_level::info; uhd::log::severity_level severity_level = uhd::log::severity_level::info;
if (device_addr.has_key("log_level")) { if (device_addr.has_key("log_level")) {
std::string log_level = device_addr.pop("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); uhd::log::set_console_level(severity_level);
#endif
#if HAVE_ASYNC_THREAD #if HAVE_ASYNC_THREAD
bool start_async_thread = true; bool start_async_thread = true;

@ -480,15 +480,25 @@ public:
sensors = device3->get_tree()->list(TREE_RX_SENSORS); 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( UHD_SAFE_C_SAVE_ERROR(
this, sensor_value = device3->get_tree()->access<uhd::sensor_value_t>(TREE_MBOARD_SENSORS / sensor_name).get();) this,
sensor_value =
device3->get_tree()->access<uhd::sensor_value_t>(TREE_MBOARD_SENSORS / sensor_name).get().to_real();)
}
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<uhd::sensor_value_t>(TREE_MBOARD_SENSORS / sensor_name).get().to_bool();)
} }
uhd_error get_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& sensor_value) override uhd_error get_rx_sensor(const std::string& sensor_name, bool& sensor_value) override
{ {
UHD_SAFE_C_SAVE_ERROR( UHD_SAFE_C_SAVE_ERROR(
this, sensor_value = device3->get_tree()->access<uhd::sensor_value_t>(TREE_RX_SENSORS / sensor_name).get();) this,
sensor_value = device3->get_tree()->access<uhd::sensor_value_t>(TREE_RX_SENSORS / sensor_name).get().to_bool();)
} }
uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) override uhd_error set_time_unknown_pps(const uhd::time_spec_t& timespec) override
{ {

@ -21,11 +21,20 @@
#ifndef SRSLTE_RF_UHD_SAFE_H #ifndef SRSLTE_RF_UHD_SAFE_H
#define SRSLTE_RF_UHD_SAFE_H #define SRSLTE_RF_UHD_SAFE_H
#include <set>
#include <uhd/utils/log.hpp> #include <uhd/utils/log.hpp>
#ifdef UHD_LOG_INFO
#define Warning(message) UHD_LOG_WARNING("UHD RF", message) #define Warning(message) UHD_LOG_WARNING("UHD RF", message)
#define Info(message) UHD_LOG_INFO("UHD RF", message) #define Info(message) UHD_LOG_INFO("UHD RF", message)
#define Debug(message) UHD_LOG_DEBUG("UHD RF", message) #define Debug(message) UHD_LOG_DEBUG("UHD RF", message)
#define Trace(message) UHD_LOG_TRACE("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 #ifdef ENABLE_UHD_X300_FW_RESET
#include <uhd/transport/udp_simple.hpp> #include <uhd/transport/udp_simple.hpp>
@ -115,8 +124,9 @@ public:
virtual uhd_error get_mboard_name(std::string& mboard_name) = 0; virtual uhd_error get_mboard_name(std::string& mboard_name) = 0;
virtual uhd_error get_mboard_sensor_names(std::vector<std::string>& sensors) = 0; virtual uhd_error get_mboard_sensor_names(std::vector<std::string>& sensors) = 0;
virtual uhd_error get_rx_sensor_names(std::vector<std::string>& sensors) = 0; virtual uhd_error get_rx_sensor_names(std::vector<std::string>& sensors) = 0;
virtual uhd_error get_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_rx_sensor(const std::string& sensor_name, uhd::sensor_value_t& 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 set_time_unknown_pps(const uhd::time_spec_t& timespec) = 0;
virtual uhd_error get_time_now(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) uhd_error start_rx_stream(double delay)

Loading…
Cancel
Save