Tools: autotest: fix race condition with getting parameters

This commit is contained in:
Peter Barker 2019-07-08 12:47:06 +10:00 committed by Peter Barker
parent 4d19d65047
commit 6332d2e729
1 changed files with 6 additions and 1 deletions

View File

@ -1055,7 +1055,12 @@ class AutoTest(ABC):
self.mavproxy.send("param fetch %s\n" % name) self.mavproxy.send("param fetch %s\n" % name)
try: try:
self.mavproxy.expect("%s = ([-0-9.]*)\r\n" % (name,), timeout=timeout/retry) self.mavproxy.expect("%s = ([-0-9.]*)\r\n" % (name,), timeout=timeout/retry)
return float(self.mavproxy.match.group(1)) try:
# sometimes race conditions garble the MAVProxy output
ret = float(self.mavproxy.match.group(1))
except ValueError as e:
continue
return ret
except pexpect.TIMEOUT: except pexpect.TIMEOUT:
pass pass
raise NotAchievedException("Failed to retrieve parameter (%s)" % name) raise NotAchievedException("Failed to retrieve parameter (%s)" % name)