aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_hwd.py
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-05-12 14:27:59 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:53 -0800
commit9dee6175da45440997c8ed82fbf40f8f380dc4a7 (patch)
treead791488d217c76f9187b318f026872f419939d5 /mpm/python/usrp_hwd.py
parentca1723c02ea3d30f1003840f6fc1350e39c97485 (diff)
downloaduhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.tar.gz
uhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.tar.bz2
uhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.zip
mpm: Moved device and dboard init/deinit to their own methods
Also cleaned up some cruft.
Diffstat (limited to 'mpm/python/usrp_hwd.py')
-rwxr-xr-xmpm/python/usrp_hwd.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/mpm/python/usrp_hwd.py b/mpm/python/usrp_hwd.py
index 863c59396..27c2870df 100755
--- a/mpm/python/usrp_hwd.py
+++ b/mpm/python/usrp_hwd.py
@@ -50,6 +50,12 @@ def setup_arg_parser():
"used instead of whatever else the code may find",
default=None
)
+ parser.add_argument(
+ '--default-args',
+ help="Provide a comma-separated list of key=value pairs that are" \
+ "used as defaults for device initialization.",
+ default=None
+ )
return parser
def parse_args():
@@ -59,6 +65,15 @@ def parse_args():
args = setup_arg_parser().parse_args()
if args.override_db_pids is not None:
args.override_db_pids = [int(x, 0) for x in args.override_db_pids.split(",")]
+ args.default_args = args.default_args or ''
+ try:
+ args.default_args = {
+ x.split('=')[0].strip(): x.split('=')[1].strip() if x.find('=') != -1 else ''
+ for x in args.default_args.split(',')
+ if len(x)
+ }
+ except IndexError:
+ log.error("Could not parse default device args: `{}'".format(args.default_args))
return args
@@ -100,8 +115,10 @@ def main():
"type": mgr._get_device_info()["type"],
"serial": mgr._get_device_info()["serial"]
}
+ mgr.init(args.default_args) # TODO really this should be called by the UHD session
if args.init_only:
log.info("Terminating on user request before launching RPC server.")
+ mgr.deinit()
return True
log.info("Spawning discovery process...")
_PROCESSES.append(
@@ -113,6 +130,7 @@ def main():
signal.signal(signal.SIGTERM, kill_time)
signal.signal(signal.SIGINT, kill_time)
signal.pause()
+ mgr.deinit() # TODO Really this should be called when a device is unclaimed
return True
if __name__ == '__main__':