Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rcd52b704ecd368081934656bda20ec01326ade12 -r7334590e610cd1543e128ad2dbc0de17e824b619 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision cd52b704ecd368081934656bda20ec01326ade12) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 7334590e610cd1543e128ad2dbc0de17e824b619) @@ -1142,27 +1142,72 @@ * The handleDGCmdResp function handles a DG command response message. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. - * @param messagePtr pointer to the message to handle. + * @param message pointer to the message to handle. * @return none *************************************************************************/ -void handleDGCmdResp( MESSAGE_T *messagePtr ) +void handleDGCmdResp( MESSAGE_T *message ) { BOOL result = FALSE; - if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + if ( message->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) { DG_CMD_RESPONSE_T dgCmdResponse; result = TRUE; - memcpy( &dgCmdResponse, messagePtr->payload, sizeof( DG_CMD_RESPONSE_T ) ); + memcpy( &dgCmdResponse, message->payload, sizeof( DG_CMD_RESPONSE_T ) ); handleDGCommandResponse( &dgCmdResponse ); } - sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); } /*********************************************************************//** * @brief + * The handleUIClockSyncRequest function handles a UI clock sync message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIClockSyncRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 epoch; + + memcpy( &epoch, message->payload, sizeof( U32 ) ); + result = setRTCEpoch( epoch ); + if ( FALSE == result ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Create a response message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_UI_SET_RTC_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payloadPtr, &result, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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_2_UI, ACK_REQUIRED ); + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief * The handleDGOpMode function handles a DG broadcast of its current mode. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. @@ -2442,6 +2487,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