diff options
author | Martin Braun <martin.braun@ettus.com> | 2022-03-11 12:19:02 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-03-28 12:54:07 -0700 |
commit | f73e32729d0607a1ffacbfe5a6378a43ed07f6c2 (patch) | |
tree | dfe404ba2d77af14f8cdfb1fa65ad46a8d8a727d /mpm/python/usrp_mpm | |
parent | c176425b852bca6f80141e66ea021f4d6bba3a9d (diff) | |
download | uhd-f73e32729d0607a1ffacbfe5a6378a43ed07f6c2.tar.gz uhd-f73e32729d0607a1ffacbfe5a6378a43ed07f6c2.tar.bz2 uhd-f73e32729d0607a1ffacbfe5a6378a43ed07f6c2.zip |
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.
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 59 |
1 files changed, 59 insertions, 0 deletions
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 ########################################################################### |