Buffer Overflow [GPS]

Hi,

It is my first time using GPS and I encountered a problem. I connected my GPS module (part number of it I don't know, I borrowed it from a person) to Arduino and copy-pasted the code from Arduino tutorial Arduino Playground - GPS, but when GPS reads raw data, the buffer overflows in this part:

void loop() {
byteGPS = Serial.read(); // Read a byte from the serial port
// Test if the port is empty
if (byteGPS == -1) {
}
else { // if it isn't empty
line[lineCounter] = byteGPS; // put data read in the buffer
lineCounter++;
delay (100);
Serial.println(byteGPS); // print data read to the serial monitor
// Test if the transmission is finished
// if it is finished, we begin to parse !
if (byteGPS==13){
counter=0;
correctness=0;

What should I do?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. Note that the receive part does not use delay.

You may need to change the value of the constant numChars if your message is longer than 32 characters.

...R

the buffer overflows in this part

So, make the buffer bigger. You did not post ALL of your code, so all we can tell is that the buffer is smaller than needed.

We can also tell that you didn't bother indenting the code properly (as you went, or using Tools + Auto Format) AND that the code you copied was crap.

Actually, strike the part after the AND. The code you copied as fine. The changes you made were crap.

Stuffing your head in the sand for 1/10th of a second after every character read WILL cause you to loose data from the GPS, since it sends one or more sentences, consisting of far more than 10 characters, every second.

I know about delay, I accidentally wrote the wrong code. Sorry.

Well, I think, that I misunderstood, maybe it's not an overflow. Buffer expanding doesn't help. When received byte is 13, the transmission does not end, it stops for a second and then cycle goes again, when it shouldn't.

I have these infinite numbers. That's all.

Saalnite:
I have these infinite numbers. That's all.

Have you tried the examples I linked to?

And for the future please don't post text output as a picture.

...R

If you'd be interested in a library to parse the GPS data, take a look at my NeoGPS. It does the parsing without using a buffer, which makes it faster and smaller than all other libraries. It is also more accurate, and can be configured to parse only the fields that you use, saving even more program space and RAM. It is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

Even if you don't use it, there is some good information on the Troubleshooting page.

Cheers,
/dev

I accidentally wrote the wrong code. Sorry.

And, you forgot to post the correct code. Strike 2.