Go Down

Topic: GPS Logging not producing right format. (Read 2134 times) previous topic - next topic


Jan 19, 2011, 08:40 pm Last Edit: Jan 19, 2011, 08:42 pm by xsixteen Reason: 1

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: ");

//buffer =  mySerial.read();
  // 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)
      //if (c == '\n')
       // continue;
    //  buffer[buffidx+1] = 0 ;
      if ((buffidx == BUFFSIZ-1) || (c == '\r') || (c == '\n')) {
        buffer[buffidx+1] = '\n';
        buffer[buffidx+2] = 0;
      buffer[buffidx++]= c;

What I am currently getting as output:

What I should be getting:

Any suggestions would be very helpful!


This code:
Code: [Select]
     if ((buffidx == BUFFSIZ-1) || (c == '\r') || (c == '\n')) {
strips the carriage return/line feed characters from the incoming data.

This code:
Code: [Select]
if(card.write_file(f, (uint8_t *) buffer,buffidx) != buffidx)
assumes that the carriage return/line feed characters are there.

Simple enough fix...
The art of getting good answers lies in asking good questions.


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

Go Up