Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rf249310122b6543b4145bb4824966535c93515d0 -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision f249310122b6543b4145bb4824966535c93515d0) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file SystemComm.c * -* @author (last) Dara Navaei -* @date (last) 20-May-2023 +* @author (last) Sean Nash +* @date (last) 10-Oct-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -45,7 +45,8 @@ #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 UI_COMM_TIMEOUT_IN_MS 7500 ///< UI has not checked in for this much time +#define UI_COMM_TIMEOUT_IN_MS 7500 ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD. +#define UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS (2 * SEC_PER_MIN * MS_PER_SECOND) ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD when in service mode. #define DG_COMM_TIMEOUT_IN_MS 1000 ///< DG has not checked in for this much time #define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm @@ -59,6 +60,9 @@ #define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm #define MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< FPGA clock speed error window +#define PENDING_ACK_LIST_OVERRIDE_UI_CHANNEL 1 ///< Value for determining UI channel when Pending ACKs are overriden. +#define PENDING_ACK_LIST_OVERRIDE_DG_CHANNEL 2 ///< Value for determining DG channel when Pending ACKs are overriden. + #pragma pack(push, 1) /// Record for transmitted message that is pending acknowledgment from receiver. @@ -111,7 +115,8 @@ 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 uiDidCommunicate = FALSE; ///< Has UI every sent a message +static OVERRIDE_U32_T pendingACKOverride = { 0, 0, 0, 0 }; ///< Pending ACK override data structure. // ********** private function prototypes ********** @@ -761,10 +766,16 @@ { if ( TRUE == uiDidCommunicate ) { - HD_OP_MODE_T opMode = getCurrentOperationMode(); - - if ( TRUE == didTimeout( timeOfLastUICheckIn, UI_COMM_TIMEOUT_IN_MS ) ) + HD_OP_MODE_T opMode = getCurrentOperationMode(); + U32 uiTO_MS = UI_COMM_TIMEOUT_IN_MS; + + // in service mode, allow up to 2 minutes for UI to check-in (for lock-down) + if ( MODE_SERV == opMode ) { + uiTO_MS = UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS; + } + if ( TRUE == didTimeout( timeOfLastUICheckIn, uiTO_MS ) ) + { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_COMM_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -780,6 +791,8 @@ if ( MODE_PRET == opMode || MODE_TREA == opMode || MODE_POST == opMode ) { activateAlarmNoData( ALARM_ID_HD_DG_COMM_TIMEOUT ); + // we don't want to keep thinking DG is in a useful mode - set it to fault mode until DG is able to report its' true mode status + setDGOpMode( DG_MODE_FAUL, 0 ); } else // Otherwise clear the alarm { @@ -866,15 +879,20 @@ static BOOL matchACKtoPendingACKList( S16 seqNo ) { BOOL result = FALSE; - U32 i; + U32 i; // Find match for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { if ( ( TRUE == pendingAckList[ i ].used ) && ( pendingAckList[ i ].seqNo == seqNo ) ) - { // Remove message pending ACK from list - pendingAckList[ i ].used = FALSE; - result = TRUE; + { + result = TRUE; + // Remove message pending ACK from list + if ( ( ( getU32OverrideValue( &pendingACKOverride ) != PENDING_ACK_LIST_OVERRIDE_UI_CHANNEL ) || ( pendingAckList[ i ].channel != COMM_BUFFER_OUT_CAN_HD_2_UI ) ) && + ( ( getU32OverrideValue( &pendingACKOverride ) != PENDING_ACK_LIST_OVERRIDE_DG_CHANNEL ) || ( pendingAckList[ i ].channel != COMM_BUFFER_OUT_CAN_HD_2_DG ) ) ) + { + pendingAckList[ i ].used = FALSE; + } break; } } @@ -912,6 +930,7 @@ U16 msgID; memcpy( &msgID, (U08*)&pendingAckList[ i ].msg[ sizeof( U08 ) + sizeof( U16) ], sizeof( U16 ) ); + if ( pendingAckList[ i ].channel != COMM_BUFFER_OUT_CAN_HD_2_DG ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_CAN_MESSAGE_NOT_ACKED_BY_UI, (U32)msgID ); @@ -1090,6 +1109,10 @@ handleTreatmentRecircCmd( message ); break; + case MSG_ID_UI_POST_TX_NEXT_REQUEST: + handlePostTxNextCmd( message ); + break; + case MSG_ID_UI_TX_END_CMD_REQUEST: handleTreatmentEndCmd( message ); break; @@ -1197,7 +1220,7 @@ } // Handle any test messages if tester has logged in successfully - if ( ( msgID > MSG_ID_FIRST_TESTER_MESSAGE ) && ( msgID <= END_OF_MSG_IDS ) && ( TRUE == isTestingActivated() ) ) + if ( ( msgID > MSG_ID_FIRST_TESTER_MESSAGE ) && ( TRUE == isTestingActivated() ) ) { switch ( msgID ) { @@ -1361,7 +1384,7 @@ handleTestSetTreatmentParameter( message ); break; - case MSG_ID_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE: + case MSG_ID_HD_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE: handleTestHDValvesBroadcastIntervalOverrideRequest( message ); break; @@ -1781,6 +1804,18 @@ handleTestHDSetRecoverFromFaultModeSignal( message ); break; + case MSG_ID_HD_RAM_STATUS_OVERRIDE: + handleTestHDRAMStatusOverrideRequest( message ); + break; + + case MSG_ID_HD_CAN_RECEIVE_ACK_MESSAGE_OVERRIDE: + handleTestHDPendingACKOverrideRequest( message ); + break; + + case MSG_ID_HD_RECIRULATION_PCT_OVERRIDE: + handleTestHDRecirulationPctOverrideRequest( message ); + break; + // The default cannot be reached in VectorCAST since the cases are run in a for loop default: // Unrecognized message ID received - ignore @@ -1789,4 +1824,54 @@ } } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetPendingACKOverride function overrides the + * pendingACKOverride variable. + * @details Inputs: none + * @details Outputs: pendingACKOverride + * @param value override for pendingACKOverride + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetPendingACKOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + pendingACKOverride.ovData = value; + pendingACKOverride.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetPendingACKOverride function resets the override + * of the pendingACKOverride variable. + * @details Inputs: none + * @details Outputs: pendingACKOverride + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetPendingACKOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + pendingACKOverride.override = OVERRIDE_RESET; + pendingACKOverride.ovData = pendingACKOverride.ovInitData; + } + + return result; +} /**@}*/