From 93e6c1a920afc02b8d58b92f7c2de3c51e6c4f33 Mon Sep 17 00:00:00 2001 From: Michael Day Date: Sat, 30 Oct 2021 17:18:32 -0400 Subject: [PATCH] Tools: sysid cannot be run together with auto-sysid Added per @peterbarker suggestion Co-authored-by: Peter Barker --- Tools/autotest/sim_vehicle.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Tools/autotest/sim_vehicle.py b/Tools/autotest/sim_vehicle.py index 5f2b392197..ad74086b80 100755 --- a/Tools/autotest/sim_vehicle.py +++ b/Tools/autotest/sim_vehicle.py @@ -714,8 +714,15 @@ def start_vehicle(binary, opts, stuff, spawns=None): c = ["-I" + str(i)] if spawns is not None: c.extend(["--home", spawns[i]]) - if opts.auto_sysid and opts.sysid is None and 0 <= i < 255: - c.extend(["--sysid", str(i + 1)]) + if opts.auto_sysid: + if opts.sysid is not None: + raise ValueError("Can't use auto-sysid and sysid together") + sysid = i + 1 + # Take 0-based logging into account + if i < 0 or i > 255: + raise ValueError("Invalid system id %d" % i) + c.extend(["--sysid", str(sysid)]) + os.chdir(i_dir) run_in_terminal_window(cmd_name, cmd + c) os.chdir(old_dir) @@ -1232,6 +1239,10 @@ if cmd_opts.strace and cmd_opts.valgrind: if cmd_opts.strace and cmd_opts.callgrind: print("callgrind and strace almost certainly not a good idea") +if cmd_opts.sysid and cmd_opts.auto_sysid: + print("Cannot use auto-sysid together with sysid") + sys.exit(1) + # magically determine vehicle type (if required): if cmd_opts.vehicle is None: cwd = os.getcwd()