//store characters to string
readString += c;
Please note that in versions of the IDE up to and including 1.0.3, the String library has bugs as discussed here and here.
In particular, the dynamic memory allocation used by the String class may fail and cause random crashes.
I recommend reworking your code to manage without String. Use C-style strings instead (strcpy, strcat, strcmp, etc.), as described here for example.
Alternatively, install the fix described here: Fixing String Crashes
Preferably upgrade your IDE to version 1.0.4 or above at: http://arduino.cc/en/Main/Software
The time taken to concatenate in the String class is quite substantial, so this isn’t a good idea if you are trying to save time.
Example:
#include <ProfileTimer.h>
void setup ()
{
Serial.begin (115200);
Serial.println ();
String s;
char a [513];
{
ProfileTimer t1 ("concatenating String");
for (int i = 0; i < 512; i++)
s += 'a';
} // end timed bit of code
Serial.println ();
{
ProfileTimer t1 ("concatenating char array");
for (int i = 0; i < 512; i++)
a [i] = 'a';
a [512] = 0; // terminating null
} // end timed bit of code
} // end of setup
void loop () { }
Output:
Start : concatenating String
Time taken: concatenating String = 12240 uS.
Start : concatenating char array
Time taken: concatenating char array = 8 uS.
That String concatenation requires a malloc and free for every byte. That takes time as well as being likely to fragment memory, a scarce resource on a microcontroller.
Using String concatenation took 1530 times as long!
I suggest you read into a fixed “char” array buffer, and then transmit (send) when you have a reasonable number, like 512 bytes.