I got a GPRS/GSM from http://www.elecrow.com/micro-controllers-c-109/shield-c-109_110/gprsgsm-shield-p-325.html .Its Schematic is showed http://www.elecrow.com/download/ELE%20GPRSshield%20v1.0.pdf.it works well when I program it with Serial COM .

but when I program the code to Arduino, there are some problems. it seems that it overflowed ,and some data lost.The following code is what I upload to the Arduino.

So the question is why I program the GPRS/GSM Shield with the first code, it will lost much data,And I program it through the Serial tool, the GPRS/GSM shield works fine. Is it because the Software library OVERFLOW?

No. It is because you expect the serial data to get to the shield, to be processed, and the reply to arrive back at the Arduino in just a few nanoseconds. That does not happen, so the reply does not go with the command.

Why you are repeatedly sending a command to set the time is a mystery. That should be done ONCE, in setup().

The response is supposed to end with some kind of value that says "this is the end of the reply". You need to wait, in a while loop, for that character to arrive BEFORE you send another command.

Why you are repeatedly sending a command to set the time is a mystery. That should be done ONCE, in setup().

Thanks for your tips, I will do as you said, setting the time at the setup(). and this program will only be done one time before I upload my project code. And GPRS/GSM Shield will be on power all time to keep its RTC run.

Quote

The response is supposed to end with some kind of value that says "this is the end of the reply". You need to wait, in a while loop, for that character to arrive BEFORE you send another command.

I changed the wait time to 2000(2s),and it works well . but the result also have a little problem.

Generally, when someone points out a problem, the thing to do is to fix that problem, first. Then, if there is still a problem, or another problem come up, ask more questions. It is incorrect to say "Yes, I'll fix that later, but why does this follow-on problem happen?". Fix the first problem. The follow-on problem may go away.