ReceiveMessage(): timeout

Friends, i am humiliated with this problem! Please help!

I am sure that my Arduino is well… It is detecting correctly and working fine for other sketches…
This is my program:

/************************************************************************************
ADD
*************************************************************************************/
byte addFingerPrint[] = {0x4D, 0x58, 0x10, 0x03, 0x40, 0x00, 0x00, 0xF8}; // 8 bytes

byte operationSuccessAdd[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x31, 0x48}; // 7 bytes
byte timeOutAdd[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x33, 0x4A}; // 7 bytes
byte processFailureAdd[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x34, 0x4B}; // 7 bytes
byte parameterErrorAdd[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x35, 0x4C}; // 7 bytes

/*************************************************
Command Code & Respond Code For Search Fingerprint
*************************************************/
byte searchFingerPrint[] = {0x4D, 0x58, 0x10, 0x05, 0x44, 0x00, 0x00, 0x00, 0x05, 0x03}; // 10 bytes

byte FingerPrint0[] = {0x4D, 0x58, 0x30, 0x04, 0x44, 0x39, 0x00, 0x00, 0x56}; // 10 bytes
byte FingerPrint1[] = {0x4D, 0x58, 0x30, 0x04, 0x44, 0x39, 0x00, 0x01, 0x57}; // 10 bytes
byte FingerPrint2[] = {0x4D, 0x58, 0x30, 0x04, 0x44, 0x39, 0x00, 0x02, 0x58}; // 10 bytes
byte FingerPrint3[] = {0x4D, 0x58, 0x30, 0x04, 0x44, 0x39, 0x00, 0x03, 0x59}; // 10 bytes
byte FingerPrint4[] = {0x4D, 0x58, 0x30, 0x04, 0x44, 0x39, 0x00, 0x04, 0x5A}; // 10 bytes

byte operationSuccessSearch[] = {0x4D, 0x58, 0x30, 0x02, 0x44, 0x31, 0x4C}; // 7 bytes
byte timeOutSearch[] = {0x4D, 0x58, 0x30, 0x02, 0x44, 0x33, 0x4E}; // 7 bytes
byte parameterErrorSearch[] = {0x4D, 0x58, 0x30, 0x02, 0x44, 0x35, 0x50}; // 7 bytes
byte processFailureSearch[] = {0x4D, 0x58, 0x30, 0x02, 0x44, 0x34, 0x4F}; // 7 bytes
byte noMatchFinger[] = {0x4D, 0x58, 0x30, 0x02, 0x44, 0x3A, 0x55}; // 7 bytes

byte respondCorrect[] = {0x4D, 0x58, 0x30, 0x01, 0x01, 0xD7}; // 6 bytes
byte respond[6],operation[7],operationOK[7],operationFound[9],a,b,c,d,e,f,g,h,i,j,k,l,m;


void setup() {
Serial.begin(57600);
addFinger();
correctRespond();
operationSuccesful();
Serial.end();
delay(1500);
Serial.begin(57600);
searchFinger();
correctRespond();
operationSuccesful();
Serial.end();
}

void loop() {
  // put your main code here, to run repeatedly:
}

void addFinger(){
  Serial.write(addFingerPrint, sizeof(addFingerPrint));   // write the 8bytes array of the command code
  delay(1000);
}

void searchFinger(){
  // write the 8bytes array of the command code
  Serial.write(searchFingerPrint, sizeof(searchFingerPrint));
  Serial.println(" Searching... ");
  delay(2000);
}

void correctRespond() {
  // correct response contains all 6 bytes
  for(byte z=0; z<6; z++)
  {
    while(Serial.available() == 0) {}; // Wait for a byte
    respond[z] = Serial.read();
  }
    
    a = memcmp(respondCorrect, respond, sizeof(respondCorrect));

    if (a!=0) {
      Serial.println(" Invalid Command code!");
      }
  delay(500);
}

void operationSuccesful() {
  // reply contains all 7 bytes
  for(byte x=0; x<7; x++)
  {
    while(Serial.available() == 0) {}; // Wait for a byte
    operation[x] = Serial.read();
  }
    b = memcmp(operationSuccessSearch, operation, sizeof(operationSuccessSearch));
    c = memcmp(parameterErrorSearch, operation, sizeof(parameterErrorSearch));
    d = memcmp(processFailureSearch, operation, sizeof(processFailureSearch));
    e = memcmp(timeOutSearch, operation, sizeof(timeOutSearch));
    f = memcmp(noMatchFinger, operation, sizeof(noMatchFinger));
    m = memcmp(operationSuccessAdd, operation, sizeof(operationSuccessAdd));

   if (m==0) {
      Serial.println(" Fingerprint added Successfully");
         }
   else if (b==0) {
      for(byte y=0; y<9; y++)
      {
        while(Serial.available() == 0) {}; // Wait for a byte
        operationFound[y] = Serial.read();

        g = memcmp(FingerPrint0, operationFound, sizeof(FingerPrint0));
        h = memcmp(FingerPrint1, operationFound, sizeof(FingerPrint1));
        i = memcmp(FingerPrint2, operationFound, sizeof(FingerPrint2));
        j = memcmp(FingerPrint3, operationFound, sizeof(FingerPrint3));
        k = memcmp(FingerPrint4, operationFound, sizeof(FingerPrint4));
        l = memcmp(noMatchFinger, operationFound, sizeof(noMatchFinger));

   if (g==0) {
      Serial.println(" Hello Farook! ");
         }
   else if (h==0) {
      Serial.println(" Fingerprint 2 found ");
         }
   else if(i==0) {
      Serial.println(" Fingerprint 3 found ");
         }
   else if(j==0) {
      Serial.println(" Fingerprint 4 found ");
         }
   else if(k==0) {
      Serial.println(" Fingerprint 5 found ");
   }
   else if(l==0) {
   Serial.println(" You are not Farook!!! ");
         }
     }
   }
   else if(c==0) {
      Serial.println(" Parameter error! ");
         }   
   else if(d==0) {
      Serial.println(" Process failed! ");
         }   
   else if(e==0) {
      Serial.println(" Time out! ");
         }
   else if(f==0){
   Serial.println(" No match found! ");
         }
}

I have attached the output below. Please help me as soon as possible as i need to complete my project :frowning: :sob:

Beyond checking that you have the correct board and port selected and I cannot help, I am afraid.

However, it would have been much easier to read the error message if you had copy/pasted it here rather than attaching a screen shot.

It would also be helpful if you HAD a function called ReceiveMessage(). If you have problems with code, use names in your title and your post that match names in the code!