From 219b04e99dceb075a91655ddc4d16d06a968db77 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 18 Oct 2017 13:16:43 -0700 Subject: mpm: tdc_sync: Remove sleeps in offset polling On the N310, there's a penalty for calling time.sleep(). This means the polling loop was extremely slow for polling TDC updates. Now, it simply polls as fast as possible. Note: This could hog the bus if run outside of an initialization sequence, where no one else is using the bus. --- mpm/python/usrp_mpm/cores/tdc_sync.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mpm/python/usrp_mpm/cores/tdc_sync.py b/mpm/python/usrp_mpm/cores/tdc_sync.py index ccedfcdcc..01724852d 100644 --- a/mpm/python/usrp_mpm/cores/tdc_sync.py +++ b/mpm/python/usrp_mpm/cores/tdc_sync.py @@ -260,15 +260,15 @@ class ClockSynchronizer(object): Return the offset (in seconds) the whatever what measured and whatever the reference is. """ - for _ in range(1000): # TODO replace with poll & timeout + timeout = time.time() + 1.0 + while True: rtc_offset_msb = self.peek32(self.RTC_OFFSET_1) - updated = (rtc_offset_msb & 0x100) == 0x100 - if updated: + if rtc_offset_msb & 0x100 == 0x100: break - time.sleep(0.001) - if not updated: - self.log.error("Offsets failed to update within timeout.") - raise RuntimeError("Offsets failed to update within timeout.") + if time.time() > timeout: + error_msg = "Offsets failed to update within timeout." + self.log.error(error_msg) + raise RuntimeError(error_msg) rtc_offset = (rtc_offset_msb & 0xFF) << 32 rtc_offset = float(rtc_offset | self.peek32(self.RTC_OFFSET_0)) / (1<<27) -- cgit v1.2.3