I'm using an Arduino UNO R3 and when I send an AT command to my GSM shield via Serial I get increasing number from Serial.available().
Here is the example I have been using to debug:
void loop()
{
Serial.println("AT+CADC?");
delay(3000);
}
void serialEvent()
{
char * sensorValue;
int serial = Serial.available();
Serial.print("-");
Serial.print(serial);
Serial.println("-");
if(serial >0)
{
sensorValue = (char*) malloc(sizeof(char) * (serial +1));
int i;
for(i = 0; i < serial; i++)
{
sensorValue[i] = Serial.read();
//Serial.print(sensorValue[i]);
}
sensorValue[serial+1] = '\0';
Serial.print(sensorValue);
}
delay(2000);
}
The result I get from the serial monitor is:
-30-
-63-
-63-
-63-
...
Why does the number of bytes available start off at 30 and then max out at 63? This happens even when I use Serial.read(), which should consume the data in the buffer.
EDIT: Added full contens of serialEvent().