mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-1290 fix event system issues caused by alarm flapping
This commit is contained in:
parent
5b6d397f76
commit
48876620fc
@ -75,8 +75,12 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity
|
||||
|
||||
// Read alarm and update its severity only if it was changed
|
||||
SystemAlarmsGet(&alarms);
|
||||
if (cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity) {
|
||||
uint32_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS;
|
||||
if ((flightTime - cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] > 1000 &&
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity)
|
||||
|| cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] < severity) {
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] = severity;
|
||||
cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] = flightTime;
|
||||
SystemAlarmsSet(&alarms);
|
||||
}
|
||||
|
||||
@ -110,10 +114,14 @@ int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm,
|
||||
|
||||
// Read alarm and update its severity only if it was changed
|
||||
SystemAlarmsGet(&alarms);
|
||||
if (cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity) {
|
||||
uint32_t flightTime = xTaskGetTickCount() * portTICK_RATE_MS;
|
||||
if ((flightTime - cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] > 1000 &&
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] != severity)
|
||||
|| cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] < severity) {
|
||||
cast_struct_to_array(alarms.ExtendedAlarmStatus, alarms.ExtendedAlarmStatus.BootFault)[alarm] = status;
|
||||
cast_struct_to_array(alarms.ExtendedAlarmSubStatus, alarms.ExtendedAlarmStatus.BootFault)[alarm] = subStatus;
|
||||
cast_struct_to_array(alarms.Alarm, alarms.Alarm.Actuator)[alarm] = severity;
|
||||
cast_struct_to_array(alarms.LastChange, alarms.LastChange.Actuator)[alarm] = flightTime;
|
||||
SystemAlarmsSet(&alarms);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,31 @@
|
||||
<elementname>Power</elementname>
|
||||
</elementnames>
|
||||
</field>
|
||||
<field name="LastChange" units="ms" type="uint32">
|
||||
<elementnames>
|
||||
<elementname>SystemConfiguration</elementname>
|
||||
<elementname>BootFault</elementname>
|
||||
<elementname>OutOfMemory</elementname>
|
||||
<elementname>StackOverflow</elementname>
|
||||
<elementname>CPUOverload</elementname>
|
||||
<elementname>EventSystem</elementname>
|
||||
<elementname>Telemetry</elementname>
|
||||
<elementname>Receiver</elementname>
|
||||
<elementname>ManualControl</elementname>
|
||||
<elementname>Actuator</elementname>
|
||||
<elementname>Attitude</elementname>
|
||||
<elementname>Sensors</elementname>
|
||||
<elementname>Airspeed</elementname>
|
||||
<elementname>Stabilization</elementname>
|
||||
<elementname>Guidance</elementname>
|
||||
<elementname>PathPlan</elementname>
|
||||
<elementname>Battery</elementname>
|
||||
<elementname>FlightTime</elementname>
|
||||
<elementname>I2C</elementname>
|
||||
<elementname>GPS</elementname>
|
||||
<elementname>Power</elementname>
|
||||
</elementnames>
|
||||
</field>
|
||||
<field name="ExtendedAlarmStatus" units="" type="enum" defaultvalue="None">
|
||||
<elementnames>
|
||||
<elementname>SystemConfiguration</elementname>
|
||||
@ -45,7 +70,7 @@
|
||||
</field>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="throttled" period="100"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="manual" period="0"/>
|
||||
</object>
|
||||
</xml>
|
||||
|
Loading…
x
Reference in New Issue
Block a user