Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -rc68065fe2cfcfee46eae9d8a8af68b42b662661c -r0cb85009b01ccd791ee7911f5b3656605c821dfa --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision c68065fe2cfcfee46eae9d8a8af68b42b662661c) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 0cb85009b01ccd791ee7911f5b3656605c821dfa) @@ -92,8 +92,8 @@ #define BLOOD_LEAK_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Blood leak embedded mode FPGA error timeout in milliseconds. #define BLOOD_LEAK_RXFIFO_COUNT_MASK 0x03FF ///< Mask high order bits of blood leak sensor rx count -#define MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< Blood Leak comm failures window -#define MAX_BLOOD_LEAK_COMM_FAILURES 3 ///< Blood Leak maximum comm failures per MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS +#define MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< Blood Leak comm failures window +#define MAX_BLOOD_LEAK_COMM_FAILURES 10 ///< Blood Leak maximum comm failures per MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates @@ -600,7 +600,6 @@ // Enqueue the zero and self test sequence (Z->G->Z->Q->T) BOOL hasCmdSqncFailed = FALSE; BOOL hasCurrCmdFailed = FALSE; - U08 failedCmd; for ( i = 0; i < NUM_OF_EMB_CMDS; i++ ) { @@ -612,14 +611,12 @@ // Check to see if any of the command responses failed hasCurrCmdFailed = ( BLOOD_LEAK_EMB_MODE_PASS_ASCII == bloodLeakEmbModeCmd[ i ].commandResp ? FALSE : TRUE ); hasCmdSqncFailed |= hasCurrCmdFailed; - failedCmd = ( TRUE == hasCurrCmdFailed ? i : NU_EMB_MODE_CMD ); break; case G_EMB_MODE_CMD: // G command will return a value that has to be greater than 0 hasCurrCmdFailed = ( bloodLeakEmbModeCmd[ i ].commandResp > 0 ? FALSE : TRUE ); hasCmdSqncFailed |= hasCurrCmdFailed; - failedCmd = ( TRUE == hasCurrCmdFailed ? i : NU_EMB_MODE_CMD ); break; default: @@ -728,7 +725,8 @@ else if ( TRUE == bloodLeakEmbModeHasZeroBeenRqustd ) { // Check whether zeroing the sensor has been requested or not if yes, transition to zero command state otherwise, stay in this state - state = BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE; + bloodLeakEmbModeHasZeroBeenRqustd = FALSE; + state = BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE; } return state; @@ -791,8 +789,10 @@ if ( FALSE == isEmbModeCmdQueueEmpty() ) { + U08 commandASCII = 0; + bloodLeakEmbModeRqstedCmd = dequeueEmbModeCmd(); - U08 commandASCII = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].commandASCII; + commandASCII = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].commandASCII; switch( bloodLeakEmbModeRqstedCmd ) { @@ -1059,13 +1059,14 @@ sendBloodLeakEmbeddedModeCommandResponse( bloodLeakEmbModeRqstedCmd, length, bloodLeakEmbModeRespBuffer ); - bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; - state = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; - if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BLOOD_LEAK_COMM_ERROR ) ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_BLOOD_LEAK_FPGA_FAULT, MAX_BLOOD_LEAK_COMM_FAILURES, (U32)MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_BLOOD_LEAK_FPGA_FAULT, (U32)bloodLeakEmbModeRqstedCmd, (U32)MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ) } + + bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; + state = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; + } return state; @@ -1281,6 +1282,7 @@ data.bloodLeakStatus = (U32)getBloodLeakStatus(); data.bloodLeakState = (U32)bloodLeakState; data.bloodLeakPersistentCounter = bloodLeakPersistenceCtr; + data.bloodLeakSerialCommState = bloodLeakEmbModeSubstate; bloodLeakDataPublicationCounter = 0; broadcastData( MSG_ID_HD_BLOOD_LEAK_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( BLOOD_LEAK_DATA_T ) ); @@ -1503,10 +1505,10 @@ static void enqueueInfoEmbModeCmds( void ) { if ( ( TRUE == didTimeout( bloodLeakEmbModeInfoCmdEnqLastTimeStamp, BLOOD_LEAK_EMB_MODE_INFO_CMD_TIMOUE_MS ) ) && - ( bloodLeakState >= BLOOD_LEAK_INIT_STATE ) ) + ( bloodLeakState >= BLOOD_LEAK_INIT_STATE ) && ( bloodLeakState != BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE ) ) { - // Enqueue the next command. Make sure the blood leak state is greater than init state since in the post state and - // check for set point, other commands are being enqueued for checking + // Enqueue the next command. Make sure the blood leak state is greater than init state and it is not the zero and self test state + // to make sure setting the embedded mode and getting the set point and zero sequence should go undisturbed. if ( 0 == bloodLeakEmbModeInfoCmdCounter ) { enqueueEmbModeCmd( I_EMB_MODE_CMD );