mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-886: use enum for extended alarm status field
See also: http://reviews.openpilot.org/cru/OPReview-430 http://progress.openpilot.org/browse/OP-915
This commit is contained in:
parent
343a4b9015
commit
220b4b5042
@ -91,11 +91,14 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity
|
||||
* Set an Extended Alarm
|
||||
* @param alarm The system alarm to be modified
|
||||
* @param severity The alarm severity
|
||||
* @param status: the Extended alarm status field
|
||||
* @param subStatus: the Extended alarm substatus field
|
||||
* @param status The Extended alarm status field
|
||||
* @param subStatus The Extended alarm substatus field
|
||||
* @return 0 if success, -1 if an error
|
||||
*/
|
||||
int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity, uint8_t status, uint8_t subStatus)
|
||||
int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm,
|
||||
SystemAlarmsAlarmOptions severity,
|
||||
SystemAlarmsExtendedAlarmStatusOptions status,
|
||||
uint8_t subStatus)
|
||||
{
|
||||
SystemAlarmsData alarms;
|
||||
|
||||
@ -170,7 +173,7 @@ void AlarmsDefaultAll()
|
||||
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
|
||||
{
|
||||
if (alarm < SYSTEMALARMS_EXTENDEDALARMSTATUS_NUMELEM) {
|
||||
return ExtendedAlarmsSet(alarm, SYSTEMALARMS_ALARM_OK, 0, 0);
|
||||
return ExtendedAlarmsSet(alarm, SYSTEMALARMS_ALARM_OK, SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE, 0);
|
||||
} else {
|
||||
return AlarmsSet(alarm, SYSTEMALARMS_ALARM_OK);
|
||||
}
|
||||
|
@ -33,7 +33,10 @@
|
||||
|
||||
int32_t AlarmsInitialize(void);
|
||||
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity);
|
||||
int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity, uint8_t status, uint8_t subStatus);
|
||||
int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm,
|
||||
SystemAlarmsAlarmOptions severity,
|
||||
SystemAlarmsExtendedAlarmStatusOptions status,
|
||||
uint8_t subStatus);
|
||||
SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm);
|
||||
int32_t AlarmsDefault(SystemAlarmsAlarmElem alarm);
|
||||
void AlarmsDefaultAll();
|
||||
|
@ -29,15 +29,9 @@
|
||||
#ifndef SANITYCHECK_H
|
||||
#define SANITYCHECK_H
|
||||
|
||||
#define SANITYCHECK_STATUS_ERROR_NONE 0
|
||||
#define SANITYCHECK_STATUS_ERROR_FLIGHTMODE 1
|
||||
|
||||
#define BOOTFAULT_STATUS_ERROR_NONE 0
|
||||
#define BOOTFAULT_STATUS_ERROR_REQUIRE_REBOOT 1
|
||||
|
||||
#if (SYSTEMALARMS_EXTENDEDALARMSTATUS_NUMELEM != SYSTEMALARMS_EXTENDEDALARMSUBSTATUS_NUMELEM) || \
|
||||
(SYSTEMALARMS_EXTENDEDALARMSUBSTATUS_NUMELEM > SYSTEMALARMS_ALARM_NUMELEM)
|
||||
#error incongruent SystemAlarms. Please revise the UAVO definition in SystemAlarm.xml
|
||||
#error Incongruent SystemAlarms. Please revise the UAVO definition in systemalarms.xml
|
||||
#endif
|
||||
|
||||
extern int32_t configuration_check();
|
||||
|
@ -54,7 +54,7 @@ static int32_t check_stabilization_settings(int index, bool multirotor);
|
||||
int32_t configuration_check()
|
||||
{
|
||||
int32_t severity = SYSTEMALARMS_ALARM_OK;
|
||||
uint8_t alarmstatus = SANITYCHECK_STATUS_ERROR_NONE;
|
||||
SystemAlarmsExtendedAlarmStatusOptions alarmstatus = SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE;
|
||||
uint8_t alarmsubstatus = 0;
|
||||
// Get board type
|
||||
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||
@ -134,9 +134,8 @@ int32_t configuration_check()
|
||||
severity = SYSTEMALARMS_ALARM_ERROR;
|
||||
}
|
||||
// mark the first encountered erroneous setting in status and substatus
|
||||
if(severity != SYSTEMALARMS_ALARM_OK && alarmstatus == SANITYCHECK_STATUS_ERROR_NONE)
|
||||
{
|
||||
alarmstatus = SANITYCHECK_STATUS_ERROR_FLIGHTMODE;
|
||||
if ((severity != SYSTEMALARMS_ALARM_OK) && (alarmstatus == SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE)) {
|
||||
alarmstatus = SYSTEMALARMS_EXTENDEDALARMSTATUS_FLIGHTMODE;
|
||||
alarmsubstatus = i;
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ static void hwSettingsUpdatedCb(UAVObjEvent * ev)
|
||||
HwSettingsGet(¤tHwSettings);
|
||||
// check whether the Hw Configuration has changed from the one used at boot time
|
||||
if (memcmp(&bootHwSettings, ¤tHwSettings, sizeof(HwSettingsData)) != 0) {
|
||||
ExtendedAlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_ERROR, BOOTFAULT_STATUS_ERROR_REQUIRE_REBOOT, 0);
|
||||
ExtendedAlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_ERROR, SYSTEMALARMS_EXTENDEDALARMSTATUS_REBOOTREQUIRED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,16 @@
|
||||
<elementname>Power</elementname>
|
||||
</elementnames>
|
||||
</field>
|
||||
<field name="ExtendedAlarmStatus" units="" type="uint8" defaultvalue="0">
|
||||
<field name="ExtendedAlarmStatus" units="" type="enum" defaultvalue="None">
|
||||
<elementnames>
|
||||
<elementname>SystemConfiguration</elementname>
|
||||
<elementname>BootFault</elementname>
|
||||
</elementnames>
|
||||
<options>
|
||||
<option>None</option>
|
||||
<option>RebootRequired</option>
|
||||
<option>FlightMode</option>
|
||||
</options>
|
||||
</field>
|
||||
<field name="ExtendedAlarmSubStatus" units="" type="uint8" defaultvalue="0">
|
||||
<elementnames>
|
||||
|
Loading…
x
Reference in New Issue
Block a user