From b8b8472bd8abbaeddc237439c2f640148d065561 Mon Sep 17 00:00:00 2001 From: Neil Bertram Date: Tue, 18 Oct 2022 21:38:22 +1300 Subject: [PATCH] option: Implement an option to not write telemetry logs or other state --- MAVProxy/mavproxy.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MAVProxy/mavproxy.py b/MAVProxy/mavproxy.py index 99e5e1c590..0ebd222083 100644 --- a/MAVProxy/mavproxy.py +++ b/MAVProxy/mavproxy.py @@ -1295,6 +1295,7 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg): parser.add_option("--non-interactive", action='store_true', help="do not start interactive shell") parser.add_option("--profile", action='store_true', help="run the Yappi python profiler") parser.add_option("--state-basedir", default=None, help="base directory for logs and aircraft directories") + parser.add_option("--no-state", action='store_true', default=False, help="Don't save logs and other state to disk. Useful for read-only filesystems or long-running systems.") parser.add_option("--version", action='store_true', help="version information") parser.add_option("--default-modules", default="log,signing,wp,rally,fence,ftp,param,relay,tuneopt,arm,mode,calibration,rc,auxopt,misc,cmdlong,battery,terrain,output,adsb,layout", help='default module list') parser.add_option("--udp-timeout",dest="udp_timeout", default=0.0, type='float', help="Timeout for udp clients in seconds") @@ -1335,9 +1336,13 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg): mpstate.command_map = command_map mpstate.continue_mode = opts.continue_mode # queues for logging - mpstate.logqueue = multiproc.Queue() - mpstate.logqueue_raw = multiproc.Queue() + if not opts.no_state: + mpstate.logqueue = multiproc.Queue() + mpstate.logqueue_raw = multiproc.Queue() + else: + mpstate.logqueue = None + mpstate.logqueue_raw = None if opts.speech: # start the speech-dispatcher early, so it doesn't inherit any ports from @@ -1441,7 +1446,8 @@ def quit_handler(signum = None, frame = None): mpstate.rl.set_prompt("") # call this early so that logdir is setup based on --aircraft - (mpstate.status.logdir, logpath_telem, logpath_telem_raw) = log_paths() + if not opts.no_state: + (mpstate.status.logdir, logpath_telem, logpath_telem_raw) = log_paths() for module in opts.load_module: modlist = module.split(',') @@ -1505,7 +1511,10 @@ def quit_handler(signum = None, frame = None): yappi.start() # log all packets from the master, for later replay - open_telemetry_logs(logpath_telem, logpath_telem_raw) + if not opts.no_state: + open_telemetry_logs(logpath_telem, logpath_telem_raw) + else: + print("Note: Not saving telemetry logs") # run main loop as a thread mpstate.status.thread = threading.Thread(target=main_loop, name='main_loop')