Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rdbcbd145954ef52510ac929a412e0dba42f0941b -r1fb58baf6e7e3d1f054b2a3634e233da7609dad9 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision dbcbd145954ef52510ac929a412e0dba42f0941b) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 1fb58baf6e7e3d1f054b2a3634e233da7609dad9) @@ -8,7 +8,7 @@ * @file SystemComm.c * * @author (last) Sean Nash -* @date (last) 07-Jul-2020 +* @date (last) 28-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -39,10 +39,10 @@ // ********** private definitions ********** -#define NUM_OF_CAN_OUT_BUFFERS 5 ///< # of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 7 ///< # of CAN buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 7 ///< number of CAN buffers for receiving #ifndef DEBUG_ENABLED - #define NUM_OF_MSG_IN_BUFFERS 7 ///< # of Msg buffers for receiving + #define NUM_OF_MSG_IN_BUFFERS 7 ///< number of Msg buffers for receiving #else #define NUM_OF_MSG_IN_BUFFERS 8 #define SCI1_RECEIVE_DMA_REQUEST 30 @@ -112,13 +112,13 @@ static volatile PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< list of outgoing messages that are awaiting an ACK -static volatile BOOL hdIsOnlyCANNode = TRUE; ///< flag indicating whether HD is alone on CAN bus. -static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. -static volatile BOOL dgIsCommunicating = FALSE; ///< has DG sent a message since last check -static U32 timeOfLastDGCheckIn = 0; ///< last time DG checked in -static volatile BOOL uiIsCommunicating = FALSE; ///< has UI sent a message since last check -static U32 timeOfLastUICheckIn = 0; ///< last time UI checked in -static volatile BOOL uiDidCommunicate = FALSE; ///< has UI every sent a message +static volatile BOOL hdIsOnlyCANNode = TRUE; ///< flag indicating whether HD is alone on CAN bus. +static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. +static volatile BOOL dgIsCommunicating = FALSE; ///< has DG sent a message since last check +static U32 timeOfLastDGCheckIn = 0; ///< last time DG checked in +static volatile BOOL uiIsCommunicating = FALSE; ///< has UI sent a message since last check +static U32 timeOfLastUICheckIn = 0; ///< last time UI checked in +static volatile BOOL uiDidCommunicate = FALSE; ///< has UI every sent a message #ifdef EMC_TEST_BUILD static U32 badCANCount; // test code in support of EMC testing @@ -187,7 +187,7 @@ /*********************************************************************//** * @brief - * The checkInFromDG function checks in the DG with the HD - indicating that \n + * The checkInFromDG function checks in the DG with the HD - indicating that * the DG is communicating. * @details * Inputs : none @@ -202,7 +202,7 @@ /*********************************************************************//** * @brief - * The checkInFromUI function checks in the UI with the HD - indicating that \n + * The checkInFromUI function checks in the UI with the HD - indicating that * the UI is communicating. * @details * Inputs : none @@ -218,7 +218,7 @@ /*********************************************************************//** * @brief - * The isDGCommunicating function determines whether the DG is communicating \n + * The isDGCommunicating function determines whether the DG is communicating * with the HD. * @details * Inputs : dgIsCommunicating @@ -232,7 +232,7 @@ /*********************************************************************//** * @brief - * The isUICommunicating function determines whether the UI is communicating \n + * The isUICommunicating function determines whether the UI is communicating * with the HD. * @details * Inputs : uiIsCommunicating @@ -263,7 +263,7 @@ /*********************************************************************//** * @brief - * The isHDOnlyCANNode function determines whether the HD is the only node \n + * The isHDOnlyCANNode function determines whether the HD is the only node * currently on the CAN bus. * @details * Inputs : hdIsOnlyCANNode @@ -300,7 +300,7 @@ /*********************************************************************//** * @brief - * The execSystemCommTx function manages data to be transmitted to other \n + * The execSystemCommTx function manages data to be transmitted to other * sub-systems. * @details * Inputs : none @@ -369,14 +369,14 @@ /*********************************************************************//** * @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 + * The handleCANMsgInterrupt function handles a CAN message interrupt. + * This may have occurred because a CAN packet transmission has completed + * or because a CAN packet has been received. The appropriate handler is * 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 ) @@ -420,7 +420,7 @@ /*********************************************************************//*** * @brief - * The handleUARTMsgRecvPacketInterrupt function handles a DMA UART receive \n + * The handleUARTMsgRecvPacketInterrupt function handles a DMA UART receive * packet completed interrupt. * @details * Inputs : none @@ -441,7 +441,7 @@ /*********************************************************************//** * @brief - * The handleUARTMsgXmitPacketInterrupt function handles a DMA UART transmit \n + * The handleUARTMsgXmitPacketInterrupt function handles a DMA UART transmit * packet completed interrupt. * @details * Inputs : none @@ -462,7 +462,7 @@ /*********************************************************************//** * @brief - * The initUARTAndDMA function initializes the SCI1 peripheral and the DMA \n + * The initUARTAndDMA function initializes the SCI1 peripheral and the DMA * to go with it for PC communication. * @details * Inputs : none @@ -528,12 +528,12 @@ /*********************************************************************//** * @brief - * The isCANBoxForXmit function determines whether a given CAN message box \n + * The isCANBoxForXmit function determines whether a given CAN message box * 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. *************************************************************************/ BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ) @@ -555,12 +555,12 @@ /*********************************************************************//** * @brief - * The isCANBoxForRecv function determines whether a given CAN message box \n + * The isCANBoxForRecv function determines whether a given CAN message box * 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. *************************************************************************/ BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ) @@ -606,12 +606,12 @@ /*********************************************************************//** * @brief - * The findNextHighestPriorityCANPacketToTransmit function gets the next \n - * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. \n + * The findNextHighestPriorityCANPacketToTransmit function gets the next + * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. * @details * Inputs : Output CAN Comm Buffer(s) * Outputs : none - * @return buffer with highest priority CAN packet to transmit, \n + * @return buffer with highest priority CAN packet to transmit, * COMM_BUFFER_NOT_USED if not CAN packets pending transmit found *************************************************************************/ static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ) @@ -634,12 +634,12 @@ /*********************************************************************//** * @brief - * The transmitNextCANPacket function gets the next 8 byte packet and initiates \n + * The transmitNextCANPacket function gets the next 8 byte packet and initiates * a CAN transmit on the appropriate CAN channel. * @details * Inputs : Output CAN Comm Buffers * Outputs : CAN packet transmit initiated. - * @return # of bytes transmitted + * @return number of bytes transmitted *************************************************************************/ static U32 transmitNextCANPacket( void ) { @@ -684,12 +684,12 @@ /*********************************************************************//** * @brief - * The transmitNextUARTPacket function sets up and initiates a DMA transmit \n + * The transmitNextUARTPacket function sets up and initiates a DMA transmit * of the next packet pending transmit (if any) via UART. * @details * Inputs : Output UART Comm Buffer(s) * Outputs : UART DMA transmit initiated. - * @return # of bytes transmitted + * @return number of bytes transmitted *************************************************************************/ #ifdef DEBUG_ENABLED static U32 transmitNextUARTPacket( void ) @@ -723,7 +723,7 @@ /*********************************************************************//** * @brief - * The processIncomingData function parses out messages from the Input \n + * The processIncomingData function parses out messages from the Input * Comm Buffers and adds them to the Received Message Queue. * @details * Inputs : Input Comm Buffers @@ -811,12 +811,12 @@ /*********************************************************************//** * @brief - * The consumeBufferPaddingBeforeSync function removes any bytes in a given \n + * The consumeBufferPaddingBeforeSync function removes any bytes in a given * buffer that lie before a sync byte. * @details * Inputs : none * Outputs : Any padding at front of buffer is consumed. - * @param msg : buffer : the comm buffer to process + * @param buffer the comm buffer to process * @return none *************************************************************************/ static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ) @@ -842,14 +842,14 @@ /*********************************************************************//** * @brief - * The parseMessageFromBuffer function looks for a complete message in a \n + * The parseMessageFromBuffer function looks for a complete message in a * 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 - * @return size of message if found, zero if no complete message found, \n + * @param data pointer to byte array to search for a message + * @param len number of bytes in the data to search + * @return size of message if found, zero if no complete message found, * -1 if message found but CRC fails. *************************************************************************/ static S32 parseMessageFromBuffer( U08 *data, U32 len ) @@ -894,7 +894,7 @@ /*********************************************************************//** * @brief - * The processReceivedMessages function processes any messages in the \n + * The processReceivedMessages function processes any messages in the * received message queues. * @details * Inputs : Received Message Queues @@ -944,7 +944,7 @@ /*********************************************************************//** * @brief - * The checkForCommTimeouts function checks for sub-system communication \n + * The checkForCommTimeouts function checks for sub-system communication * timeout errors. * @details * Inputs : timeOfLastDGCheckIn, timeOfLastUICheckIn @@ -968,8 +968,8 @@ /*********************************************************************//** * @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 + * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs + * within a set period of time. Assumed function is being called when a new * bad CRC is detected so a new bad CRC will be added to the list. * @details * Inputs : badCRCTimeStamps[], badCRCListIdx, badCRCListCount @@ -981,7 +981,7 @@ if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) { #ifndef DISABLE_CRC_ERROR - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_COMM_TOO_MANY_BAD_CRCS, 1 ); // 1 for HD + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_COMM_TOO_MANY_BAD_CRCS, (U32)ALARM_SOURCE_HD ); #endif } #ifdef DEBUG_ENABLED @@ -995,15 +995,15 @@ /*********************************************************************//** * @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 + * The addMsgToPendingACKList function adds a given message to the pending + * ACK list. Messages in this list will require receipt of an ACK message * 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 number 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 ) @@ -1043,13 +1043,13 @@ /*********************************************************************//** * @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 matchACKtoPendingACKList function searches the pending ACK list to + * see if the sequence # from a received ACK msg matches any. If found, * 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 ) @@ -1073,8 +1073,8 @@ /*********************************************************************//** * @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 + * The checkPendingACKList function searches the pending ACK list to + * see if any have expired. Any such messages will be queued for retransmission * and if max retries reached a fault is triggered. * @details * Inputs : pendingAckList[] @@ -1115,7 +1115,7 @@ * @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 ) @@ -1202,8 +1202,24 @@ case MSG_ID_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); - break; - + break; + + case MSG_ID_UI_NEW_TREATMENT_PARAMS: + handleTreatmentParametersFromUI( message ); + break; + + case MSG_ID_UI_START_TREATMENT: + handleUIStartTreatmentMsg( message ); + break; + + case MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS: + handleUIUserConfirmTreatmentParameters( message ); + break; + + case MSG_ID_UI_TREATMENT_END_REQUEST: + handleUIUserEndTreatmentRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; @@ -1412,6 +1428,10 @@ break; #endif + case MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER: + handleTestSetTreatmentParameter( message ); + break; + default: // TODO - unrecognized message ID received - ignore break;