Arduino rfid serial output is loosing characters.

Im building a code to a rfid reader, a rdm6300 and a arduino pro micro.
the sensor reads the cards and led continualy does a spectrum loop.
But the sensor output that is stored in a variable is bugging and loosing some letters/numbers.

const int redPin = 6;
const int greenPin = 5;
const int bluePin = 3;

String ledloop = "on";
String scanresult = "";

#define STX 0x02
#define ETX 0x03

const size_t LEN = 24; // length of the expected message (e.g. 12 hex characters = 12 * 2 = 24)


char buffer[LEN+1];
int index = 0;
bool receiving = false;



void setup() {
  // Start off with the LED off.
  setColourRgb(0,0,0);
    Serial.begin(9600);
  Serial1.begin(9600);

}

void loop() {


  do {
    
  unsigned int rgbColour[3];

  // Start off with red.
  rgbColour[0] = 255;
  rgbColour[1] = 0;
  rgbColour[2] = 0;  

  // Choose the colours to increment and decrement.
  for (int decColour = 0; decColour < 3; decColour += 1) {
    int incColour = decColour == 2 ? 0 : decColour + 1;

    // cross-fade the two colours.
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
      
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      scan();
      delay(5);
    }
   }
  } while (ledloop == "on"); 



}




void scan() {

 if (Serial1.available() > 0) {
    char serialByte = Serial1.read();
    if (serialByte == STX) {
      receiving = true;
      index = 0;
    } else if (serialByte == ETX || index == LEN) {
      buffer[index] = '\0';
      parse(buffer, index);
      index = 0;
      receiving = false;
    } else if (receiving) {
      buffer[index++] = serialByte;
    }
  }
 
  
  }


void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
 }

 
void parse(char* input, size_t length) {

  scanresult = input;
  Serial.println(scanresult);
  
  
}

You read one character, in scan(), regardless of how many are available. Why?

Then, you delay() for 5 milliseconds. Why? You need to read, understand, and embrace the blink without delay philosophy, and complete rewrite your program.

You almost certainly do NOT want to be using a do/while statement that only checks the condition after making a pass through the body.

Im new to this language and part of the code was given to me by a community menber. i can be using this in a bad way. The delay controls the speed that the led chages color and if i remove it it bugs. How can i solve this issue? Please help

How can i solve this issue?

Re-read reply #1. Get rid of the delay. Of course, that means CTRL-A, CTRL-X and starting over, but that's life.