Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r3956c379375c22a95accfd791245e32e0782705a -ra9160f295f6baf4fad4a8e2a739782f6df7d177a --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 3956c379375c22a95accfd791245e32e0782705a) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision a9160f295f6baf4fad4a8e2a739782f6df7d177a) @@ -23,12 +23,13 @@ #include "CPLD.h" #include "DialInFlow.h" #include "FPGA.h" -#include "OperationModes.h" -#include "RTC.h" -#include "WatchdogMgmt.h" #include "ModeInitPOST.h" #include "NVDataMgmt.h" +#include "OperationModes.h" +#include "RTC.h" +#include "SystemCommMessages.h" #include "Valves.h" +#include "WatchdogMgmt.h" /** * @addtogroup HDInitAndPOSTMode @@ -39,11 +40,14 @@ // ********** private data ********** -static HD_POST_STATE_T postState = POST_STATE_START; ///< Current state of initialize and POST mode. -static BOOL postCompleted = FALSE; ///< Flag indicates whether POST is completed. -static BOOL postPassed = FALSE; ///< Flag indicates all POST tests passed. -static BOOL tempPOSTPassed = TRUE; ///< Flag indicates all POST tests have passed so far. +static HD_POST_STATE_T postState; ///< Current state of initialize and POST mode. +static BOOL postCompleted; ///< Flag indicates whether POST is completed. +static BOOL postPassed; ///< Flag indicates all POST tests passed. +static BOOL tempPOSTPassed; ///< Flag indicates all POST tests have passed so far. +static BOOL uiPOSTPassed; ///< Final result for UI POST tests (TRUE = passed, FALSE = failed). +static BOOL dgPOSTPassed; ///< Final result for DG POST tests (TRUE = passed, FALSE = failed). + // ********** private function prototypes ********** static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); @@ -62,6 +66,8 @@ postCompleted = FALSE; postPassed = FALSE; tempPOSTPassed = TRUE; + uiPOSTPassed = FALSE; + dgPOSTPassed = FALSE; } /*********************************************************************//** @@ -187,19 +193,23 @@ } break; + // TODO - add POST test requiring all DG and UI POST tests to pass + case POST_STATE_COMPLETED: // Set overall HD POST status to "passed" postPassed = TRUE; // Set overall HD POST completed status to TRUE postCompleted = TRUE; - // TODO - send POST status on CAN + // Broadcast final POST passed + sendPOSTFinalResult( TRUE ); // Go to standby mode requestNewOperationMode( MODE_STAN ); break; case POST_STATE_FAILED: // Should not get here - any failed post test should have already triggered a fault and taken us to fault mode default: + sendPOSTFinalResult( FALSE ); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_INIT_POST_INVALID_POST_STATE, postState ) postState = POST_STATE_FAILED; break; @@ -219,11 +229,39 @@ *************************************************************************/ void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ) { + // TODO - anything required here? +} +/*********************************************************************//** + * @brief + * The signalUIPOSTFinalResult function records the final POST result for + * the UI. + * @details Inputs: none + * @details Outputs: uiPOSTPassed + * @param passed TRUE if UI POST tests all passed, FALSE if any UI POST test failed + * @return none + *************************************************************************/ +void signalUIPOSTFinalResult( BOOL passed ) +{ + uiPOSTPassed = passed; } /*********************************************************************//** * @brief + * The signalDGPOSTFinalResult function records the final POST result for + * the DG. + * @details Inputs: none + * @details Outputs: dgPOSTPassed + * @param passed TRUE if DG POST tests all passed, FALSE if any DG POST test failed + * @return none + *************************************************************************/ +void signalDGPOSTFinalResult( BOOL passed ) +{ + dgPOSTPassed = passed; +} + +/*********************************************************************//** + * @brief * The isPOSTCompleted function determines whether all HD POST have * been run and completed. If true, call the isPOSTPassed() to see final * result (pass/fail). @@ -264,12 +302,18 @@ if ( testStatus == SELF_TEST_STATUS_PASSED ) { - result = (HD_POST_STATE_T)((int)postState + 1); // Move on to next POST test + // Broadcast passed POST result + sendPOSTTestResult( (HD_POST_STATE_T)((int)postState), TRUE ); + // Move on to next POST test + result = (HD_POST_STATE_T)((int)postState + 1); } else if ( testStatus == SELF_TEST_STATUS_FAILED ) { // At least one POST has failed tempPOSTPassed = FALSE; + // Broadcast failed POST results + sendPOSTTestResult( (HD_POST_STATE_T)((int)postState), FALSE ); + sendPOSTFinalResult( FALSE ); // Test that failed should have triggered a fault which will request fault mode, so should POST state machine should never see FAILED state and will fault if it does result = POST_STATE_FAILED; } Index: firmware/App/Modes/ModeInitPOST.h =================================================================== diff -u -r1942c708bc95f57e87b0bf6a472ebe824a3f38ed -ra9160f295f6baf4fad4a8e2a739782f6df7d177a --- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 1942c708bc95f57e87b0bf6a472ebe824a3f38ed) +++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision a9160f295f6baf4fad4a8e2a739782f6df7d177a) @@ -37,6 +37,8 @@ BOOL isPOSTCompleted( void ); // Determine whether POST has completed yet BOOL isPOSTPassed( void ); // Determine whether POST has passed void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode +void signalUIPOSTFinalResult( BOOL passed ); // Record UI POST result +void signalDGPOSTFinalResult( BOOL passed ); // Record DG POST result /**@}*/ Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r9c0470dd725f1399b558f2eaf91f0275c5e021f1 -ra9160f295f6baf4fad4a8e2a739782f6df7d177a --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 9c0470dd725f1399b558f2eaf91f0275c5e021f1) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision a9160f295f6baf4fad4a8e2a739782f6df7d177a) @@ -1265,36 +1265,20 @@ handleDGCmdResp( message ); break; - case MSG_ID_TESTER_LOGIN_REQUEST: - handleTesterLogInRequest( message ); + case MSG_ID_DG_POST_FINAL_TEST_RESULT: + handleDGPOSTFinalResult( message ); break; - case MSG_ID_HD_SET_CALIBRATION_RECORD: - handleSetHDCalibrationRecord( message ); + case MSG_ID_UI_POST_FINAL_TEST_RESULT: + handleUIPOSTFinalResult( message ); break; - case MSG_ID_HD_GET_CALIBRATION_RECORD: - handleGetHDCalibrationRecord( message ); + case MSG_ID_TESTER_LOGIN_REQUEST: + handleTesterLogInRequest( message ); break; - case MSG_ID_HD_SET_SYSTEM_RECORD: - handleSetHDSystemRecord( message ); - break; - - case MSG_ID_HD_GET_SYSTEM_RECORD: - handleGetHDSystemRecord( message ); - break; - - case MSG_ID_HD_GET_SERVICE_RECORD: - handleGetHDServiceRecord( message ); - break; - - case MSG_ID_HD_SET_SERVICE_RECORD: - handleSetHDServiceRecord( message ); - break; - default: - // Unrecognized message ID received - ignore + // Un-recognized or un-handled message ID received - ignore break; } @@ -1617,6 +1601,30 @@ handleTestSyringePumpADCReadCtrOverrideRequest( message ); break; + case MSG_ID_HD_SET_CALIBRATION_RECORD: + handleSetHDCalibrationRecord( message ); + break; + + case MSG_ID_HD_GET_CALIBRATION_RECORD: + handleGetHDCalibrationRecord( message ); + break; + + case MSG_ID_HD_SET_SYSTEM_RECORD: + handleSetHDSystemRecord( message ); + break; + + case MSG_ID_HD_GET_SYSTEM_RECORD: + handleGetHDSystemRecord( message ); + break; + + case MSG_ID_HD_GET_SERVICE_RECORD: + handleGetHDServiceRecord( message ); + break; + + case MSG_ID_HD_SET_SERVICE_RECORD: + handleSetHDServiceRecord( message ); + break; + default: // Unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r3533955f242cec0505e8826e0e2d96f7b79ad499 -ra9160f295f6baf4fad4a8e2a739782f6df7d177a --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3533955f242cec0505e8826e0e2d96f7b79ad499) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a9160f295f6baf4fad4a8e2a739782f6df7d177a) @@ -2290,6 +2290,117 @@ } } +/*********************************************************************//** + * @brief + * The sendPOSTTestResult function constructs an HD POST test result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST test result msg constructed and queued. + * @param test ID of HD POST test + * @param passed TRUE if POST test passed, FALSE if not + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTTestResult( HD_POST_STATE_T test, BOOL passed ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 testID = (U32)test; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_SINGLE_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &passed, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &testID, sizeof( U32) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_REQUIRED ); + + return result; + +} + +/*********************************************************************//** + * @brief + * The sendPOSTFinalResult function constructs an HD POST final result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST final result msg constructed and queued. + * @param passed TRUE if HD POST passed, FALSE if not + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTFinalResult( BOOL passed ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_FINAL_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &passed, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGPOSTFinalResult function handles a DG POST final result message. + * @details Inputs: none + * @details Outputs: DG POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + + // TODO - handle DG POST final result + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleUIPOSTFinalResult function handles a UI POST final result message. + * @details Inputs: none + * @details Outputs: UI POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + + // TODO - handle UI POST final result + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + /*********************************************************************//** * @brief * The handleOffButtonConfirmMsgFromUI function handles a response to an Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r5fef605363d4f8023b3db2989b097b6c5f58db1a -ra9160f295f6baf4fad4a8e2a739782f6df7d177a --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 5fef605363d4f8023b3db2989b097b6c5f58db1a) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision a9160f295f6baf4fad4a8e2a739782f6df7d177a) @@ -79,6 +79,18 @@ // MSG_ID_ALARM_CONDITION_CLEARED void handleAlarmUserAction( MESSAGE_T *message ); +// MSG_ID_HD_POST_SINGLE_TEST_RESULT +BOOL sendPOSTTestResult( HD_POST_STATE_T test, BOOL passed ); + +// MSG_ID_HD_POST_FINAL_TEST_RESULT +BOOL sendPOSTFinalResult( BOOL passed ); + +// MSG_ID_DG_POST_FINAL_TEST_RESULT +void handleDGPOSTFinalResult( MESSAGE_T *message ); + +// MSG_ID_UI_POST_FINAL_TEST_RESULT +void handleUIPOSTFinalResult( MESSAGE_T *message ); + // MSG_ID_LOAD_CELL_READINGS void handleLoadCellReadingsFromDG( MESSAGE_T *message );