From 1dae1fe7dfc4b473d86e2ab85aecb5a6edf7bd11 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 21 Jun 2024 11:54:02 +1000 Subject: [PATCH] autotest: add get_mode_string_for_mode --- Tools/autotest/vehicle_test_suite.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tools/autotest/vehicle_test_suite.py b/Tools/autotest/vehicle_test_suite.py index c67df6a5f8..3a90f18acf 100644 --- a/Tools/autotest/vehicle_test_suite.py +++ b/Tools/autotest/vehicle_test_suite.py @@ -6697,6 +6697,18 @@ class TestSuite(ABC): self.progress("No mode (%s); available modes '%s'" % (mode, mode_map)) raise ErrorException("Unknown mode '%s'" % mode) + def get_mode_string_for_mode(self, mode): + if isinstance(mode, str): + return mode + mode_map = self.mav.mode_mapping() + if mode_map is None: + return f"mode={mode}" + for (n, v) in mode_map.items(): + if v == mode: + return n + self.progress(f"No mode ({mode} {type(mode)}); available modes '{mode_map}'") + raise ErrorException("Unknown mode '%s'" % mode) + def run_cmd_do_set_mode(self, mode, timeout=30,