1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-293 Added state parameter to receive highest severity level.

This commit is contained in:
Vladimir Zidar 2016-04-21 13:42:06 +02:00 committed by Vladimir Zidar
parent 91a9c19e1f
commit e513db4b4d
2 changed files with 7 additions and 2 deletions

View File

@ -327,7 +327,7 @@ static const SystemAlarmsAlarmOptions severity_order[] = {
SYSTEMALARMS_ALARM_CRITICAL, SYSTEMALARMS_ALARM_WARNING, SYSTEMALARMS_ALARM_ERROR
};
size_t AlarmString(SystemAlarmsData *alarm, char *buffer, size_t buffer_size)
size_t AlarmString(SystemAlarmsData *alarm, char *buffer, size_t buffer_size, SystemAlarmsAlarmOptions *state)
{
size_t bytes_written = 0;
@ -339,6 +339,11 @@ size_t AlarmString(SystemAlarmsData *alarm, char *buffer, size_t buffer_size)
for (unsigned i = 0; i < SYSTEMALARMS_ALARM_NUMELEM; ++i) {
if ((SystemAlarmsAlarmToArray(alarm->Alarm)[i] == severity_order[order])
&& (systemalarms_alarm_names[i])) {
if (state) { // they are already sorted by severity as we are processing in specific order
*state = severity_order[order];
state = 0;
}
// in which case should we dig into extended alarm status?
// looks like SYSTEMALARMS_ALARM_SYSTEMCONFIGURATION sets most of the extended alarms
// except SYSTEMALARMS_ALARM_BOOTFAULT which also sets SYSTEMALARMS_EXTENDEDALARMSTATUS_REBOOTREQUIRED

View File

@ -48,7 +48,7 @@ int32_t AlarmsHasErrors();
int32_t AlarmsHasCritical();
SystemAlarmsAlarmOptions AlarmsGetHighestSeverity();
size_t AlarmString(SystemAlarmsData *alarm, char *buffer, size_t buffer_size);
size_t AlarmString(SystemAlarmsData *alarm, char *buffer, size_t buffer_size, SystemAlarmsAlarmOptions *state);
#endif // ALARMS_H