aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric <ewild@sysmocom.de>2021-05-28 21:20:19 +0200
committerHoernchen <ewild@sysmocom.de>2021-05-29 15:55:28 +0000
commit5e6b10cd9e08da52f57b1f746659d020cf278eb4 (patch)
tree8dba66d480d8a1f49830130a1f6f06efe93008fd
parentctrl_sock_handle_rx(): fix missing space in LOGCHAN() statement (diff)
downloadOsmoTRX-5e6b10cd9e08da52f57b1f746659d020cf278eb4.tar.xz
OsmoTRX-5e6b10cd9e08da52f57b1f746659d020cf278eb4.zip
uhd: ensure configured clock source is actually used
We wouldn't want to get caught running with unlocked external clock sources, right?! Change-Id: Ie38d85617f46eb5ab7d9527ddf6aaab4d3edf6bf
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 010fa8c..5486822 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -548,6 +548,7 @@ void uhd_device::set_channels(bool swap)
int uhd_device::open(const std::string &args, int ref, bool swap_channels)
{
const char *refstr;
+ int clock_lock_attempts = 15;
/* Register msg handler. Different APIs depending on UHD version */
#ifdef USE_UHD_3_11
@@ -620,6 +621,19 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
usrp_dev->set_clock_source(refstr);
+ std::vector<std::string> sensor_names = usrp_dev->get_mboard_sensor_names();
+ if (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end()) {
+ LOGC(DDEV, INFO) << "Waiting for clock reference lock (max " << clock_lock_attempts << "s)..." << std::flush;
+ while (!usrp_dev->get_mboard_sensor("ref_locked", 0).to_bool() && clock_lock_attempts--)
+ sleep(1);
+
+ if (!clock_lock_attempts) {
+ LOGC(DDEV, ALERT) << "Locking to external 10Mhz failed!";
+ return -1;
+ }
+ }
+ LOGC(DDEV, INFO) << "Selected clock source is " << usrp_dev->get_clock_source(0);
+
try {
set_rates();
} catch (const std::exception &e) {