Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r736cc5b56cc9c784ab1d8fc8687a73d190c35759 -r0ca939ac0e3ad7d432152a89135075bfd67246df --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 736cc5b56cc9c784ab1d8fc8687a73d190c35759) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 0ca939ac0e3ad7d432152a89135075bfd67246df) @@ -42,13 +42,14 @@ #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Temperatures.h" +#include "Timers.h" #include "Valves.h" #include "WatchdogMgmt.h" - /** - * @addtogroup HDInitAndPOSTMode - * @{ - */ +/** + * @addtogroup HDInitAndPOSTMode + * @{ + */ // ********** private definitions ********** @@ -60,6 +61,8 @@ /// Maximum wait time for UI to send its final POST result. #define POST_UI_MAX_WAIT_TIME ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define SN_INST_SEND_TO_UI_TIME_INTERVAL_MS 500 ///< Serial Number and institutional record send time interval in milliseconds. + // ********** private data ********** static HD_POST_STATE_T postState; ///< Current state of initialize and POST mode. @@ -77,6 +80,7 @@ static UI_VERSIONS_T uiVersion = { 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by UI. static DG_VERSIONS_T dgVersion = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by DG. static U32 startPOSTDelayCounter = 0; ///< Start POST delay counter. +static U32 SNAndInstConfigSendStartTimeMS; ///< serial number and institutional configuration send start time milliseconds. extern U32 savedResetReasonCode; ///< Saved reset reason code from sys_startup.c. @@ -87,6 +91,8 @@ static SELF_TEST_STATUS_T execFWCompatibilityTest( void ); static SELF_TEST_STATUS_T execUITest( void ); +static void sendSerialNumberAndInstitutionalToUI( void ); + /*********************************************************************//** * @brief * The initInitAndPOSTMode function initializes the Initialize & POST Mode module. @@ -96,17 +102,18 @@ *************************************************************************/ void initInitAndPOSTMode( void ) { - postState = POST_STATE_START; - postCompleted = FALSE; - postPassed = FALSE; - tempPOSTPassed = TRUE; - uiPOSTPassed = FALSE; - dgPOSTPassed = FALSE; - uiPOSTResultReceived = FALSE; - dgPOSTResultReceived = FALSE; - waitForUIPostTimerCtr = 0; - postCompleteDelayTimerCtr = 0; - startPOSTDelayCounter = 0; + postState = POST_STATE_START; + postCompleted = FALSE; + postPassed = FALSE; + tempPOSTPassed = TRUE; + uiPOSTPassed = FALSE; + dgPOSTPassed = FALSE; + uiPOSTResultReceived = FALSE; + dgPOSTResultReceived = FALSE; + waitForUIPostTimerCtr = 0; + postCompleteDelayTimerCtr = 0; + startPOSTDelayCounter = 0; + SNAndInstConfigSendStartTimeMS = getMSTimerCount(); } /*********************************************************************//** @@ -157,6 +164,8 @@ // Ignore stop button in this mode. } + sendSerialNumberAndInstitutionalToUI(); + // Execute current POST state *Note - these switch cases must be in same order as enum HD_POST_States switch ( postState ) { @@ -609,4 +618,29 @@ return result; } +/*********************************************************************//** + * @brief + * The sendSerialNumberAndInstitutionalToUI function sends the serial number + * and institutional records to the UI unsolicited. + * @details Inputs: SNAndInstConfigSendStartTimeMS, postState + * @details Outputs: SNAndInstConfigSendStartTimeMS + * @return none + *************************************************************************/ +static void sendSerialNumberAndInstitutionalToUI( void ) +{ + if ( ( TRUE == didTimeout( SNAndInstConfigSendStartTimeMS, SN_INST_SEND_TO_UI_TIME_INTERVAL_MS ) ) && ( postState > POST_STATE_NVDATAMGMT ) ) + { + MESSAGE_T message; + + // Create a message object with the payload length to be 0 for the institutional message + message.hdr.msgID = 0; + message.hdr.payloadLen = 0; + + handleHDSerialNumberRequest(); + handleSendInstitutionalRecordToUI( &message ); + + SNAndInstConfigSendStartTimeMS = getMSTimerCount(); + } +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rca8a4a4cf6d2c59d9296c3abdf314765550a2624 -r0ca939ac0e3ad7d432152a89135075bfd67246df --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ca8a4a4cf6d2c59d9296c3abdf314765550a2624) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 0ca939ac0e3ad7d432152a89135075bfd67246df) @@ -3354,23 +3354,28 @@ blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_SERIAL_NUMBER_RESPONSE; - // Add 1 byte for null terminator - msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; - - for ( i = 0; i < MAX_TOP_LEVEL_SN_CHARS; i++ ) + // Check if the first element of the serial number is not 0 meaning that we are not sending empty serial number + // to the UI + if ( system.topLevelSN[0] != 0 ) { - // NOTE: A local variable was created to avoid system.topLevelSN in the messages list - // NOTE: For loop was used instead of memory copy to ensure it is not parsed in the messages list script - localTopLevelSN.topLevelSN[ i ] = system.topLevelSN[ i ]; - } + // Add 1 byte for null terminator + msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; - // Fill message payload - memcpy( payloadPtr, &localTopLevelSN, sizeof( LOCAL_TOP_SN_T ) ); - payloadPtr += MAX_TOP_LEVEL_SN_CHARS; - *payloadPtr = 0; + for ( i = 0; i < MAX_TOP_LEVEL_SN_CHARS; i++ ) + { + // NOTE: A local variable was created to avoid system.topLevelSN in the messages list + // NOTE: For loop was used instead of memory copy to ensure it is not parsed in the messages list script + localTopLevelSN.topLevelSN[ i ] = system.topLevelSN[ i ]; + } - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + // Fill message payload + memcpy( payloadPtr, &localTopLevelSN, sizeof( LOCAL_TOP_SN_T ) ); + payloadPtr += MAX_TOP_LEVEL_SN_CHARS; + *payloadPtr = 0; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + } } /*********************************************************************//**