mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 17:08:28 -04:00
autotest: add get_mode_string_for_mode
This commit is contained in:
parent
744da0aec7
commit
1dae1fe7df
@ -6697,6 +6697,18 @@ class TestSuite(ABC):
|
|||||||
self.progress("No mode (%s); available modes '%s'" % (mode, mode_map))
|
self.progress("No mode (%s); available modes '%s'" % (mode, mode_map))
|
||||||
raise ErrorException("Unknown mode '%s'" % mode)
|
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,
|
def run_cmd_do_set_mode(self,
|
||||||
mode,
|
mode,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
|
Loading…
Reference in New Issue
Block a user