Index: firmware/App/Services/SystemCommDD.c =================================================================== diff -u -r48ca7fd644c67920acc29a80b7af379d0a134d1a -r9102c5da21a15bdaf4bb3bc38795ceb064e3c443 --- firmware/App/Services/SystemCommDD.c (.../SystemCommDD.c) (revision 48ca7fd644c67920acc29a80b7af379d0a134d1a) +++ firmware/App/Services/SystemCommDD.c (.../SystemCommDD.c) (revision 9102c5da21a15bdaf4bb3bc38795ceb064e3c443) @@ -36,13 +36,14 @@ // ********** private definitions ********** -#define TD_COMM_TIMEOUT_IN_MS 2000 ///< TD has not sent any broadcast messages for this much time +#define TD_COMM_TIMEOUT_IN_MS 2000 ///< TD has not sent any broadcast messages for this much time +#define RO_COMM_TIMEOUT_IN_MS 2000 ///< RO has not sent any broadcast messages for this much time -#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 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 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 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 // ********** private data ********** @@ -73,6 +74,8 @@ static volatile BOOL ddIsOnlyCANNode = TRUE; ///< flag indicating whether DG is alone on CAN bus. static OVERRIDE_U32_T tdCommunicationStatus = {0, 0, 0, 0}; ///< has TD sent a message since last check static volatile U32 timeOfLastTDCheckIn = 0; ///< last time we received an TD broadcast +static OVERRIDE_U32_T roCommunicationStatus = {0, 0, 0, 0}; ///< has RO sent a message since last check +static volatile U32 timeOfLastROCheckIn = 0; ///< last time we received an RO broadcast // ********** private function prototypes ********** @@ -97,9 +100,47 @@ /*********************************************************************//** * @brief + * The checkInFromTD function checks in the TD with the DD - indicating that + * the TD is communicating. + * @details \b Inputs: none + * @details \b Outputs: tdCommunicationStatus, timeOfLastTDCheckIn + * @return none + *************************************************************************/ +void checkInFromTD( void ) +{ + tdCommunicationStatus.data = TRUE; + timeOfLastTDCheckIn = getMSTimerCount(); + +// if ( TRUE == isAlarmActive( ALARM_ID_DD_TD_COMM_TIMEOUT ) ) +// { +// clearAlarmCondition( ALARM_ID_DD_TD_COMM_TIMEOUT ); +// } +} + +/*********************************************************************//** + * @brief + * The checkInFromRO function checks in the RO with the DD - indicating that + * the RO is communicating. + * @details \b Inputs: none + * @details \b Outputs: roCommunicationStatus, timeOfLastROCheckIn + * @return none + *************************************************************************/ +void checkInFromRO( void ) +{ + roCommunicationStatus.data = TRUE; + timeOfLastROCheckIn = getMSTimerCount(); + +// if ( TRUE == isAlarmActive( ALARM_ID_DD_RO_COMM_TIMEOUT ) ) +// { +// clearAlarmCondition( ALARM_ID_DD_RO_COMM_TIMEOUT ); +// } +} + +/*********************************************************************//** + * @brief * The isTDCommunicating function determines whether the TD is communicating * with the DD. - * @details \b Inputs: tdIsCommunicating + * @details \b Inputs: tdCommunicationStatus * @details \b Outputs: none * @return TRUE if TD has broadcast since last call, FALSE if not *************************************************************************/ @@ -110,6 +151,19 @@ /*********************************************************************//** * @brief + * The isROCommunicating function determines whether the RO is communicating + * with the DD. + * @details \b Inputs: roCommunicationStatus + * @details \b Outputs: none + * @return TRUE if RO has broadcast since last call, FALSE if not + *************************************************************************/ +BOOL isROCommunicating( void ) +{ + return getU32OverrideValue( &roCommunicationStatus ); +} + +/*********************************************************************//** + * @brief * The isOnlyCANNode function determines whether the DD is the only node * currently on the CAN bus. * @details \b Inputs: ddIsOnlyCANNode @@ -154,7 +208,7 @@ /*********************************************************************//** * @brief * The checkForCommTimeouts function checks for sub-system communication timeout errors. - * @details \b Inputs: timeOfLastDGCheckIn, timeOfLastUICheckIn + * @details \b Inputs: timeOfLastTDCheckIn, timeOfLastROCheckIn * @details \b Outputs: possibly a comm t/o alarm * @return none *************************************************************************/ @@ -166,9 +220,14 @@ setTDOperationMode( 0, 0 ); // If TD off or not connected, consider TD mode is fault. //stopHeater( DG_TRIMMER_HEATER ); // If TD off or not connected, ensure trimmer heater is off. } + + if ( TRUE == didTimeout( timeOfLastROCheckIn, RO_COMM_TIMEOUT_IN_MS ) ) + { + roCommunicationStatus.data = FALSE; + //setROOperationMode( 0, 0 ); // If RO off or not connected, consider RO mode is fault. + } } - /*********************************************************************//** * @brief * The getInBufferID function gets the buffer ID for a given buffer index. @@ -211,11 +270,10 @@ { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_COMM_TOO_MANY_BAD_CRCS, 2 ); // 2 for DG + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_COMM_TOO_MANY_BAD_CRCS, 2 ); // 2 for DD } } - /*********************************************************************//** * @brief * The getOutBufferID function gets the buffer ID for a given buffer index. @@ -258,26 +316,44 @@ handleIncomingMessage( message ); } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief - * The testTDCommunicationStatus function sets the override + * The testTDCommunicationStatusOverride function sets the override * of the TD communication status. * @details \b Inputs: none * @details \b Outputs: tdCommunicationStatus * @param message Override message from Dialin which includes the flag * value to override for the Td communication status. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testTDCommunicationStatus( MESSAGE_T *message ) +BOOL testTDCommunicationStatusOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &tdCommunicationStatus, FALSE, TRUE ); return result; } +/*********************************************************************//** + * @brief + * The testROCommunicationStatusOverride function sets the override + * of the RO communication status. + * @details \b Inputs: none + * @details \b Outputs: roCommunicationStatus + * @param message Override message from Dialin which includes the flag + * value to override for the RO communication status. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testROCommunicationStatusOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &roCommunicationStatus, FALSE, TRUE ); + + return result; +} + /**@}*/