Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -radde281467e093774f5fa84419a1476b5b2bf52c -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision adde281467e093774f5fa84419a1476b5b2bf52c) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -8,7 +8,7 @@ * @file BloodLeak.c * * @author (last) Dara Navaei -* @date (last) 13-Sep-2023 +* @date (last) 10-Oct-2023 * * @author (original) Peman Montazemi * @date (original) 18-Mar-2021 @@ -1142,43 +1142,42 @@ U08 expChar1 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar1; U08 expChar2 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar2; - if ( ( expChar1 != NU_EMB_MODE_CMD ) && ( NU_EMB_MODE_CMD == expChar2 ) ) + if ( expChar1 != NU_EMB_MODE_CMD ) { // This is the case that there is a start character. If current character buffer index is less than the // length of the expected response of the command. if ( bloodLeakEmbModeRespIndex < length ) { - // Check if the expected char is received and the response buffer is empty because the index is 0, - // insert the buffer data - if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + if ( NU_EMB_MODE_CMD == expChar2 ) { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; + // Check if the expected char is received and the response buffer is empty because the index is 0, + // insert the buffer data + if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + // Check if the buffer index is cd ve> 0 so the first char has been inserted and the rest is data but it is not the echo of the command + // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. + else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } } - // Check if the buffer index is > 0 so the first char has been inserted and the rest is data but it is not the echo of the command - // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. - else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) + else { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; + // Check if either of the expected chars are received and if they are insert it into the response buffer + if ( ( expChar1 == data ) || ( expChar2 == data ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } } } } - else if ( ( expChar1 != NU_EMB_MODE_CMD ) && ( expChar2 != NU_EMB_MODE_CMD ) ) + else { - // This is the case that both expected chars are not null. Either of the chars are accepted like P or F - if ( bloodLeakEmbModeRespIndex < length ) - { - // Check if either of the expected chars are received and if they are insert it into the response buffer - if ( ( expChar1 == data ) || ( expChar2 == data ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - } - } - else if ( ( NU_EMB_MODE_CMD == expChar1 ) && ( NU_EMB_MODE_CMD == expChar2 ) ) - { // This is the case that there are no expected characters and the received value are numbers if ( bloodLeakEmbModeRespIndex < length ) {