aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-10-12 10:47:07 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:04:02 -0800
commitd601fd03d5655f9e744a7b5454aac40492d7ad09 (patch)
tree694c23ea2dd2da110e8f06b543146aa2d95c5cce /mpm
parent4e9b707a66c49a4667ce89b9c0fa1b9780975a21 (diff)
downloaduhd-d601fd03d5655f9e744a7b5454aac40492d7ad09.tar.gz
uhd-d601fd03d5655f9e744a7b5454aac40492d7ad09.tar.bz2
uhd-d601fd03d5655f9e744a7b5454aac40492d7ad09.zip
mpm: Properly populate device_info dict for dboard classes
Prior to this commit, device_info was always an empty dictionary on all dboard classes. The device_info dict is now auto-populated from the EEPROM contents, if any were provided. Dboard classes can still opt to amend that dictionary in specific class implementations. Signed-off-by: Martin Braun <martin.braun@ettus.com>
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/base.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py
index cf3510abf..2b42e47c5 100644
--- a/mpm/python/usrp_mpm/dboard_manager/base.py
+++ b/mpm/python/usrp_mpm/dboard_manager/base.py
@@ -61,7 +61,24 @@ class DboardManagerBase(object):
def __init__(self, slot_idx, **kwargs):
self.log = get_logger('dboardManager')
self.slot_idx = slot_idx
- self.device_info = {}
+ if 'eeprom_md' not in kwargs:
+ self.log.warn("No EEPROM metadata given!")
+ def anystr_to_str(any_str):
+ """
+ Convert byte-string or regular string to regular string, regardless
+ of Python version (2 or 3).
+ """
+ try:
+ return str(any_str, 'ascii')
+ except TypeError:
+ return str(any_str)
+ # In C++, we can only handle dicts if all the values are of the
+ # same type. So we must convert them all to strings here:
+ self.device_info = {
+ key: anystr_to_str(kwargs.get('eeprom_md', {}).get(key, 'n/a'))
+ for key in ('pid', 'serial', 'rev', 'eeprom_version')
+ }
+ self.log.trace("Dboard device info: `{}'".format(self.device_info))
self._init_spi_nodes(kwargs.get('spi_nodes', []))