GPS/GPRS SIM908 Shield loosing datetime

Hello, I have the GPS shield and am facing a problem when it sends an sms with the date and time coordinates, after synchronize sms loses part of the string date and time. example while the GPS synchronizes not get the sms like this:
lat long datetime
0.000000,0.000000,20150320141717

after syncing receive
-12.547854, -39.524574,201503201

so sms loses the numbers the hour minute and second 41717

I hope that colleagues can help

I'm using this AT to get information from gps

AT+CGPSINF=0

and receive this answer:

0,-3915.870823,-1257.929730,0.196135,20150320104050.000,195,5,0.0000000,0.000000

this code read the string and record it on 'inData' from terminal

void read_String() {
index = 0;
while (mySerial.available() > 0)
{
if (index < 199)
{
inChar = mySerial.read();
inData[index] = inChar;
index++;
}
}
inData[199] = '\0';

Now cut of inData the selected values

strtok(inData, ",");
strcpy(longitude, strtok(NULL, ","));
strcpy(latitude, strtok(NULL, ","));
strcpy(altitude, strtok(NULL, ","));
strcpy(datetime, strtok(NULL, ","));

while I wait synchronization gps, get the sms this information with the full date and time

0.000000,0.000000,20150320101525

when the GPS sync sms loses hour minute and second

-12.654758,-39.254562,201503201

The read_String function certainly has a problem. The '\0' character is the NUL-termination of character arrays; it says there are no more bytes to use in the rest of the array.

If you only read 42 bytes, you must set inData[42] = '\0';[/tt]. Your routine always sets inData[199] = '\0';[/tt]. This is ok if you always read 199 bytes, but it won't work if you only read 42 bytes.

Another problem is that your while loop exits when there are no more characters to read. What if your loop is reading faster than the device can send the bytes? The device may have more bytes to send, they just aren't available yet. I think you probably need to wait for the line terminator: CR '\r', LF '\n' or both. Then you know the device is finished sending the line, and then you can parse it.

Please read How to use this forum, and please post all of your program between [ code ] and [ /code ] tags (no spaces in the tags).

Cheers,
/dev