Change in osmo-trx[master]: uhd: ensure configured clock source is actually used

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Hoernchen gerrit-no-reply at lists.osmocom.org
Sat May 29 15:55:28 UTC 2021


Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/24447 )

Change subject: uhd: ensure configured clock source is actually used
......................................................................

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
---
M Transceiver52M/device/uhd/UHDDevice.cpp
1 file changed, 14 insertions(+), 0 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Hoernchen: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 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 @@
 
 	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) {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/24447
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Ie38d85617f46eb5ab7d9527ddf6aaab4d3edf6bf
Gerrit-Change-Number: 24447
Gerrit-PatchSet: 6
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210529/cb7f677f/attachment.htm>


More information about the gerrit-log mailing list