From 3a2b5d633271eba7c297a286fed0028de3ca01fe Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Wed, 7 May 2014 23:50:39 +0200 Subject: [PATCH] OP-1332 fix problem in alarm handling where alarms are unable to reset on their own --- flight/libraries/alarms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flight/libraries/alarms.c b/flight/libraries/alarms.c index 0ea46c5e5..fc96aa2ce 100644 --- a/flight/libraries/alarms.c +++ b/flight/libraries/alarms.c @@ -82,7 +82,7 @@ int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity // Read alarm and update its severity only if it was changed SystemAlarmsAlarmGet(&alarms); uint16_t flightTime = (uint16_t)xTaskGetTickCount() * (uint16_t)portTICK_RATE_MS; // this deliberately overflows every 2^16 milliseconds to save memory - if ((flightTime - lastAlarmChange[alarm] > PIOS_ALARM_GRACETIME && + if (((uint16_t)(flightTime - lastAlarmChange[alarm]) > PIOS_ALARM_GRACETIME && cast_struct_to_array(alarms, alarms.Actuator)[alarm] != severity) || cast_struct_to_array(alarms, alarms.Actuator)[alarm] < severity) { cast_struct_to_array(alarms, alarms.Actuator)[alarm] = severity; @@ -121,7 +121,7 @@ int32_t ExtendedAlarmsSet(SystemAlarmsAlarmElem alarm, // Read alarm and update its severity only if it was changed SystemAlarmsGet(&alarms); uint16_t flightTime = (uint16_t)xTaskGetTickCount() * (uint16_t)portTICK_RATE_MS; // this deliberately overflows every 2^16 milliseconds to save memory - if ((flightTime - lastAlarmChange[alarm] > PIOS_ALARM_GRACETIME && + if (((uint16_t)(flightTime - lastAlarmChange[alarm]) > PIOS_ALARM_GRACETIME && 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;