Index: App/Services/SystemCommMessages.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -19,6 +19,7 @@ #include // for memcpy() #include "Common.h" +#include "AlarmLamp.h" #include "Buttons.h" #include "MsgQueues.h" #include "SystemCommMessages.h" @@ -36,8 +37,8 @@ typedef struct { U08 reset; - U08 button_state; -} BUTTON_STATE_OVERRIDE_CARGO_T; + U08 state; +} TEST_OVERRIDE_CARGO_T; #pragma pack(pop) @@ -48,6 +49,7 @@ // ********** private function prototypes ********** static U32 serializeMessage( MESSAGE_T msg, U08 *data ); +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); /************************************************************************* * @brief serializeMessage @@ -154,6 +156,55 @@ /************************************************************************* + * @brief isTestingActivated + * The isTestingActivated function determines whether a tester has successfully \n + * logged in to activate testing functionality. + * @details + * Inputs : testerLoggedIn + * Outputs : none + * @param none + * @return TRUE if a tester has logged in to activate testing, FALSE if not + *************************************************************************/ +BOOL isTestingActivated( void ) +{ + return testerLoggedIn; +} + +/************************************************************************* + * @brief sendTestAckResponseMsg + * The sendTestAckResponseMsg function constructs a simple response \n + * message for a handled test message and queues it for transmit on the \n + * appropriate UART channel. + * @details + * Inputs : none + * Outputs : response message constructed and queued for transmit. + * @param msgID : ID of handled message that we are responding to + * @param ack : TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + U32 msgSize; + U08 data[PC_MESSAGE_PACKET_SIZE]; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.cargoLen = 1; + msg.cargo[0] = (U08)ack; + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) + msgSize = serializeMessage( msg, data ); + + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); + + return result; +} + +/************************************************************************* * @brief handleTesterLogInRequest * The handleTesterLogInRequest function handles a request to login as a \n * tester. @@ -176,57 +227,36 @@ testerLoggedIn = FALSE; } // respond to would be tester - sendTesterLogInResponse(); + sendTestAckResponseMsg( MSG_ID_TESTER_LOGIN_REQUEST, testerLoggedIn ); } /************************************************************************* - * @brief sendTesterLogInResponse - * The sendTesterLogInResponse function constructs a tester login response \n - * msg and queues the msg for transmit on the appropriate UART channel. + * @brief handleTestHDMessageRequest + * The handleTestHDMessageRequest function handles a request to add an \n + * HD message to the received message queue. * @details * Inputs : none - * Outputs : Off button msg constructed and queued. - * @param none - * @return TRUE if msg successfully queued for transmit, FALSE if not + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none *************************************************************************/ -BOOL sendTesterLogInResponse( void ) +void handleTestHDMessageRequest( MESSAGE_T *message ) { + MESSAGE_WRAPPER_T hdMessage; + U32 msgLen = (U32)(message->hdr.cargoLen); + U08 *msgBytes = (U08*)(&(hdMessage)); BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TESTER_LOGIN_REQUEST; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)testerLoggedIn; + memcpy( msgBytes, message->cargo, msgLen ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); + // add HD message to received message queue + result = addToMsgQueue( MSG_Q_IN, &hdMessage ); - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; + // respond to request + sendTestAckResponseMsg( MSG_ID_HD_MESSAGE, result ); } /************************************************************************* - * @brief isTestingActivated - * The isTestingActivated function determines whether a tester has successfully \n - * logged in to activate testing functionality. - * @details - * Inputs : testerLoggedIn - * Outputs : none - * @param none - * @return TRUE if a tester has logged in to activate testing, FALSE if not - *************************************************************************/ -BOOL isTestingActivated( void ) -{ - return testerLoggedIn; -} - -/************************************************************************* * @brief handleTestOffButtonStateOverrideRequest * The handleTestOffButtonStateOverrideRequest function handles a request to \n * override the state of the off button. @@ -238,57 +268,24 @@ *************************************************************************/ void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ) { - BUTTON_STATE_OVERRIDE_CARGO_T cargo; + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(BUTTON_STATE_OVERRIDE_CARGO_T) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); if ( FALSE == (BOOL)(cargo.reset) ) { - result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.button_state) ); + result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); } else { result = testResetOffButtonStateOverride(); } // respond to request - sendTestOffButtonStateOverrideResponse( result ); + sendTestAckResponseMsg( MSG_ID_OFF_BUTTON_STATE_OVERRIDE, result ); } /************************************************************************* - * @brief sendTestOffButtonStateOverrideResponse - * The sendTestOffButtonStateOverrideResponse function constructs an off \n - * button override response msg and queues the msg for transmit on the \n - * appropriate UART channel. - * @details - * Inputs : none - * Outputs : Off button override response msg constructed and queued. - * @param ack : TRUE if override successful, FALSE if not - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendTestOffButtonStateOverrideResponse( BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_STATE_OVERRIDE; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)ack; - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; -} - -/************************************************************************* * @brief handleTestStopButtonStateOverrideRequest * The handleTestStopButtonStateOverrideRequest function handles a request to \n * override the stop button state. @@ -300,53 +297,50 @@ *************************************************************************/ void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ) { - BUTTON_STATE_OVERRIDE_CARGO_T cargo; + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(BUTTON_STATE_OVERRIDE_CARGO_T) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); if ( FALSE == (BOOL)(cargo.reset) ) { - result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.button_state) ); + result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); } else { result = testResetStopButtonStateOverride(); } // respond to request - sendTestStopButtonStateOverrideResponse( result ); + sendTestAckResponseMsg( MSG_ID_STOP_BUTTON_STATE_OVERRIDE, result ); } /************************************************************************* - * @brief sendTestStopButtonStateOverrideResponse - * The sendTestStopButtonStateOverrideResponse function constructs a stop \n - * button override response msg and queues the msg for transmit on the \n - * appropriate UART channel. + * @brief handleTestAlarmLampPatternOverrideRequest + * The handleTestAlarmLampPatternOverrideRequest function handles a request to \n + * override the alarm lamp pattern. * @details * Inputs : none - * Outputs : stop button override response msg constructed and queued. - * @param ack : TRUE if override successful, FALSE if not - * @return TRUE if msg successfully queued for transmit, FALSE if not + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none *************************************************************************/ -BOOL sendTestStopButtonStateOverrideResponse( BOOL ack ) +void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ) { + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_STOP_BUTTON_STATE_OVERRIDE; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)ack; + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetCurrentLampPatternOverride( (LAMP_PATTERN_T)(cargo.state) ); + } + else + { + result = testResetCurrentLampPatternOverride(); + } + // respond to request + sendTestAckResponseMsg( MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE, result ); } +