If you are using "Carriage return" as the option, try something like this:
char inData[9];
byte index = 0;
bool errorPrinted = false;
void loop()
{
while(Serial.available() > 0)
{
char c = Serial.read();
if(char == '\n')
{
// Got the carriage return
// Use the data in inData, if index in range
index = 0;
inData[index] = '\0';
errorPrinted = false;
}
else
{
if(index < 8)
{
inData[index++] = c;
inData[index] = '\0';
}
else
{
if(!errorPrinted)
{
// Print an error
errorPrinted = true;
}
}
}
}
}