From 00c306d5c441e60e7dfd2516e05e4e433977ecee Mon Sep 17 00:00:00 2001 From: Samuel O'Brien Date: Fri, 24 Jul 2020 08:35:35 -0500 Subject: sim: Integrate simulator into UHD This commit adds a device::register_device which allows uhd to start up a simulator when uhd is called with the arguments type=sim. Creating the device object creates a subprocess using pybind and an embedded interpreter, and destroying the object cleans up those subprocesses. Signed-off-by: Samuel O'Brien --- mpm/python/usrp_hwd.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'mpm/python/usrp_hwd.py') diff --git a/mpm/python/usrp_hwd.py b/mpm/python/usrp_hwd.py index fb8c1b94e..aaa426fc4 100755 --- a/mpm/python/usrp_hwd.py +++ b/mpm/python/usrp_hwd.py @@ -24,12 +24,22 @@ from threading import Event, Thread _PROCESSES = [] _KILL_EVENT = Event() +# This Global Variable is used by the Simulator to make the spawn_processes, +# and by extension the main method, exit without waiting for the simulator to stop. +# See process_manager.py:bootstrap() for more information. +JOIN_PROCESSES = True def setup_arg_parser(): """ Create an arg parser """ parser = argparse.ArgumentParser(description="USRP Hardware Daemon") + parser.add_argument( + '--no-logbuf', + dest='use_logbuf', + help="Do not send log messages to UHD", + action="store_false", + ) parser.add_argument( '--daemon', help="Run as daemon", @@ -169,8 +179,9 @@ def spawn_processes(log, args): Thread(target=kill_thread, daemon=False).start() signal.signal(signal.SIGTERM, kill_time) signal.signal(signal.SIGINT, kill_time) - for proc in _PROCESSES: - proc.join() + if JOIN_PROCESSES: + for proc in _PROCESSES: + proc.join() return True def main(): @@ -181,6 +192,7 @@ def main(): """ args = parse_args() log = mpm.get_main_logger( + use_logbuf=args.use_logbuf, log_default_delta=args.verbose-args.quiet ).getChild('main') version_string = mpm.__version__ -- cgit v1.2.3