Make failed mavlink commands exception more verbose in pytflix

This commit is contained in:
Oleg Kalachev
2026-08-29 16:52:34 +03:00
parent 0dae0a3e7e
commit 3861c4438a
2 changed files with 8 additions and 3 deletions
+3 -1
View File
@@ -264,7 +264,9 @@ class Flix:
self.mavlink.command_long_send(self.system_id, 0, command, 0, *params) # type: ignore
ack = self.wait('mavlink.COMMAND_ACK', value=lambda msg: msg.command == command, timeout=0.1)
if ack.result != mavlink.MAV_RESULT_ACCEPTED:
raise RuntimeError(f'Command {command} failed with result {ack.result}')
name = getattr(mavlink.enums['MAV_CMD'].get(command, {}), 'name', f'UNKNOWN({command})')
result = getattr(mavlink.enums['MAV_RESULT'].get(ack.result, {}), 'name', f'UNKNOWN({ack.result})')
raise RuntimeError(f'Command {name} failed with result {result}')
return
except TimeoutError:
continue