Skip to content

Commit 6d882e1

Browse files
nexton-winjeelpeterbarker
authored andcommitted
autotest: Verify methods for requesting MESSAGE_INTERVAL are equivalent
1 parent d1b81b1 commit 6d882e1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Tools/autotest/rover.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6884,6 +6884,32 @@ def REQUIRE_LOCATION_FOR_ARMING(self):
68846884
self.context_pop()
68856885
self.reboot_sitl()
68866886

6887+
def GetMessageInterval(self):
6888+
'''check that the two methods for requesting a MESSAGE_INTERVAL message are equivalent'''
6889+
target_msg = mavutil.mavlink.MAVLINK_MSG_ID_HOME_POSITION
6890+
old_cmd = (mavutil.mavlink.MAV_CMD_GET_MESSAGE_INTERVAL, target_msg, 0)
6891+
new_cmd = (mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, mavutil.mavlink.MAVLINK_MSG_ID_MESSAGE_INTERVAL, target_msg)
6892+
6893+
interval_us = None
6894+
6895+
for run_command in self.run_cmd, self.run_cmd_int:
6896+
for cmd in old_cmd, new_cmd:
6897+
cmd_id, p1, p2 = cmd
6898+
6899+
self.context_collect("MESSAGE_INTERVAL")
6900+
run_command(cmd_id, p1=p1, p2=p2)
6901+
m = self.assert_receive_message('MESSAGE_INTERVAL', timeout=1, check_context=True)
6902+
self.context_clear_collection("MESSAGE_INTERVAL")
6903+
6904+
if m.message_id != target_msg:
6905+
raise NotAchievedException(f"Unexpected ID in MESSAGE_INTERVAL (want={target_msg}, got={m.message_id})")
6906+
6907+
if interval_us is None:
6908+
interval_us = m.interval_us
6909+
6910+
if m.interval_us != interval_us:
6911+
raise NotAchievedException(f"Unexpected interval_us (want={interval_us}, got={m.interval_us})")
6912+
68876913
def tests(self):
68886914
'''return list of all tests'''
68896915
ret = super(AutoTestRover, self).tests()
@@ -6984,6 +7010,7 @@ def tests(self):
69847010
self.JammingSimulation,
69857011
self.BatteryInvalid,
69867012
self.REQUIRE_LOCATION_FOR_ARMING,
7013+
self.GetMessageInterval,
69877014
])
69887015
return ret
69897016

0 commit comments

Comments
 (0)