Char array to integer

Does the string get read in completely? if L300 gets cut of to L30 it would explain all

What is speed of your Serial? 9600? As at 9600 baud there is approx 1 char per millisecond, you might need to increase the delay(1) to delay(5) or make it adaptive

while (Serial.available() > 0)
{  
  cmd[index++] = Serial.read();
  int t = 5;                                   // max 5 millis between chars
  while ((Serial.available() == 0 ) && (t-- > 0)) delay(1);
}
cmd[index] = 0;