autotest: add option to timeout parameter fetching in system time
This commit is contained in:
parent
83f2f365c0
commit
2917c75f35
@ -1529,20 +1529,10 @@ class AutoTest(ABC):
|
|||||||
if required_bootcount is None:
|
if required_bootcount is None:
|
||||||
required_bootcount = old_bootcount + 1
|
required_bootcount = old_bootcount + 1
|
||||||
while True:
|
while True:
|
||||||
# get_parameter calls get_sim_time.... streamrates may
|
|
||||||
# be zero so we need to prompt for one of these...
|
|
||||||
self.send_cmd(mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE,
|
|
||||||
mavutil.mavlink.MAVLINK_MSG_ID_SYSTEM_TIME,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0)
|
|
||||||
if time.time() - tstart > timeout:
|
if time.time() - tstart > timeout:
|
||||||
raise AutoTestTimeoutException("Did not detect reboot")
|
raise AutoTestTimeoutException("Did not detect reboot")
|
||||||
try:
|
try:
|
||||||
current_bootcount = self.get_parameter('STAT_BOOTCNT', timeout=1, attempts=1)
|
current_bootcount = self.get_parameter('STAT_BOOTCNT', timeout=1, attempts=1, verbose=True, timeout_in_wallclock=True)
|
||||||
self.progress("current=%s required=%u" % (str(current_bootcount), required_bootcount))
|
self.progress("current=%s required=%u" % (str(current_bootcount), required_bootcount))
|
||||||
if current_bootcount == required_bootcount:
|
if current_bootcount == required_bootcount:
|
||||||
break
|
break
|
||||||
@ -3548,7 +3538,7 @@ class AutoTest(ABC):
|
|||||||
# self.progress("Requesting (%s) (retry=%u)" % (name, i))
|
# self.progress("Requesting (%s) (retry=%u)" % (name, i))
|
||||||
continue
|
continue
|
||||||
delta = abs(autopilot_values[name] - value)
|
delta = abs(autopilot_values[name] - value)
|
||||||
if delta < epsilon:
|
if delta <= epsilon:
|
||||||
# correct value
|
# correct value
|
||||||
self.progress("%s is now %f" % (name, autopilot_values[name]))
|
self.progress("%s is now %f" % (name, autopilot_values[name]))
|
||||||
if add_to_context:
|
if add_to_context:
|
||||||
@ -3606,21 +3596,27 @@ class AutoTest(ABC):
|
|||||||
encname,
|
encname,
|
||||||
-1)
|
-1)
|
||||||
|
|
||||||
def get_parameter_direct(self, name, attempts=1, timeout=60, verbose=True):
|
def get_parameter_direct(self, name, attempts=1, timeout=60, verbose=True, timeout_in_wallclock=False):
|
||||||
while attempts > 0:
|
while attempts > 0:
|
||||||
if verbose:
|
if verbose:
|
||||||
self.progress("Sending param_request_read for (%s)" % name)
|
self.progress("Sending param_request_read for (%s)" % name)
|
||||||
# we MUST parse here or collections fail where we need
|
# we MUST parse here or collections fail where we need
|
||||||
# them to work!
|
# them to work!
|
||||||
self.drain_mav(quiet=True)
|
self.drain_mav(quiet=True)
|
||||||
tstart = self.get_sim_time()
|
if timeout_in_wallclock:
|
||||||
|
tstart = time.time()
|
||||||
|
else:
|
||||||
|
tstart = self.get_sim_time()
|
||||||
self.send_get_parameter_direct(name)
|
self.send_get_parameter_direct(name)
|
||||||
while True:
|
while True:
|
||||||
now = self.get_sim_time_cached()
|
if timeout_in_wallclock:
|
||||||
if tstart > now:
|
now = time.time()
|
||||||
self.progress("Time wrap detected")
|
else:
|
||||||
# we're going to have to send another request...
|
now = self.get_sim_time_cached()
|
||||||
break
|
if tstart > now:
|
||||||
|
self.progress("Time wrap detected")
|
||||||
|
# we're going to have to send another request...
|
||||||
|
break
|
||||||
delta_time = now - tstart
|
delta_time = now - tstart
|
||||||
if delta_time > timeout:
|
if delta_time > timeout:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user