diff --git a/conf/tools/pprzgcs.xml b/conf/tools/pprzgcs.xml index 7cf2892d3c..a64aa478fd 100644 --- a/conf/tools/pprzgcs.xml +++ b/conf/tools/pprzgcs.xml @@ -1,2 +1,2 @@ - + diff --git a/sw/supervision/pc_control_panel.ml b/sw/supervision/pc_control_panel.ml index 57ba4c0097..8d025737a5 100644 --- a/sw/supervision/pc_control_panel.ml +++ b/sw/supervision/pc_control_panel.ml @@ -257,8 +257,8 @@ let supervision = fun ?file gui log (ac_combo : Gtk_tools.combo) (target_combo : in let run_gcs = fun () -> - let args = get_program_args (Hashtbl.find programs "GCS") in - run_and_monitor ?file gui log "GCS" args in + let args = get_program_args (Hashtbl.find programs "PprzGCS") in + run_and_monitor ?file gui log "PprzGCS" args in let run_server = fun args -> run_and_monitor ?file gui log "Server" args in let choose_and_run_sitl = fun ac_name -> let get_args = fun simtype ac_name -> diff --git a/sw/tools/gcs_launch.py b/sw/tools/gcs_launch.py new file mode 100755 index 0000000000..7266b43c80 --- /dev/null +++ b/sw/tools/gcs_launch.py @@ -0,0 +1,73 @@ +#! /usr/bin/env python3 +from optparse import OptionParser, OptionGroup, OptionValueError +import subprocess +from os import getenv, path, execvp + +HOME = getenv("PAPARAZZI_HOME", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../'))) +LEGACY_GCS_PATH = path.join(HOME, "sw", "ground_segment", "cockpit", "gcs") + + +def pprzgcs_help(option, opt, value, parser): + try: + cp = subprocess.run(["pprzgcs", "-h"], capture_output=True) + # trim to relevant output + lines = cp.stdout.decode().split("\n")[4:] + options = "\n".join(lines) + print("PprzGCS options:\n\n" + options) + exit(0) + except FileNotFoundError: + print("PprzGCS not found!") + exit(1) + + +def legacy_help(option, opt, value, parser): + try: + cp = subprocess.run([LEGACY_GCS_PATH, "--help"], capture_output=True) + # trim to relevant output + lines = cp.stdout.decode().split("\n")[1:] + options = "\n".join(lines) + print("Legacy GCS options:\n\n" + options) + exit(0) + except FileNotFoundError: + print("Legacy GCS not found!") + exit(1) + + +def main(): + + usage = "usage: %prog -g -- [GCS arguments]\n" + \ + "Run %prog --help to list the options." + parser = OptionParser(usage) + + parser.add_option("-g", "--gcs", dest="gcstype", + type='choice', choices=['pprzgcs', 'legacy'], + action="store", help="GCS type to start: pprgcs or legacy") + parser.add_option("--pprzgcs_help", dest="pprzgcs_help", action="callback", callback=pprzgcs_help, + help="Print help for pprzgcs") + parser.add_option("--legacy_help", dest="legacy_help", action="callback", callback=legacy_help, + help="Print help for legacy GCS") + + (options, args) = parser.parse_args() + + def run_gcs(cmd, args, error_msg): + try: + args = [cmd] + args + print("Running \"" + " ".join(args) + "\"") + execvp(cmd, args) + except FileNotFoundError: + print(error_msg) + + if options.gcstype == "pprzgcs": + run_gcs("pprzgcs", args, "PprzGCS not found!") + elif options.gcstype == "legacy": + run_gcs(LEGACY_GCS_PATH, args, "Legacy GCS not found!") + elif options.gcstype is None: + run_gcs("pprzgcs", args, "PprzGCS not found!") + run_gcs(LEGACY_GCS_PATH, args, "Legacy GCS not found!") + + +if __name__ == "__main__": + main() + + +