that communicates at 57600 bps (I think this refers to bits per second, NOT bytes per second). Dividing by 8 gives 7200 bytes per second,
The serial input buffer on the arduino Mega is 64 bytes (or 64 characters) so if it isn't checked very frequently, ...
and assuming a typical NMEA sentence of up to 85 characters, this means a full sentence can arrive in about 12 milliseconds.
Would lowering the GPS bit rate work?
You aren't planning to check it at least every 10 mS?
you could increase the serial buffer size
You could just ignore the sentences that don't arrive completely
Follow the links there, and you'll be able to change those settings you're asking for.
If you receive incomplete sentence, then you have to assume it is invalid
Do you need all sentences ?If you don't you can check the sentence identifier, and if you're not interested in it, ignore the rest of it.If you receive incomplete sentence, then you have to assume it is invalid (because you have no way of confirming it's validity).
How do i do this? I though the input serial buffer size on a mega was fixed to 64 bytes?
The buffer is a software construct, so you can make it any size that you like
4 UARTs (hardware serial ports)
Did you read the 2nd link ?
At the moment I'm testing for data at the port using the available() function. Is there any interupt that I can use to tell me when some data has arrived? If there was, I might be able to have a routine that as soon as more than say 30 bytes arrived I could copy the data to another bigger buffer and process it later when nothing else was happening.cheers
The specification for the Mega suggests these are hardware ports, so I assumed the buffer size was fixed.
How do I change the size? what's the command to use?The specification for the Mega suggests these are hardware ports, so I assumed the buffer size was fixed.
// Define constants and variables for buffering incoming serial data. We're// using a ring buffer (I think), in which head is the index of the location// to which to write the next incoming character and tail is the index of the// location from which to read.#if (RAMEND < 1000) #define SERIAL_BUFFER_SIZE 16#else #define SERIAL_BUFFER_SIZE 64#endif