From f73e32729d0607a1ffacbfe5a6378a43ed07f6c2 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 11 Mar 2022 12:19:02 +0100 Subject: mpm: PeriphManagerBase: List all sync-related methods All PeriphManagerBase childs need to implement - get_{clock,time,sync}_source() - get_{clock,time,sync}_sources() - set_{clock,time,sync}_source() So we populate PeriphManagerBase with defaults for all of those. --- mpm/python/usrp_mpm/periph_manager/base.py | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'mpm/python') diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 35986a83c..0e6aad370 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -1216,6 +1216,14 @@ class PeriphManagerBase(object): ####################################################################### # Sync API ####################################################################### + def get_clock_source(self): + " Returns the currently selected clock source " + raise NotImplementedError("get_clock_source() not available on this device!") + + def get_time_source(self): + " Returns the currently selected time source " + raise NotImplementedError("get_time_source() not available on this device!") + def get_sync_source(self): """ Gets the current time and clock source @@ -1225,6 +1233,57 @@ class PeriphManagerBase(object): "clock_source": self.get_clock_source(), } + def get_clock_sources(self): + """ + Returns a list of valid clock sources. This is a list of strings. + """ + self.log.warning("get_clock_sources() was not specified for this device!") + return [] + + def get_time_sources(self): + """ + Returns a list of valid time sources. This is a list of strings. + """ + self.log.warning("get_time_sources() was not specified for this device!") + return [] + + def get_sync_sources(self): + """ + Returns a list of valid sync sources. This is a list of dictionaries. + """ + self.log.warning("get_sync_sources() was not specified for this device!") + return [] + + def set_clock_source(self, *args): + """ + Set a clock source. + + The choice to allow arbitrary arguments is based on historical decisions + and backward compatibility. UHD/mpmd will call this with a single argument, + so args[0] is the clock source (as a string). + """ + raise NotImplementedError("set_clock_source() not available on this device!") + + def set_time_source(self, time_source): + " Set a time source " + raise NotImplementedError("set_time_source() not available on this device!") + + def set_sync_source(self, sync_args): + """ + If a device has no special code for setting the sync-source atomically, + we simply forward these settings to set_clock_source() and set_time_source() + (in that order). + """ + if sync_args not in self.get_sync_sources(): + sync_args_str = \ + ','.join([str(k) + '=' + str(v) for k, v in sync_args.items()]) + self.log.warn( + f"Attempting to set unrecognized Sync source {sync_args_str}!") + clock_source = sync_args.get('clock_source', self.get_clock_source()) + time_source = sync_args.get('time_source', self.get_time_source()) + self.set_clock_source(clock_source) + self.set_time_source(time_source) + ########################################################################### # Clock/Time API ########################################################################### -- cgit v1.2.3