Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -ra7bf3ca23ea37a61000379facae628a31b3ecc59 -rf308cc4c35eab630ebbbde405cfe47d049afeafb --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision a7bf3ca23ea37a61000379facae628a31b3ecc59) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) @@ -7,8 +7,8 @@ * * @file SystemComm.c * -* @author (last) Dara Navaei -* @date (last) 10-Jun-2020 +* @author (last) Quang Nguyen +* @date (last) 03-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -28,31 +28,38 @@ #include "Utilities.h" #include "SystemCommMessages.h" +/** + * @addtogroup SystemComm + * @{ + */ + // ********** private definitions ********** -#define NUM_OF_CAN_OUT_BUFFERS 4 // # of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 6 // # of CAN buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 6 ///< Number of CAN buffers for receiving #ifndef DEBUG_ENABLED - #define NUM_OF_MSG_IN_BUFFERS 6 // # of Msg buffers for receiving + #define NUM_OF_MSG_IN_BUFFERS 6 ///< Number of Msg buffers for receiving #else - #define NUM_OF_MSG_IN_BUFFERS 7 // # of Msg buffers for receiving - 1 is UART + #define NUM_OF_MSG_IN_BUFFERS 7 #define SCI1_RECEIVE_DMA_REQUEST 30 #define SCI1_TRANSMIT_DMA_REQUEST 31 #endif #define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< if transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on +#define MAX_XMIT_RETRIES 5 ///< maximum number of retries on no transmit complete interrupt timeout -#define HD_COMM_TIMEOUT_IN_MS 2000 +#define HD_COMM_TIMEOUT_IN_MS 2000 ///< HD has not sent any broadcast messages for this much time -#define MAX_COMM_CRC_FAILURES 5 -#define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) +#define MAX_COMM_CRC_FAILURES 5 ///< maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window -#define MSG_NOT_ACKED_TIMEOUT_MS ( MS_PER_SECOND * 1 ) -#define MSG_NOT_ACKED_MAX_RETRIES 3 -#define PENDING_ACK_LIST_SIZE 25 +#define MSG_NOT_ACKED_TIMEOUT_MS ( MS_PER_SECOND * 1 ) ///< maximum time for a Denali message that requires ACK to be ACK'd +#define MSG_NOT_ACKED_MAX_RETRIES 3 ///< maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm +#define PENDING_ACK_LIST_SIZE 25 ///< maximum number of Delanli messages that can be pending ACK at any given time #pragma pack(push, 1) - + +/// Record for transmitted message that is pending acknowledgement from receiver. typedef struct { BOOL used; @@ -67,15 +74,18 @@ #pragma pack(pop) // ********** private data ********** - + +/// Array of out-going CAN buffers. const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = { COMM_BUFFER_OUT_CAN_DG_ALARM, COMM_BUFFER_OUT_CAN_DG_2_HD, - COMM_BUFFER_OUT_CAN_DG_BROADCAST, - COMM_BUFFER_OUT_CAN_PC + COMM_BUFFER_OUT_CAN_DG_BROADCAST, + COMM_BUFFER_OUT_CAN_PC, + COMM_BUFFER_OUT_CAN_DG_2_UI }; - + +/// Array of in-coming CAN buffers. const COMM_BUFFER_T MSG_IN_BUFFERS[ NUM_OF_MSG_IN_BUFFERS ] = { COMM_BUFFER_IN_CAN_HD_ALARM, @@ -88,39 +98,31 @@ COMM_BUFFER_IN_UART_PC #endif }; + +static U08 lastCANPacketSent[ CAN_MESSAGE_PAYLOAD_SIZE ]; ///< Keep last packet sent on CAN bus in case we need to re-send. +static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; ///< Keep channel last packet was sent on CAN bus in case we need to re-send. +static U32 lastCANPacketSentTimeStamp = 0; ///< Keep time last packet sent on CAN bus so we can timeout on transmission attempt. -static U08 lastCANPacketSent[ CAN_MESSAGE_PAYLOAD_SIZE ]; -static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; -static U32 lastCANPacketSentTimeStamp = 0; +static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< list of outgoing messages that are awaiting an ACK -#ifdef DEBUG_ENABLED -static U08 pcXmitPacket[ 1024 ]; -static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -#endif +static volatile BOOL dgIsOnlyCANNode = TRUE; ///< flag indicating whether DG is alone on CAN bus. +static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. +static volatile BOOL hdIsCommunicating = FALSE; ///< has HD sent a message since last check +static volatile U32 timeOfLastHDCheckIn = 0; ///< last time we received an HD broadcast -static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; // list of outgoing messages that are awaiting an ACK - -// DMA control records -static g_dmaCTRL pcDMAXmitControlRecord; // DMA transmit control record (UART-debug) -static g_dmaCTRL pcDMARecvControlRecord; // DMA receive control record (UART-debug) - -static volatile BOOL hdIsCommunicating = FALSE; // has HD sent a message since last check -static volatile U32 timeOfLastHDCheckIn = 0; // last time we received an HD broadcast - -static U32 badCRCTimeStamps[ MAX_COMM_CRC_FAILURES ]; // time of last five bad message CRCs (wrapping list) -static U32 badCRCListIdx = 0; // where next bad message CRC time stamp will go in list -static U32 badCRCListCount = 0; // # of bad CRCs in the list - +#ifdef DEBUG_ENABLED + // debug buffers + static U08 pcXmitPacket[ 1024 ]; + static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + // DMA control records + static g_dmaCTRL pcDMAXmitControlRecord; + static g_dmaCTRL pcDMARecvControlRecord; +#endif + // ********** private function prototypes ********** -#ifdef DEBUG_ENABLED - static void initUARTAndDMA( void ); - static U32 transmitNextUARTPacket( void ); -#endif +static void clearCANXmitBuffers( void ); -static BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ); -static BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ); - static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ); static U32 transmitNextCANPacket( void ); @@ -136,13 +138,17 @@ static BOOL matchACKtoPendingACKList( S16 seqNo ); static void checkPendingACKList( void ); -/************************************************************************* - * @brief initSystemComm +#ifdef DEBUG_ENABLED + static void initUARTAndDMA( void ); + static U32 transmitNextUARTPacket( void ); +#endif + +/*********************************************************************//** + * @brief * The initSystemComm function initializes the SystemComm module. * @details * Inputs : none * Outputs : SystemComm module initialized. - * @param none * @return none *************************************************************************/ void initSystemComm( void ) @@ -154,45 +160,50 @@ initUARTAndDMA(); #endif - // initialize bad message CRC list - for ( i = 0; i < MAX_COMM_CRC_FAILURES; i++ ) - { - badCRCTimeStamps[ i ] = 0; - } - + // initialize bad message CRC time windowed count + initTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC, MAX_COMM_CRC_FAILURES, MAX_COMM_CRC_FAILURE_WINDOW_MS ); + // initialize pending ACK list for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { pendingAckList[ i ].used = FALSE; } } -/************************************************************************* +/*********************************************************************//** * @brief * The isHDCommunicating function determines whether the HD is communicating \n * with the DG. * @details * Inputs : hdIsCommunicating * Outputs : none - * @param none * @return TRUE if HD has broadcast since last call, FALSE if not *************************************************************************/ BOOL isHDCommunicating( void ) { - BOOL result = hdIsCommunicating; - - hdIsCommunicating = FALSE; - - return result; + return hdIsCommunicating; +} + +/*********************************************************************//** + * @brief + * The isDGOnlyCANNode function determines whether the DG is the only node \n + * currently on the CAN bus. + * @details + * Inputs : dgIsOnlyCANNode + * Outputs : none + * @return TRUE if DG is only node on CAN bus, FALSE if not + *************************************************************************/ +BOOL isDGOnlyCANNode( void ) +{ + return dgIsOnlyCANNode; } -/************************************************************************* - * @brief execSystemCommRx +/*********************************************************************//** + * @brief * The execSystemCommRx function manages received data from other sub-systems. * @details * Inputs : none - * Outputs : none - * @param none + * Outputs : Incoming frames processed. * @return none *************************************************************************/ void execSystemCommRx( void ) @@ -210,32 +221,63 @@ checkPendingACKList(); } -/************************************************************************* - * @brief execSystemCommTx +/*********************************************************************//** + * @brief * The execSystemCommTx function manages data to be transmitted to other \n * sub-systems. * @details * Inputs : none - * Outputs : none - * @param none + * Outputs : Next outgoing frame transmitted. * @return none *************************************************************************/ void execSystemCommTx( void ) -{ - // if CAN transmitter is idle, start transmitting any pending packets - if ( FALSE == isCAN1TransmitInProgress() ) - { - transmitNextCANPacket(); - } - else - { // generally, transmitter should not be busy at time of this function call - check timeout just in case so we don't get stuck waiting forever - if ( TRUE == didTimeout( lastCANPacketSentTimeStamp, CAN_XMIT_PACKET_TIMEOUT_MS ) ) - { - // TODO - depending on why we timed out, we may need to reset CAN controller??? - // assume last packet was not successfully transmitted. TODO - Re-send last packet? Or should we move on? - canTransmit( canREG1, lastCANPacketSentChannel, lastCANPacketSent ); - } - } +{ + // don't bother with transmitting if no other nodes on CAN bus + if ( FALSE == dgIsOnlyCANNode ) + { + // if CAN transmitter is idle, start transmitting any pending packets + if ( FALSE == isCAN1TransmitInProgress() ) + { + transmitNextCANPacket(); + } + else + { + // generally, transmitter should not be busy at time of this function call - check timeout just in case so we don't get stuck waiting forever + if ( TRUE == didTimeout( lastCANPacketSentTimeStamp, CAN_XMIT_PACKET_TIMEOUT_MS ) ) + { + // assume last packet was not successfully transmitted. Re-send last packet. + if ( ++canXmitRetryCtr <= MAX_XMIT_RETRIES ) + { + // ensure we have a previous CAN packet/channel to resend - canTransmit() channel param MUST be valid + if ( ( lastCANPacketSentChannel > COMM_BUFFER_NOT_USED ) && ( lastCANPacketSentChannel <= COMM_BUFFER_LAST_CAN_BUFFER ) ) + { + canTransmit( canREG1, lastCANPacketSentChannel, lastCANPacketSent ); + } +#ifdef DEBUG_ENABLED + { + char debugStr[100]; + strcpy( debugStr, "SystemComm-DG resend Last Frame.\n" ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } +#endif + } + // we must be only node on CAN bus - nobody is ACKing our transmitted frames + else + { + dgIsOnlyCANNode = TRUE; // set only CAN node flag + canXmitRetryCtr = MAX_XMIT_RETRIES; + signalCANXmitsCompleted(); // clear pending xmit flag + clearCANXmitBuffers(); // clear xmit buffers - nothing is going out right now +#ifdef DEBUG_ENABLED + char debugStr[100]; + strcpy( debugStr, "SystemComm-DG is only node.\n" ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); +#endif + } // end - are we retrying xmit or are we alone on CAN bus + } // end - pending xmit timeout? + } // end - transmit in progress or not + } // end - DG not alone on CAN bus #ifdef DEBUG_ENABLED // if UART transmitter is idle, start transmitting any pending packets @@ -246,16 +288,16 @@ #endif } -/************************************************************************* - * @brief handleCANMsgInterrupt +/*********************************************************************//** + * @brief * The handleCANMsgInterrupt function handles a CAN message interrupt. \n * This may have occurred because a CAN packet transmission has completed \n * or because a CAN packet has been received. The appropriate handler is \n * called. * @details * Inputs : none * Outputs : message interrupt handled - * @param srcCANBox : which CAN message box triggered this interrupt + * @param srcCANBox which CAN message box triggered this interrupt * @return none *************************************************************************/ void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ) @@ -294,14 +336,13 @@ } } -/************************************************************************* - * @brief handleUARTMsgRecvPacketInterrupt +/*********************************************************************//** + * @brief * The handleUARTMsgRecvPacketInterrupt function handles a DMA UART receive \n * packet completed interrupt. * @details * Inputs : none * Outputs : none - * @param none * @return none *************************************************************************/ #ifdef DEBUG_ENABLED @@ -316,14 +357,13 @@ } #endif -/************************************************************************* - * @brief handleUARTMsgXmitPacketInterrupt +/*********************************************************************//** + * @brief * The handleUARTMsgXmitPacketInterrupt function handles a DMA UART transmit \n * packet completed interrupt. * @details * Inputs : none * Outputs : none - * @param none * @return none *************************************************************************/ #ifdef DEBUG_ENABLED @@ -338,14 +378,13 @@ } #endif -/************************************************************************* - * @brief initUARTAndDMA +/*********************************************************************//** + * @brief * The initUARTAndDMA function initializes the SCI1 peripheral and the DMA \n * to go with it for PC communication. * @details * Inputs : none * Outputs : SCI1 and DMA initialized - * @param none * @return none *************************************************************************/ #ifdef DEBUG_ENABLED @@ -404,17 +443,17 @@ } #endif -/************************************************************************* - * @brief isCANBoxForXmit +/*********************************************************************//** + * @brief * The isCANBoxForXmit function determines whether a given CAN message box \n * is configured for transmit. * @details * Inputs : CAN_OUT_BUFFERS[] * Outputs : none - * @param srcCANBox : which CAN message box to check + * @param srcCANBox which CAN message box to check * @return TRUE if the given CAN message box is configured for transmit, FALSE if not. *************************************************************************/ -static BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ) +BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ) { BOOL result = FALSE; U32 i; @@ -431,17 +470,17 @@ return result; } -/************************************************************************* - * @brief isCANBoxForRecv +/*********************************************************************//** + * @brief * The isCANBoxForRecv function determines whether a given CAN message box \n * is configured for receiving. * @details * Inputs : MSG_IN_BUFFERS[] * Outputs : none - * @param srcCANBox : which CAN message box to check + * @param srcCANBox which CAN message box to check * @return TRUE if the given CAN message box is configured for receiving, FALSE if not. *************************************************************************/ -static BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ) +BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ) { BOOL result = FALSE; U32 i; @@ -456,6 +495,24 @@ } return result; +} + +/*********************************************************************//** + * @brief + * The clearCANXmitBuffers function clears all CAN transmit buffers. + * @details + * Inputs : CAN_OUT_BUFFERS[] + * Outputs : CAN transmit buffers cleared. + * @return none + *************************************************************************/ +static void clearCANXmitBuffers( void ) +{ + U32 i; + + for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) + { + clearBuffer( CAN_OUT_BUFFERS[ i ] ); + } } @@ -464,14 +521,13 @@ *************************************************************************/ -/************************************************************************* - * @brief findNextHighestPriorityCANPacketToTransmit +/*********************************************************************//** + * @brief * The findNextHighestPriorityCANPacketToTransmit function gets the next \n * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. \n * @details * Inputs : Output CAN Comm Buffer(s) * Outputs : none - * @param msg : none * @return buffer with highest priority CAN packet to transmit, \n * COMM_BUFFER_NOT_USED if not CAN packets pending transmit found *************************************************************************/ @@ -493,14 +549,13 @@ return result; } -/************************************************************************* - * @brief transmitNextCANPacket +/*********************************************************************//** + * @brief * The transmitNextCANPacket function gets the next 8 byte packet and initiates \n * a CAN transmit on the appropriate CAN channel. * @details * Inputs : Output CAN Comm Buffers * Outputs : CAN packet transmit initiated. - * @param msg : none * @return # of bytes transmitted *************************************************************************/ static U32 transmitNextCANPacket( void ) @@ -532,26 +587,25 @@ { signalCANXmitsCompleted(); // TODO - shouldn't get here, but let's see if we do - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_SOFTWARE_FAULT, (U32)mBox ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, (U32)mBox ) } } else { // TODO - shouldn't get here - just testing - set first data to new s/w fault enum later - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, (U32)buffer, (U32)dataSize ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, (U32)buffer, (U32)dataSize ) } } return result; } -/************************************************************************* - * @brief transmitNextUARTPacket +/*********************************************************************//** + * @brief * The transmitNextUARTPacket function sets up and initiates a DMA transmit \n * of the next packet pending transmit (if any) via UART. * @details * Inputs : Output UART Comm Buffer(s) * Outputs : UART DMA transmit initiated. - * @param msg : none * @return # of bytes transmitted *************************************************************************/ #ifdef DEBUG_ENABLED @@ -585,14 +639,13 @@ *************************************************************************/ -/************************************************************************* - * @brief processIncomingData +/*********************************************************************//** + * @brief * The processIncomingData function parses out messages from the Input \n * Comm Buffers and adds them to the Received Message Queue. * @details * Inputs : Input Comm Buffers * Outputs : Parsed message(s) added to Received Message Queue - * @param msg : none * @return none *************************************************************************/ static void processIncomingData( void ) @@ -622,6 +675,9 @@ U32 bytesPeeked = peekFromCommBuffer( MSG_IN_BUFFERS[ i ], data, MIN( numOfBytesInBuffer, sizeof( MESSAGE_WRAPPER_T ) + 1 ) ); S32 msgSize = parseMessageFromBuffer( data, bytesPeeked ); + dgIsOnlyCANNode = FALSE; // if we're getting a message, we can't be alone + canXmitRetryCtr = 0; + if ( msgSize > 0 ) // valid, complete message found? { MESSAGE_WRAPPER_T rcvMsg; @@ -646,7 +702,7 @@ // if message from HD broadcast channel, update HD comm status if ( COMM_BUFFER_IN_CAN_HD_BROADCAST == MSG_IN_BUFFERS[ i ] ) { - hdIsCommunicating = TRUE; + hdIsCommunicating = TRUE; timeOfLastHDCheckIn = getMSTimerCount(); } } @@ -667,14 +723,14 @@ } } -/************************************************************************* - * @brief consumeBufferPaddingBeforeSync +/*********************************************************************//** + * @brief * The consumeBufferPaddingBeforeSync function removes any bytes in a given \n * buffer that lie before a sync byte. * @details * Inputs : none - * Outputs : none - * @param msg : buffer : the comm buffer to process + * Outputs : Any padding at front of comm buffer is consumed. + * @param buffer the comm buffer to process * @return none *************************************************************************/ static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ) @@ -698,15 +754,15 @@ } } -/************************************************************************* - * @brief parseMessageFromBuffer +/*********************************************************************//** + * @brief * The parseMessageFromBuffer function looks for a complete message in a \n * given buffer. If a message is found, its size is returned. * @details * Inputs : none - * Outputs : none - * @param data : pointer to byte array to search for a message - * @param len : # of bytes in the data to search + * Outputs : If a complete message can be found in buffer contents, it is parsed out. + * @param data pointer to byte array to search for a message + * @param len # of bytes in the data to search * @return size of message if found, zero if no complete message found, \n * -1 if message found but CRC fails. *************************************************************************/ @@ -750,14 +806,13 @@ return result; } -/************************************************************************* - * @brief processReceivedMessages +/*********************************************************************//** + * @brief * The processReceivedMessages function processes any messages in the \n * received message queues. * @details * Inputs : Received Message Queues * Outputs : Message(s) processed. - * @param msg : none * @return none *************************************************************************/ static void processReceivedMessages( void ) @@ -797,14 +852,13 @@ } } -/************************************************************************* - * @brief checkForCommTimeouts +/*********************************************************************//** + * @brief * The checkForCommTimeouts function checks for sub-system communication \n * timeout errors. * @details * Inputs : timeOfLastDGCheckIn, timeOfLastUICheckIn * Outputs : possibly a comm t/o alarm - * @param none * @return none *************************************************************************/ static void checkForCommTimeouts( void ) @@ -818,8 +872,8 @@ } } -/************************************************************************* - * @brief checkTooManyBadMsgCRCs +/*********************************************************************//** + * @brief * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs \n * within a set period of time. Assumed function is being called when a new \n * bad CRC is detected so a new bad CRC will be added to the list. @@ -829,34 +883,32 @@ * @return none *************************************************************************/ static void checkTooManyBadMsgCRCs( void ) -{ - U32 listTimeInMS; - - // replace oldest bad CRC in list with this new one - badCRCTimeStamps[ badCRCListIdx ] = getMSTimerCount(); - // move list index to next position (may wrap) - badCRCListIdx = INC_WRAP( badCRCListIdx, 0, MAX_COMM_CRC_FAILURES - 1 ); - // update list count - badCRCListCount = INC_CAP( badCRCListCount, MAX_COMM_CRC_FAILURES ); - // check if too many bad CRCs in window of time - listTimeInMS = calcTimeSince( badCRCTimeStamps[ badCRCListIdx ] ); - if ( ( badCRCListCount >= MAX_COMM_CRC_FAILURES ) && ( listTimeInMS <= MAX_COMM_CRC_FAILURE_WINDOW_MS ) ) - { - activateAlarmNoData( ALARM_ID_COMM_TOO_MANY_BAD_CRCS ); +{ + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_COMM_TOO_MANY_BAD_CRCS, 2 ); // 2 for DG } +#ifdef DEBUG_ENABLED + { + char debugStr[100]; + + strcpy( debugStr, "SystemComm-DG-Bad Msg CRC.\n" ); + sendDebugDataToUI( (U08*)debugStr ); + } +#endif } -/************************************************************************* - * @brief addMsgToPendingACKList +/*********************************************************************//** + * @brief * The addMsgToPendingACKList function adds a given message to the pending \n * ACK list. Messages in this list will require receipt of an ACK message \n * for this particular message within a limited time. * @details * Inputs : pendingAckList[] * Outputs : pendingAckList[] - * @param msg : pointer to msg within the message data - * @param msgData : pointer to message data to add to pending ACK list - * @param len : # of bytes of message data + * @param msg pointer to msg within the message data + * @param msgData pointer to message data to add to pending ACK list + * @param len # of bytes of message data * @return TRUE if message added successfully, FALSE if not *************************************************************************/ BOOL addMsgToPendingACKList( MESSAGE_T *msg, COMM_BUFFER_T channel, U08 *msgData, U32 len ) @@ -892,15 +944,15 @@ return result; } -/************************************************************************* - * @brief matchACKtoPendingACKList +/*********************************************************************//** + * @brief * The matchACKtoPendingACKList function searches the pending ACK list to \n * see if the sequence # from a received ACK msg matches any. If found, \n * the list entry is removed. * @details * Inputs : pendingAckList[] * Outputs : pendingAckList[] - * @param seqNo : sequence # to match to an entry in the list + * @param seqNo sequence # to match to an entry in the list * @return TRUE if a match was found, FALSE if not *************************************************************************/ static BOOL matchACKtoPendingACKList( S16 seqNo ) @@ -922,15 +974,14 @@ return result; } -/************************************************************************* - * @brief checkPendingACKList +/*********************************************************************//** + * @brief * The checkPendingACKList function searches the pending ACK list to \n * see if any have expired. Any such messages will be queued for retransmission \n * and if max retries reached a fault is triggered. * @details * Inputs : pendingAckList[] * Outputs : pendingAckList[] - * @param none * @return none *************************************************************************/ static void checkPendingACKList( void ) @@ -939,33 +990,35 @@ // find expired messages pending ACK for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { + { // pending ACK expired? if ( ( TRUE == pendingAckList[ i ].used ) && ( TRUE == didTimeout( pendingAckList[ i ].timeStamp, MSG_NOT_ACKED_TIMEOUT_MS ) ) ) - { + { // if retries left, reset and resend pending message if ( pendingAckList[ i ].retries > 0 ) { // re-queue message for transmit pendingAckList[ i ].retries--; pendingAckList[ i ].timeStamp = getMSTimerCount(); addToCommBuffer( pendingAckList[ i ].channel, pendingAckList[ i ].msg, pendingAckList[ i ].msgSize ); - } + } + // if no retries left, alarm else { U16 msgID; memcpy( &msgID, &pendingAckList[ i ].msg[ sizeof( U08 ) + sizeof( U16) ], sizeof( U16 ) ); - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_CAN_MESSAGE_NOT_ACKED, (U32)msgID ); + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_CAN_MESSAGE_NOT_ACKED, (U32)msgID ); + pendingAckList[ i ].used = FALSE; // take pending message off of list } } } } -/************************************************************************* - * @brief processReceivedMessage +/*********************************************************************//** + * @brief * The processReceivedMessage function processes a given message. * @details * Inputs : none * Outputs : message processed - * @param message : pointer to message to process + * @param message pointer to message to process * @return none *************************************************************************/ static void processReceivedMessage( MESSAGE_T *message ) @@ -1069,7 +1122,7 @@ handleTestROPumpDataBroadcastIntervalOverrideRequest( message ); break; - case MSG_ID_DRAIN_PUMP_SET_PT_OVERRIDE: + case MSG_ID_DRAIN_PUMP_SET_RPM_OVERRIDE: handleTestDrainPumpSetPointOverrideRequest( message ); break; @@ -1087,6 +1140,7 @@ case MSG_ID_DG_SAFETY_SHUTDOWN_OVERRIDE: handleTestDGSafetyShutdownOverrideRequest( message ); + break; case MSG_ID_TEMPERATURE_SENSORS_VALUE_OVERRIDE: handleTestTemperatureSensorsOverrideRequest ( message ); @@ -1098,12 +1152,37 @@ case MSG_ID_HEATERS_PUBLISH_INTERVAL_ORVERRIDE: handleTestHeatersDataPublishOverrideRequest ( message ); - break; + break; + case MSG_ID_CONDUCTIVITY_OVERRIDE: + handleTestSetConductivityOverrideRequest ( message ); + break; + + case MSG_ID_CONDUCTIVITY_PUBLISH_INTERVAL_OVERRIDE: + handleTestSetConductivityDataPublishIntervalOverrideRequest ( message ); + break; + + case MSG_ID_DG_ACCEL_OVERRIDE: + handleTestDGAccelOverrideRequest( message ); + break; + + case MSG_ID_DG_ACCEL_MAX_OVERRIDE: + handleTestDGAccelMaxOverrideRequest( message ); + break; + + case MSG_ID_DG_ACCEL_SEND_INTERVAL_OVERRIDE: + handleTestDGAccelBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_DG_ACCEL_SET_CALIBRATION: + handleSetAccelCalibration( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; } } } - + +/**@}*/