2014-01-27 02:38:57 -04:00
|
|
|
from LogAnalyzer import Test,TestResult
|
|
|
|
import DataflashLog
|
|
|
|
|
|
|
|
|
|
|
|
class TestEvents(Test):
|
|
|
|
'''test for erroneous events and failsafes'''
|
2014-03-03 14:55:25 -04:00
|
|
|
# TODO: need to check for vehicle-specific codes
|
2014-01-27 02:38:57 -04:00
|
|
|
|
|
|
|
def __init__(self):
|
2014-06-27 20:11:23 -03:00
|
|
|
Test.__init__(self)
|
2014-01-27 02:38:57 -04:00
|
|
|
self.name = "Event/Failsafe"
|
|
|
|
|
2014-03-03 13:46:17 -04:00
|
|
|
def run(self, logdata, verbose):
|
2014-01-27 02:38:57 -04:00
|
|
|
self.result = TestResult()
|
2014-06-15 18:35:14 -03:00
|
|
|
self.result.status = TestResult.StatusType.GOOD
|
2014-01-27 02:38:57 -04:00
|
|
|
|
|
|
|
errors = set()
|
|
|
|
|
|
|
|
if "ERR" in logdata.channels:
|
2014-02-23 10:20:18 -04:00
|
|
|
assert(len(logdata.channels["ERR"]["Subsys"].listData) == len(logdata.channels["ERR"]["ECode"].listData))
|
|
|
|
for i in range(len(logdata.channels["ERR"]["Subsys"].listData)):
|
|
|
|
subSys = logdata.channels["ERR"]["Subsys"].listData[i][1]
|
|
|
|
eCode = logdata.channels["ERR"]["ECode"].listData[i][1]
|
2014-01-27 02:38:57 -04:00
|
|
|
if subSys == 2 and (eCode == 1):
|
|
|
|
errors.add("PPM")
|
|
|
|
elif subSys == 3 and (eCode == 1 or eCode == 2):
|
|
|
|
errors.add("COMPASS")
|
|
|
|
elif subSys == 5 and (eCode == 1):
|
|
|
|
errors.add("FS_THR")
|
|
|
|
elif subSys == 6 and (eCode == 1):
|
|
|
|
errors.add("FS_BATT")
|
|
|
|
elif subSys == 7 and (eCode == 1):
|
|
|
|
errors.add("GPS")
|
|
|
|
elif subSys == 8 and (eCode == 1):
|
|
|
|
errors.add("GCS")
|
|
|
|
elif subSys == 9 and (eCode == 1 or eCode == 2):
|
|
|
|
errors.add("FENCE")
|
|
|
|
elif subSys == 10:
|
|
|
|
errors.add("FLT_MODE")
|
|
|
|
elif subSys == 11 and (eCode == 2):
|
|
|
|
errors.add("GPS_GLITCH")
|
|
|
|
elif subSys == 12 and (eCode == 1):
|
|
|
|
errors.add("CRASH")
|
|
|
|
|
2014-02-23 10:20:18 -04:00
|
|
|
if errors:
|
2014-01-27 02:38:57 -04:00
|
|
|
if len(errors) == 1 and "FENCE" in errors:
|
|
|
|
self.result.status = TestResult.StatusType.WARN
|
|
|
|
else:
|
|
|
|
self.result.status = TestResult.StatusType.FAIL
|
|
|
|
if len(errors) == 1:
|
|
|
|
self.result.statusMessage = "ERR found: "
|
|
|
|
else:
|
|
|
|
self.result.statusMessage = "ERRs found: "
|
|
|
|
for err in errors:
|
|
|
|
self.result.statusMessage = self.result.statusMessage + err + " "
|
|
|
|
|