Skip to content

Commit

Permalink
autotest: Verify methods for requesting MESSAGE_INTERVAL are equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
nexton-winjeel committed Oct 9, 2024
1 parent 7693a16 commit 0761215
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Tools/autotest/rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6876,6 +6876,32 @@ def BatteryInvalid(self):
self.set_parameter("BATT_MONITOR", 0)
self.wait_ready_to_arm()

def GetMessageInterval(self):
'''check that the two methods for requesting a MESSAGE_INTERVAL message are equivalent'''
target_msg = mavutil.mavlink.MAVLINK_MSG_ID_HOME_POSITION
old_cmd = (mavutil.mavlink.MAV_CMD_GET_MESSAGE_INTERVAL, target_msg, 0)
new_cmd = (mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, mavutil.mavlink.MAVLINK_MSG_ID_MESSAGE_INTERVAL, target_msg)

interval_us = None

for run_command in self.run_cmd, self.run_cmd_int:
for cmd in old_cmd, new_cmd:
cmd_id, p1, p2 = cmd

self.context_collect("MESSAGE_INTERVAL")
run_command(cmd_id, p1=p1, p2=p2)
m = self.assert_receive_message('MESSAGE_INTERVAL', timeout=1, check_context=True)
self.context_clear_collection("MESSAGE_INTERVAL")

if m.message_id != target_msg:
raise NotAchievedException(f"Unexpected ID in MESSAGE_INTERVAL (want={target_msg}, got={m.message_id})")

if interval_us is None:
interval_us = m.interval_us

if m.interval_us != interval_us:
raise NotAchievedException(f"Unexpected interval_us (want={interval_us}, got={m.interval_us})")

def tests(self):
'''return list of all tests'''
ret = super(AutoTestRover, self).tests()
Expand Down Expand Up @@ -6973,6 +6999,7 @@ def tests(self):
self.ClearMission,
self.JammingSimulation,
self.BatteryInvalid,
self.GetMessageInterval,
])
return ret

Expand Down

0 comments on commit 0761215

Please sign in to comment.