aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
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', []))