GPS Logging not producing right format.


I recently began a small project to both display the latitude and longitude on a LCD screen and log the GPS data.

The problem I am encountering is when I record the data to the SD card the data is not formatted correctly. Tools like GPS visualizer require that each GPS data sentence be on its own line.

My code is based on ladada gps shield GPS test parsing sketch.

Here is my code snippets.

void loop() { uint32_t tmp; int intpart;

Serial.print("\n\rread: "); readline();

//buffer =; // check if $GPRMC (global positioning fixed data) //check to see if we have any message... then process.

//This section is used for parsing and interpretation.

if (strncmp(buffer, "$GPRMC",6) == 0) {

if(card.write_file(f, (uint8_t *) buffer,buffidx) != buffidx) { putstring_nl("can't write!"); }


void readline(void) { char c;

buffidx = 0; // start at begninning while (1) {; if (c == -1) continue; Serial.print(c); //if (c == '\n') // continue; // buffer[buffidx+1] = 0 ; if ((buffidx == BUFFSIZ-1) || (c == '\r') || (c == '\n')) { buffer[buffidx]='\r'; buffer[buffidx+1] = '\n'; buffer[buffidx+2] = 0; return; } buffer[buffidx++]= c; } }

What I am currently getting as output:


What I should be getting:

$GPRMC,041918.000,A,4240.7654,N,08312.5918,W,0.65,104.70,180111,,*12 $GPRMC,041919.000,A,4240.7669,N,08312.5982,W,0.38,134.59,180111,,*1E $GPRMC,041920.000,A,4240.7673,N,08312.6029,W,0.44,139.75,180111,,*1C

Any suggestions would be very helpful!

This code:

      if ((buffidx == BUFFSIZ-1) || (c == '\r') || (c == '\n')) {

strips the carriage return/line feed characters from the incoming data.

This code:

if(card.write_file(f, (uint8_t *) buffer,buffidx) != buffidx)

assumes that the carriage return/line feed characters are there.

Simple enough fix...

I see what you mean! Thank you, I have been pouring over this for a while and missed that detail..