Index: TestSupport.c =================================================================== diff -u -rd797fb40d36f986ae2d8b169b9d133ffb0d90453 -rbb4952a602ec8ee91f2d04bd24e8270b7511dcaf --- TestSupport.c (.../TestSupport.c) (revision d797fb40d36f986ae2d8b169b9d133ffb0d90453) +++ TestSupport.c (.../TestSupport.c) (revision bb4952a602ec8ee91f2d04bd24e8270b7511dcaf) @@ -1,21 +1,23 @@ /************************************************************************** * -* Copyright (c) 2021 Diality Inc. - All Rights Reserved. +* Copyright (c) 2021-2023 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 TestSupport.c +* @file TestSupport.c * -* @author (last) Sean Nash -* @date (last) 10-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 19-Oct-2023 * -* @author (original) Sean Nash -* @date (original) 10-Aug-2021 +* @author (original) Sean Nash +* @date (original) 10-Aug-2021 * ***************************************************************************/ #include "Common.h" +#include "SystemCommMessages.h" +#include "Timers.h" /** * @addtogroup TestSupport @@ -24,15 +26,85 @@ // ********** private definitions ********** +#define TEST_CONFIG_ENABLE_KEY 0xDABA36B2 ///< Release software configuration enable key. +#define TEST_CONFIG_DISABLE_KEY 0x00000000 ///< Release software configuration disable key. +#define DIALIN_CHECK_IN_TIMEOUT_MS ( 8 * MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ) ///< Dialin check in timeout in milliseconds. // ********** private data ********** +static U32 testConfig[ NUM_OF_TEST_CONFIGS ]; ///< Release software configuration. +static U32 dialinCheckInTimeStamp; ///< Dialin checkin time stamp. +static BOOL signalRecoverFromFaultMode; ///< Boolean flag to allow the user to recover from fault mode in test configurations. // ********** private function prototypes ********** /*********************************************************************//** * @brief + * The getU08OverrideValue function extracts the appropriate U08 + * value from a given U32 override record according to the record state. + * @details Inputs: none + * @details Outputs: none + * @param ovU32 pointer to a floating point override record + * @return overridden U08 point value from the record + *************************************************************************/ +U08 getU08OverrideValue( OVERRIDE_U32_T *ovU32 ) +{ + U08 result = (U08)( ovU32->data & MASK_OFF_U32_MSBS ); + + if ( OVERRIDE_KEY == ovU32->override ) + { + result = (U08)( ovU32->ovData & MASK_OFF_U32_MSBS ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getU16OverrideValue function extracts the appropriate U16 + * value from a given U32 override record according to the record state. + * @details Inputs: none + * @details Outputs: none + * @param ovU32 pointer to a floating point override record + * @return overridden U16 point value from the record + *************************************************************************/ +U16 getU16OverrideValue( OVERRIDE_U32_T *ovU32 ) +{ + U16 result = (U16)( ovU32->data & MASK_OFF_MSW ); + + if ( OVERRIDE_KEY == ovU32->override ) + { + result = (U16)( ovU32->ovData & MASK_OFF_MSW ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getS32OverrideValue function extracts the appropriate signed integer + * value from a given signed integer override record according to the + * record state. + * @details Inputs: none + * @details Outputs: none + * @param ovS32 pointer to an unsigned integer override record + * @return either the real or overridden signed integer value from the record + *************************************************************************/ +S32 getS32OverrideValue( OVERRIDE_S32_T *ovS32 ) +{ + S32 result = ovS32->data; + + if ( OVERRIDE_KEY == ovS32->override ) + { + result = ovS32->ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getU32OverrideValue function extracts the appropriate unsigned integer * value from a given unsigned integer override record according to the * record state. @@ -74,4 +146,241 @@ return result; } +// ********** Release software configurations functions ********** + +/*********************************************************************//** + * @brief + * The initTestConfigs function initializes the test software configurations. + * @details Inputs: none + * @details Outputs: signalRecoverFromFaultMode + * @return none + *************************************************************************/ +void initTestConfigs( void ) +{ + resetAllTestConfigs(); + signalRecoverFromFaultMode = FALSE; +} + +/*********************************************************************//** + * @brief + * The setTestConfig function sets the test configuration. + * Must be logged into HD/DG. + * @details Inputs: none + * @details Outputs: testConfig + * @param config which is the configuration to set + * @return TRUE if the set configuration was successful otherwise, FALSE + *************************************************************************/ +BOOL setTestConfig( TEST_CONFIG_T config ) +{ + BOOL status = FALSE; + + if ( ( config < NUM_OF_TEST_CONFIGS ) && ( TRUE == isTestingActivated() ) ) + { + testConfig[ config ] = TEST_CONFIG_ENABLE_KEY; + status = TRUE; + } + else + { +#ifdef _DG_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_DG_INVALID_TEST_CONFIG_SELECTED, config ) +#endif +#ifdef _HD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_TEST_CONFIG_SELECTED, config ) +#endif + } + + return status; +} + +/*********************************************************************//** + * @brief + * The resetTestConfig function resets the test configuration. + * Must be logged into HD/DG. + * @details Inputs: none + * @details Outputs: testConfig + * @param config which is the configuration to reset + * @return TRUE if the reset configuration was successful otherwise, FALSE + *************************************************************************/ +BOOL resetTestConfig( TEST_CONFIG_T config ) +{ + BOOL status = FALSE; + + if ( ( config < NUM_OF_TEST_CONFIGS ) && ( TRUE == isTestingActivated() ) ) + { + testConfig[ config ] = TEST_CONFIG_DISABLE_KEY; + status = TRUE; + } + else + { +#ifdef _DG_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_DG_INVALID_TEST_CONFIG_SELECTED, config ) +#endif +#ifdef _HD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_TEST_CONFIG_SELECTED, config ) +#endif + } + + return status; +} + +/*********************************************************************//** + * @brief + * The getTestConfigStatus function gets the status of the provided test + * configuration. Must be logged into HD/DG. + * @details Inputs: testConfig + * @details Outputs: none + * @param config the test configuration + * @return TRUE if the test configuration is enabled otherwise, FALSE + *************************************************************************/ +BOOL getTestConfigStatus( TEST_CONFIG_T config ) +{ + BOOL status = FALSE; + + if ( ( TEST_CONFIG_ENABLE_KEY == testConfig[ config ] ) && ( TRUE == isTestingActivated() ) ) + { + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The sendTestConfigStatusToDialin function sends the test configuration + * status to dialin. + * @details Inputs: none + * @details Outputs: testConfig + * @return TRUE if the serialization is successful otherwise, FALSE + *************************************************************************/ +BOOL sendTestConfigStatusToDialin( void ) +{ + BOOL result = FALSE; + MESSAGE_T msg; + TEST_CONFIG_T config; + U32 configStatus = 0; + U08 *payloadPtr = msg.payload; + + if ( TRUE == isTestingActivated() ) + { + // Create a message record + blankMessage( &msg ); +#ifdef _DG_ + msg.hdr.msgID = MSG_ID_DG_SEND_TEST_CONFIGURATION; +#endif +#ifdef _HD_ + msg.hdr.msgID = MSG_ID_HD_SEND_TEST_CONFIGURATION; +#endif + msg.hdr.payloadLen = sizeof( testConfig ); + + for ( config = TEST_CONFIG_FIRST; config < NUM_OF_TEST_CONFIGS; ++config ) + { + configStatus = (U32)getTestConfigStatus( config ); + + memcpy( payloadPtr, &configStatus, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + } + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The resetAllTestConfigs function resets all of the test configurations. + * Must be logged into HD/DG. + * @details Inputs: none + * @details Outputs: testConfig + * @return TRUE if the reset was successful otherwise, FALSE + *************************************************************************/ +BOOL resetAllTestConfigs( void ) +{ + BOOL status = FALSE; + + if ( TRUE == isTestingActivated() ) + { + TEST_CONFIG_T config; + + for ( config = TEST_CONFIG_FIRST; config < NUM_OF_TEST_CONFIGS; ++config ) + { + testConfig[ config ] = TEST_CONFIG_DISABLE_KEY; + } + + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The setDialinCheckInTimeStamp function set the dialin check in timestamp. + * @details Inputs: none + * @details Outputs: dialinCheckInTimeStamp + * @return none + *************************************************************************/ +void setDialinCheckInTimeStamp( void ) +{ + dialinCheckInTimeStamp = getMSTimerCount(); +} + +/*********************************************************************//** + * @brief + * The hasDialinCheckInExpired function checks whether the check in from + * dialin has expired or not. + * @details Inputs: none + * @details Outputs: dialinCheckInTimeStamp + * @return TRUE if the check in has been expired otherwise, FALSE + *************************************************************************/ +BOOL hasDialinCheckInExpired( void ) +{ + BOOL status = FALSE; + + if ( ( TRUE == didTimeout( dialinCheckInTimeStamp, DIALIN_CHECK_IN_TIMEOUT_MS ) ) && ( TRUE == isTestingActivated() ) ) + { + // If the dialin check in has timed out and tester has logged in check for the expiration value + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The setRecoverFromFaultModeSignal function sets the recover from fault + * mode signal upon receiving it from the user. + * @details Inputs: none + * @details Outputs: signalRecoverFromFaultMode + * @return none + *************************************************************************/ +void setRecoverFromFaultModeSignal( void ) +{ + if ( TRUE == isTestingActivated() ) + { + signalRecoverFromFaultMode = TRUE; + } +} + +/*********************************************************************//** + * @brief + * The hasRecoverFromFaultModeBeenSet function returns the status of the + * recover from fault mode signal + * @details Inputs: none + * @details Outputs: signalRecoverFromFaultMode + * @return TRUE is the user is logged in and the signal is TRUE, otherwise FLASE + *************************************************************************/ +BOOL hasRecoverFromFaultModeBeenSet( void ) +{ + BOOL status = FALSE; + + if ( TRUE == isTestingActivated() ) + { + status = signalRecoverFromFaultMode; + } + + return status; +} + /**@}*/