Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r026197c08dc426a0a79c9a958d20578d52a9fee3 -rbaec590e57965acc167c510875127addf4ac34dd --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 026197c08dc426a0a79c9a958d20578d52a9fee3) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision baec590e57965acc167c510875127addf4ac34dd) @@ -468,8 +468,10 @@ CONFIRMATION_REQUEST_STATUS_T status = CONFIRMATION_REQUEST_STATUS_PENDING; U32 i; - GENERIC_CONFIRMATION_REQUEST_T cmd = { 0 }; + GENERIC_CONFIRMATION_REQUEST_T cmd; + memset( &cmd, 0, sizeof( GENERIC_CONFIRMATION_REQUEST_T ) ); + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( confirmRequests[ i ].requestID == requestID ) @@ -566,16 +568,18 @@ U32 i; BOOL confirmAlreadyPending = FALSE; GENERIC_CONFIRM_ID_T newID = GENERIC_CONFIRM_ID_NONE; - GENERIC_CONFIRMATION_REQUEST_T cmd = { 0 }; + GENERIC_CONFIRMATION_REQUEST_T cmd; + memset( &cmd, 0, sizeof( GENERIC_CONFIRMATION_REQUEST_T ) ); + // Check whether this confirmation is already pending for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( ( confirmRequests[ i ].requestID == requestID ) && ( CONFIRMATION_REQUEST_STATUS_UNUSED != confirmRequests[ i ].status ) ) { confirmAlreadyPending = TRUE; - return requestID; + newID = requestID; } } @@ -604,6 +608,7 @@ } } } + return newID; } Index: firmware/App/Monitors/Buttons.c =================================================================== diff -u -r026197c08dc426a0a79c9a958d20578d52a9fee3 -rbaec590e57965acc167c510875127addf4ac34dd --- firmware/App/Monitors/Buttons.c (.../Buttons.c) (revision 026197c08dc426a0a79c9a958d20578d52a9fee3) +++ firmware/App/Monitors/Buttons.c (.../Buttons.c) (revision baec590e57965acc167c510875127addf4ac34dd) @@ -299,20 +299,20 @@ offRequestPulseTimer = 0; offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; offButtonPressPending = TRUE; -} - -/*********************************************************************//** - * @brief - * The handleOffButtonProcessing function checks for and processes off button +} + +/*********************************************************************//** + * @brief + * The handleOffButtonProcessing function checks for and processes off button * activity. * @details \b Message \b Sent: TD_EVENT_BUTTON when off button state changes. * @details \b Message \b Sent: OFF_BUTTON_CMD_CANCEL_USER_CONFIRM_PROMPT when - * pending off button expires. - * @details \b Inputs: offButtonState, prevOffButtonState + * pending off button expires. + * @details \b Inputs: offButtonState, prevOffButtonState * @details \b Outputs: offButtonPressPending, offRequestPulseCount, offRequestPulseTimer - * offRequestAwaitingUserConfirmation, offRequestPendingTimer - * @return none - *************************************************************************/ + * offRequestAwaitingUserConfirmation, offRequestPendingTimer + * @return none + *************************************************************************/ static void handleOffButtonProcessing( void ) { CONFIRMATION_REQUEST_STATUS_T responseStatus = CONFIRMATION_REQUEST_STATUS_UNUSED; @@ -367,12 +367,13 @@ } else if ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == responseStatus ) { - offRequestAwaitingUserConfirmation = FALSE; if ( TRUE == isCurrentOpModeOkToTurnOff() ) { POWER_OFF_WARNING_DATA_T data; + offRequestAwaitingUserConfirmation = FALSE; + data.powerOffWarning = 0; broadcastData( MSG_ID_POWER_OFF_WARNING, @@ -385,15 +386,7 @@ offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; offRequestPulseTimer = 0; } - else - { - addConfirmationRequest( GENERIC_CONFIRM_ID_POWER_OFF, GENERIC_CONFIRM_CMD_REJECT, REQUEST_REJECT_REASON_SYSTEM_IN_OPERATIONMODE ); - } } - else - { - ; // do nothing - } } // If user confirmed off button press, manage off request sequence @@ -421,57 +414,57 @@ } } } - -/*********************************************************************//** - * @brief - * The handleStopButtonProcessing function checks for and processes stop button + +/*********************************************************************//** + * @brief + * The handleStopButtonProcessing function checks for and processes stop button * activity. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if a pending stop button is * expires. * @details \b Message \b Sent: TD_EVENT_BUTTON when stop button state changes. - * @details \b Inputs: stopButtonState, prevStopButtonState - * @details \b Outputs: stopButtonPressPending - * @return none - *************************************************************************/ -static void handleStopButtonProcessing( void ) -{ - // Handle button state transitions for stop button - if ( getStopButtonState() != prevStopButtonState ) - { - if ( getStopButtonState() == BUTTON_STATE_PRESSED ) - { - stopButtonPressPending = TRUE; + * @details \b Inputs: stopButtonState, prevStopButtonState + * @details \b Outputs: stopButtonPressPending + * @return none + *************************************************************************/ +static void handleStopButtonProcessing( void ) +{ + // Handle button state transitions for stop button + if ( getStopButtonState() != prevStopButtonState ) + { + if ( getStopButtonState() == BUTTON_STATE_PRESSED ) + { + stopButtonPressPending = TRUE; // stopButtonPendingTimer = getMSTimerCount(); // Log stop button press SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_BUTTON, BUTTON_STOP, BUTTON_STATE_PRESSED ) } else { SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_BUTTON, BUTTON_STOP, BUTTON_STATE_RELEASED ) - } - prevStopButtonState = getStopButtonState(); - } - - // Handle when a stop button press is pending - if ( TRUE == stopButtonPressPending ) - { - // If stop button not consumed within a reasonable time, s/w fault - if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT_MS ) ) - { + } + prevStopButtonState = getStopButtonState(); + } + + // Handle when a stop button press is pending + if ( TRUE == stopButtonPressPending ) + { + // If stop button not consumed within a reasonable time, s/w fault + if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT_MS ) ) + { stopButtonPressPending = FALSE; -#ifndef TEST_NO_STOP_CONSUME_CHECK +#ifndef TEST_NO_STOP_CONSUME_CHECK SET_ALARM_WITH_1_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_BUTTONS_STOP_BUTTON_NOT_CONSUMED ) -#endif - } - } -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - +#endif + } + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + /*********************************************************************//** * @brief * The testOffButtonOverride function overrides the off button state.