Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r660876bca7ae34f862ae9cc6feef9a30ec02fe94 -r75e1ae332d1446dddf9b8d4ce6e8317449c57d67 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 660876bca7ae34f862ae9cc6feef9a30ec02fe94) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 75e1ae332d1446dddf9b8d4ce6e8317449c57d67) @@ -8,7 +8,7 @@ * @file BloodLeak.c * * @author (last) Dara Navaei -* @date (last) 11-Jan-2023 +* @date (last) 22-Jan-2023 * * @author (original) Peman Montazemi * @date (original) 18-Mar-2021 @@ -542,6 +542,7 @@ BLOOD_LEAK_STATE_T state = BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE; BOOL areCommandsReady = TRUE; + // Check to see if all commands in sequence have been responded to for ( i = 0; i < NUM_OF_EMB_CMDS; i++ ) { switch( i ) @@ -556,6 +557,7 @@ } } + // When all commands in sequence have been responded to, determine whether anything went wrong if ( TRUE == areCommandsReady ) { // Enqueue the zero and self test sequence (Z->G->Z->Q->T) @@ -571,7 +573,7 @@ case Q_EMB_MODE_CMD: case T_EMB_MODE_CMD: // Check to see if any of the command responses failed - hasCurrCmdFailed = ( BLOOD_LEAK_EMB_MODE_FAIL_ASCII == bloodLeakEmbModeCmd[ i ].commandResp ? TRUE : FALSE ); + hasCurrCmdFailed = ( BLOOD_LEAK_EMB_MODE_PASS_ASCII == bloodLeakEmbModeCmd[ i ].commandResp ? FALSE : TRUE ); hasCmdSqncFailed |= hasCurrCmdFailed; failedCmd = ( TRUE == hasCurrCmdFailed ? i : NU_EMB_MODE_CMD ); break; @@ -585,6 +587,7 @@ } } + // Pass self-test if entire sequence was successful if ( FALSE == hasCmdSqncFailed ) { // Done with zero sequence, transition to other states @@ -593,6 +596,7 @@ bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; state = BLOOD_LEAK_NORMAL_STATE; } + // If not successful, retry if we've not run out else if ( bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) { if ( TRUE == zeroBloodLeak() ) @@ -603,6 +607,7 @@ bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandRetryCount++; } } + // If out of retries, fault else { #ifndef _RELEASE_