I've got it configured to transmit data at 57600 baud, and produce only the NMEA sentence RMC .
The problem is that at 57600 baud, data is arriving at a rate of 57 bytes per millisecond. Since the default size of the serial buffer is 64 bytes and the typical length of the RMC sentence is about 85 bytes the buffer can overflow in less than 2ms!
To ensure I loose no data, I think have two options ......
Check the serial port at least once every millisecond, or
Increase the buffer size of the serial port.
Since many of my other processes take more than 10 milliseconds (reading from i2c devices, writing to a SD card etc etc) I think my only option is the 2nd one.
I've edited the size of the serial port in {installation root}hardware/arduino/cores/arduino/HardWareSerial.cpp and increased the value of SERIAL_BUFFER_SIZE from 64 to 128 bytes. Unfortunately this doesn't seem to have worked, I'm still finding exactly the same symptoms (NMEA sentences are still truncated). My current assumption is there's something else I need to modify to increase the serial buffer size, if so what?
On the same subject, since the mega has 4 serials ports, does this mean that by increasing the size from 64 to 128 bytes, I've actually reduced the dynamic memory available by 256 bytes, not just 64 bytes? Finally, what are the valid values I can change it to? The data I'm interested in is only 85 bytes long, do I have to increase the value to 128? or could I just increase it to 85?
The problem is that at 57600 baud, data is arriving at a rate of 57 bytes per millisecond. Since the default size of the serial buffer is 64 bytes and the typical length of the RMC sentence is about 85 bytes the buffer can overflow in less than 2ms!
at 57600 there comes 57bits per millisecond, given that one byte takes about 10.5 bit at best this equals to 6 bytes/millisecond.
The buffer will overflow in ~15 milliseconds
To ensure I loose no data, I think have two options ......
Check the serial port at least once every millisecond, or
Increase the buffer size of the serial port.
Step 2 is the most robust in your case
Unfortunately this doesn't seem to have worked, I'm still finding exactly the same symptoms (NMEA sentences are still truncated).
Can you post the code, or better a minimal version that shows this behaviour?
How many strings are send per second, one or continuously?
DO you use the hardwareSerial or a SoftwareSerial?
The latter is/was not very reliable for receiving
On the same subject, since the mega has 4 serials ports, does this mean that by increasing the size from 64 to 128 bytes, I've actually reduced the dynamic memory available by 256 bytes, not just 64 bytes? Finally, what are the valid values I can change it to? The data I'm interested in is only 85 bytes long, do I have to increase the value to 128? or could I just increase it to 85?
IIRC Only if you use the 4 Serials that is the case
google for Arduino freeRAM() to see the actual memory difference.