@ -3,6 +3,7 @@
@@ -3,6 +3,7 @@
# Dive ArduSub in SITL
from __future__ import print_function
import os
import time
from pymavlink import mavutil
@ -326,16 +327,43 @@ class AutoTestSub(AutoTest):
@@ -326,16 +327,43 @@ class AutoTestSub(AutoTest):
def reboot_sitl ( self ) :
""" Reboot SITL instance and wait it to reconnect. """
self . context_push ( )
self . context_collect ( " STATUSTEXT " )
self . send_reboot_command ( )
# "Init ArduSub" comes out as raw text, not a statustext
for i in range ( 2 ) :
# out battery is reset to full on reboot. So reduce it to 10%
# and wait for it to go above 50.
self . run_cmd ( mavutil . mavlink . MAV_CMD_BATTERY_RESET ,
255 , # battery mask
10 , # percentage
0 ,
0 ,
0 ,
0 ,
0 ,
0 )
self . run_cmd_reboot ( )
tstart = time . time ( )
while True :
if time . time ( ) - tstart > 30 :
raise NotAchievedException ( " Did not detect reboot " )
# ask for the message:
batt = None
try :
self . wait_statustext ( " ArduPilot Ready " , check_context = True , wallclock_timeout = True )
self . send_cmd ( mavutil . mavlink . MAV_CMD_REQUEST_MESSAGE ,
mavutil . mavlink . MAVLINK_MSG_ID_BATTERY_STATUS ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 )
batt = self . mav . recv_match ( type = ' BATTERY_STATUS ' ,
blocking = True ,
timeout = 1 )
except ConnectionResetError as e :
pass
self . context_pop ( )
self . progress ( " Battery: %s " % str ( batt ) )
if batt is None :
continue
if batt . battery_remaining > 50 :
break
self . initialise_after_reboot_sitl ( )
def apply_defaultfile_parameters ( self ) :