diff --git a/lib/src/phy/rf/rf_uhd_generic.h b/lib/src/phy/rf/rf_uhd_generic.h index c5049666e..6b408b4a8 100644 --- a/lib/src/phy/rf/rf_uhd_generic.h +++ b/lib/src/phy/rf/rf_uhd_generic.h @@ -48,7 +48,6 @@ private: uhd_error test_ad936x_device(uint32_t nof_channels) { - uhd_error err = set_rx_rate(1.92e6); if (err != UHD_ERROR_NONE) { return err; @@ -209,7 +208,6 @@ public: Info("The device is based on AD9361, get RX stream for checking LIBUSB_TRANSFER_ERROR"); uint32_t ntrials = 10; do { - // If no error getting RX stream, return err = test_ad936x_device(nof_channels); if (err == UHD_ERROR_NONE) { @@ -268,13 +266,13 @@ public: { UHD_SAFE_C_SAVE_ERROR(this, timespec = usrp->get_time_now();) } - uhd_error set_sync_source(const std::string& source) override + uhd_error set_sync_source(const std::string& sync_source, const std::string& clock_source) override { - Debug("Setting PPS source to '" << source << "'"); + Debug("Setting PPS source to '" << sync_source << "' and clock source to '" << clock_source << "'"); #if UHD_VERSION < 3140099 - UHD_SAFE_C_SAVE_ERROR(this, usrp->set_clock_source(source); usrp->set_time_source(source);) + UHD_SAFE_C_SAVE_ERROR(this, usrp->set_clock_source(clock_source); usrp->set_time_source(sync_source);) #else - UHD_SAFE_C_SAVE_ERROR(this, usrp->set_sync_source(source, source);) + UHD_SAFE_C_SAVE_ERROR(this, usrp->set_sync_source(clock_source, sync_source);) #endif } uhd_error get_gain_range(uhd::gain_range_t& tx_gain_range, uhd::gain_range_t& rx_gain_range) override diff --git a/lib/src/phy/rf/rf_uhd_imp.cc b/lib/src/phy/rf/rf_uhd_imp.cc index a2c4cb6aa..c5da99775 100644 --- a/lib/src/phy/rf/rf_uhd_imp.cc +++ b/lib/src/phy/rf/rf_uhd_imp.cc @@ -178,7 +178,7 @@ static cf_t zero_mem[64 * 1024] = {}; #define print_usrp_error(h) \ do { \ - ERROR("USRP reported the following error: %s", h->uhd->last_error.c_str()); \ + ERROR("USRP reported the following error: %s", h->uhd->last_error.c_str()); \ } while (false) static void log_overflow(rf_uhd_handler_t* h) @@ -603,6 +603,12 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels clock_src = device_addr.pop("clock"); } + // Select same synchronization source only if more than one channel is opened + std::string sync_src = "internal"; + if (nof_channels > 1) { + sync_src = clock_src; + } + // Logging level #ifdef UHD_LOG_INFO uhd::log::severity_level severity_level = uhd::log::severity_level::info; @@ -779,7 +785,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels std::string sensor_name; // Set sync source - if (handler->uhd->set_sync_source(clock_src) != UHD_ERROR_NONE) { + if (handler->uhd->set_sync_source(sync_src, clock_src) != UHD_ERROR_NONE) { print_usrp_error(handler); return SRSRAN_ERROR; } diff --git a/lib/src/phy/rf/rf_uhd_safe.h b/lib/src/phy/rf/rf_uhd_safe.h index 6120be7de..d9e7f862e 100644 --- a/lib/src/phy/rf/rf_uhd_safe.h +++ b/lib/src/phy/rf/rf_uhd_safe.h @@ -143,7 +143,7 @@ public: stream_cmd.stream_now = true; rx_stream->issue_stream_cmd(stream_cmd);) } - virtual uhd_error set_sync_source(const std::string& source) = 0; + virtual uhd_error set_sync_source(const std::string& sync_source, const std::string& clock_source) = 0; virtual uhd_error get_gain_range(uhd::gain_range_t& tx_gain_range, uhd::gain_range_t& rx_gain_range) = 0; virtual uhd_error set_master_clock_rate(double rate) = 0; virtual uhd_error set_rx_rate(double rate) = 0;