diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-09-29 13:58:43 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:02 -0800 |
commit | e2f8f8e0bd36171246e99d96a5155a5b098f6700 (patch) | |
tree | 1ac23209444fba1b32529d0498f7d3ef048763dd /mpm/python/usrp_mpm/dboard_manager/base.py | |
parent | 21605b4e8b58053f4fa91a0a5136261da33e3bfb (diff) | |
download | uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.tar.gz uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.tar.bz2 uhd-e2f8f8e0bd36171246e99d96a5155a5b098f6700.zip |
mpm: Added sensor API
- Motherboard sensors are automatically populated into the property
tree, they can be automatically enumerated and queried
- Daughterboard sensors have an API for querying and enumerating
sensors, but this commit does not automatically add them to the
property tree
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager/base.py')
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/base.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py index 56655f946..b87033860 100644 --- a/mpm/python/usrp_mpm/dboard_manager/base.py +++ b/mpm/python/usrp_mpm/dboard_manager/base.py @@ -34,6 +34,10 @@ class DboardManagerBase(object): # Very important: A list of PIDs that apply to the current device. Must be # list, even if there's only one entry. pids = [] + # See PeriphManager.mboard_sensor_callback_map for a description. + rx_sensor_callback_map = {} + # See PeriphManager.mboard_sensor_callback_map for a description. + tx_sensor_callback_map = {} # A dictionary that maps chips or components to chip selects for SPI. # If this is given, a dictionary called self._spi_nodes is created which # maps these keys to actual spidev paths. Also throws a warning/error if @@ -108,3 +112,37 @@ class DboardManagerBase(object): Call this function if the frequency of the reference clock changes. """ self.log.warning("update_ref_clock_freq() called but not implemented") + + def get_sensors(self, direction): + """ + Return a list of RX daughterboard sensor names. + + direction needs to be either RX or TX. + """ + if direction.lower() == 'rx': + return list(self.rx_sensor_callback_map.keys()) + else: + return list(self.tx_sensor_callback_map.keys()) + + def get_sensor(self, direction, sensor_name): + """ + Return a dictionary that represents the sensor values for a given + sensor. If the requested sensor sensor_name does not exist, throw an + exception. direction is either RX or TX. + + See PeriphManager.get_mb_sensor() for a description of the return value + format. + """ + callback_map = \ + rx_sensor_callback_map if direction.lower() == 'rx' \ + else tx_sensor_callback_map + if sensor_name not in callback_map: + error_msg = "Was asked for non-existent sensor `{}'.".format( + sensor_name + ) + self.log.error(error_msg) + raise RuntimeError(error_msg) + return getattr( + self, self.callback_map.get('sensor_name') + )() + |