Coding Help Starting and Ending with a certain Character

Hey Robin2, thank you very much for the reply and suggestion. I tried what you said

No you did not. He said

Leave my function unchanged

Here is your receive code followed by Robin2's code. Are they the same?

Your code

void recvWithStartEndMarkers() {
  static boolean recvInProgress = false;
  static byte ndx = 0;
  char startMarker = '<';
  char endMarker = '>';
  char rc;

  while (Serial.available()) {
    rc = Serial.read();


    if (recvInProgress == true) {
      if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
      }
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }

    }
    else if (rc == startMarker) {
      recvInProgress = true;
    }
  }
}

Robin2's code

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
 
    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}