aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-05-07 17:52:03 -0700
committerMartin Braun <martin.braun@ettus.com>2018-06-08 13:27:13 -0700
commit30cc2e99827a689fc8ace112e72f864173eee1a5 (patch)
treeaa221a731f1b93633f9c864fdc232ec90e1115cf
parentd1e1ac71be64577c35ab46b30ca4e218ffddda53 (diff)
downloaduhd-30cc2e99827a689fc8ace112e72f864173eee1a5.tar.gz
uhd-30cc2e99827a689fc8ace112e72f864173eee1a5.tar.bz2
uhd-30cc2e99827a689fc8ace112e72f864173eee1a5.zip
mpm: Distinguish mboard_info and device_info
In the N3xx series, the motherboard ID and the device ID can differ. For example, the N310 could share the same motherboard with a different device that uses different daughterboards.
-rw-r--r--mpm/python/usrp_mpm/periph_manager/base.py31
-rw-r--r--mpm/python/usrp_mpm/periph_manager/n3xx.py24
2 files changed, 34 insertions, 21 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py
index e3bf89c33..b7debf82c 100644
--- a/mpm/python/usrp_mpm/periph_manager/base.py
+++ b/mpm/python/usrp_mpm/periph_manager/base.py
@@ -52,7 +52,8 @@ class PeriphManagerBase(object):
# These values are meant to be overridden by the according subclasses
#########################################################################
# Very important: A map of PIDs that apply to the current device. Format is
- # pid -> product name.
+ # pid -> product name. If there are multiple products with the same
+ # motherboard PID, use generate_device_info() to update the product key.
pids = {}
# A textual description of this device type
description = "MPM Device"
@@ -129,6 +130,16 @@ class PeriphManagerBase(object):
updateable_components = {}
@staticmethod
+ def generate_device_info(eeprom_md, mboard_info, dboard_infos):
+ """
+ Returns a dictionary which describes the device.
+
+ mboard_info -- Dictionary; motherboard info
+ device_args -- List of dictionaries; daughterboard info
+ """
+ return mboard_info
+
+ @staticmethod
# Yes, this is overridable too: List the required device tree overlays
def list_required_dt_overlays(eeprom_md, device_args):
"""
@@ -164,6 +175,8 @@ class PeriphManagerBase(object):
self.log.info("Device serial number: {}"
.format(self.mboard_info.get('serial', 'n/a')))
dboard_infos = self._get_dboard_eeprom_info()
+ self.device_info = \
+ self.generate_device_info(self.mboard_info, dboard_infos)
self._default_args = self._update_default_args(args)
self.log.debug("Using default args: {}".format(self._default_args))
self._init_mboard_overlays(self._eeprom_head, self._default_args)
@@ -319,10 +332,10 @@ class PeriphManagerBase(object):
"""
prefs_cache = prefs.get_prefs()
periph_section_name = None
- if prefs_cache.has_section(self.mboard_info.get('product')):
- periph_section_name = self.mboard_info.get('product')
- elif prefs_cache.has_section(self.mboard_info.get('type')):
- periph_section_name = self.mboard_info.get('type')
+ if prefs_cache.has_section(self.device_info.get('product')):
+ periph_section_name = self.device_info.get('product')
+ elif prefs_cache.has_section(self.device_info.get('type')):
+ periph_section_name = self.device_info.get('type')
if periph_section_name is not None:
prefs_cache.read_dict({periph_section_name: default_args})
return dict(prefs_cache[periph_section_name])
@@ -490,13 +503,13 @@ class PeriphManagerBase(object):
@no_rpc
def get_device_info(self):
"""
- Return the mboard_info dict and add a claimed field.
+ Return the device_info dict and add a claimed field.
Will also call into get_device_info_dyn() for additional information.
Don't override this function.
"""
result = {"claimed": str(self.claimed)}
- result.update(self.mboard_info)
+ result.update(self.device_info)
result.update({
'name': net.get_hostname(),
'description': self.description,
@@ -525,9 +538,9 @@ class PeriphManagerBase(object):
"""
assert conn_type in ('remote', 'local', None)
if conn_type is None:
- self.mboard_info.pop('rpc_connection', None)
+ self.device_info.pop('rpc_connection', None)
else:
- self.mboard_info['rpc_connection'] = conn_type
+ self.device_info['rpc_connection'] = conn_type
@no_claim
def get_dboard_info(self):
diff --git a/mpm/python/usrp_mpm/periph_manager/n3xx.py b/mpm/python/usrp_mpm/periph_manager/n3xx.py
index 37810c54f..cfd189391 100644
--- a/mpm/python/usrp_mpm/periph_manager/n3xx.py
+++ b/mpm/python/usrp_mpm/periph_manager/n3xx.py
@@ -253,7 +253,7 @@ class n3xx(PeriphManagerBase):
likely.
"""
# Sanity checks
- assert self.mboard_info.get('product') in self.pids.values(), \
+ assert self.device_info.get('product') in self.pids.values(), \
"Device product could not be determined!"
# Init peripherals
self.log.trace("Initializing TCA6424 port expander controls...")
@@ -303,7 +303,7 @@ class n3xx(PeriphManagerBase):
)
self._status_monitor_thread.start()
# Init complete.
- self.log.debug("mboard info: {}".format(self.mboard_info))
+ self.log.debug("Device info: {}".format(self.device_info))
###########################################################################
# Session init and deinit
@@ -332,7 +332,7 @@ class n3xx(PeriphManagerBase):
# source connectors on the front panel, so we assume that if this was
# selected, it was an artifact from N310-related code. The user gets
# a warning and the setting is reset to internal.
- if self.mboard_info.get('product') == 'n300':
+ if self.device_info.get('product') == 'n300':
for lo_source in ('rx_lo_source', 'tx_lo_source'):
if lo_source in args and args.get(lo_source) != 'internal':
self.log.warning("The N300 variant does not support "
@@ -407,13 +407,13 @@ class n3xx(PeriphManagerBase):
"operating on temporary SID: %s",
dst_address, suggested_src_address, str(xport_type), str(sid))
# FIXME token!
- assert self.mboard_info['rpc_connection'] in ('remote', 'local')
- if self.mboard_info['rpc_connection'] == 'remote':
+ assert self.device_info['rpc_connection'] in ('remote', 'local')
+ if self.device_info['rpc_connection'] == 'remote':
return self._xport_mgrs['udp'].request_xport(
sid,
xport_type,
)
- elif self.mboard_info['rpc_connection'] == 'local':
+ elif self.device_info['rpc_connection'] == 'local':
return self._xport_mgrs['liberio'].request_xport(
sid,
xport_type,
@@ -429,14 +429,14 @@ class n3xx(PeriphManagerBase):
session.
"""
## Go, go, go
- assert self.mboard_info['rpc_connection'] in ('remote', 'local')
+ assert self.device_info['rpc_connection'] in ('remote', 'local')
sid = SID(xport_info['send_sid'])
self._available_endpoints.remove(sid.src_ep)
self.log.debug("Committing transport for SID %s, xport info: %s",
str(sid), str(xport_info))
- if self.mboard_info['rpc_connection'] == 'remote':
+ if self.device_info['rpc_connection'] == 'remote':
return self._xport_mgrs['udp'].commit_xport(sid, xport_info)
- elif self.mboard_info['rpc_connection'] == 'local':
+ elif self.device_info['rpc_connection'] == 'local':
return self._xport_mgrs['liberio'].commit_xport(sid, xport_info)
###########################################################################
@@ -915,7 +915,7 @@ class n3xx(PeriphManagerBase):
# Cut off the period from the file extension
file_extension = file_extension[1:].lower()
binfile_path = self.updateable_components['fpga']['path'].format(
- self.mboard_info['product'])
+ self.device_info['product'])
if file_extension == "bit":
self.log.trace("Converting bit to bin file and writing to {}"
.format(binfile_path))
@@ -945,12 +945,12 @@ class n3xx(PeriphManagerBase):
:param metadata: Dictionary of strings containing metadata
"""
dtsfile_path = self.updateable_components['dts']['path'].format(
- self.mboard_info['product'])
+ self.device_info['product'])
self.log.trace("Updating DTS with image at %s to %s (metadata: %s)",
filepath, dtsfile_path, str(metadata))
shutil.copy(filepath, dtsfile_path)
dtbofile_path = self.updateable_components['dts']['output'].format(
- self.mboard_info['product'])
+ self.device_info['product'])
self.log.trace("Compiling to %s...", dtbofile_path)
dtc_command = [
'dtc',