diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-10 18:04:31 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:53 -0800 |
commit | 13cd22e86763f4bfd9419a573ae96b4748b6781b (patch) | |
tree | 042bf68d09603e6488b9a827572c7a28bdd404d1 /mpm/python | |
parent | 4efea95324b66477f877d65c2d9c6ce188850174 (diff) | |
download | uhd-13cd22e86763f4bfd9419a573ae96b4748b6781b.tar.gz uhd-13cd22e86763f4bfd9419a573ae96b4748b6781b.tar.bz2 uhd-13cd22e86763f4bfd9419a573ae96b4748b6781b.zip |
mpm: Added command line args to usrp_hwd.py
Diffstat (limited to 'mpm/python')
-rwxr-xr-x | mpm/python/usrp_hwd.py | 41 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/eiscat.py | 2 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 7 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 4 |
4 files changed, 46 insertions, 8 deletions
diff --git a/mpm/python/usrp_hwd.py b/mpm/python/usrp_hwd.py index a6b242415..863c59396 100755 --- a/mpm/python/usrp_hwd.py +++ b/mpm/python/usrp_hwd.py @@ -20,6 +20,7 @@ Main executable for the USRP Hardware Daemon """ from __future__ import print_function import sys +import argparse from gevent import signal import usrp_mpm as mpm from usrp_mpm.mpmtypes import SharedState @@ -27,6 +28,40 @@ from usrp_mpm.periph_manager import periph_manager _PROCESSES = [] + +def setup_arg_parser(): + """ + Create an arg parser + """ + parser = argparse.ArgumentParser(description="USRP Hardware Daemon") + parser.add_argument( + '--daemon', + help="Run as daemon", + action="store_true", + ) + parser.add_argument( + '--init-only', + help="Don't start the RPC server, terminate after running initialization", + action="store_true", + ) + parser.add_argument( + '--override-db-pids', + help="Provide a comma-separated list of daughterboard PIDs that are " \ + "used instead of whatever else the code may find", + default=None + ) + return parser + +def parse_args(): + """ + Return a fully parse args object + """ + 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(",")] + return args + + def kill_time(sig, frame): """ kill all processes @@ -51,6 +86,7 @@ def main(): Main process loop. """ log = mpm.get_main_logger().getChild('main') + args = parse_args() shared = SharedState() # Create the periph_manager for this device # This call will be forwarded to the device specific implementation @@ -59,11 +95,14 @@ def main(): # with cmake (-DMPM_DEVICE). # mgr is thus derived from PeriphManagerBase (see periph_manager/base.py) log.info("Spawning periph manager...") - mgr = periph_manager() + mgr = periph_manager(args) discovery_info = { "type": mgr._get_device_info()["type"], "serial": mgr._get_device_info()["serial"] } + if args.init_only: + log.info("Terminating on user request before launching RPC server.") + return True log.info("Spawning discovery process...") _PROCESSES.append( mpm.spawn_discovery_process(discovery_info, shared)) diff --git a/mpm/python/usrp_mpm/dboard_manager/eiscat.py b/mpm/python/usrp_mpm/dboard_manager/eiscat.py index 330e6a605..0ba6ce115 100644 --- a/mpm/python/usrp_mpm/dboard_manager/eiscat.py +++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py @@ -353,7 +353,7 @@ class EISCAT(DboardManagerBase): def __init__(self, slot_idx, **kwargs): super(EISCAT, self).__init__(slot_idx, **kwargs) - self.log = get_logger("EISCAT") + self.log = get_logger("EISCAT-{}".format(slot_idx)) self.log.trace("Initializing EISCAT daughterboard, slot index {}".format(self.slot_idx)) self.initialized = False self.ref_clock_freq = 10e6 diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index e46df44c2..a6f69fd6d 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -236,15 +236,14 @@ class PeriphManagerBase(object): dboard_spimaster_addrs = [] - def __init__(self): + def __init__(self, args): # First, make some checks to see if the child class is correctly set up: assert len(self.pids) > 0 assert self.mboard_eeprom_magic is not None # Set up logging self.log = get_logger('PeriphManager') self._init_mboard_with_eeprom() - self._init_dboards() - + self._init_dboards(args.override_db_pids) def _init_mboard_with_eeprom(self): """ @@ -331,7 +330,7 @@ class PeriphManagerBase(object): # This will actually instantiate the dboard class: db_class = get_dboard_class_from_pid(db_pid) if db_class is None: - self.log.warning("Could not identify daughterboard class for PID {:04X}!".format(pid)) + self.log.warning("Could not identify daughterboard class for PID {:04X}!".format(db_pid)) continue self.dboards.append(db_class(dboard_idx, **dboard_info)) self.log.info("Found {} daughterboard(s).".format(len(self.dboards))) diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 4d36700a3..59eb7da94 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -112,9 +112,9 @@ class n310(PeriphManagerBase): dboard_spimaster_addrs = ["e0006000.spi",] - def __init__(self, *args, **kwargs): + def __init__(self, args): # First initialize parent class - will populate self._eeprom_head and self._eeprom_rawdata - super(n310, self).__init__(*args, **kwargs) + super(n310, self).__init__(args) self.log.trace("Initializing TCA6424 port expander controls...") self._gpios = TCA6424() |