Logo Search packages:      
Sourcecode: gaia version File versions  Download package

int GPSSourceNMEA::ParseSentence ( char *  sentence,
GPSData target 
) [private]

Parse one NMEA sentence

Parameters:
sentence pointer to null-terminated string containing sentence
target where to store coordinates in case of success
Returns:
1 if sentence was parsed successfully (i.e. *target valid), 0 otherwise

Definition at line 105 of file GPSSourceNMEA.cc.

References ParseGPRMC(), and TestChecksum().

Referenced by Poll().

                                                                {
      /* get rid of $ */
      if (*sentence != '\0')
            sentence++;

      /* get provided checksum */
      char *checksum = strrchr(sentence, '*');
      if (!checksum)
            return 0;
      *checksum++ = '\0';

      /* test checksum */
      if (!TestChecksum(sentence, checksum))
            return 0;

      /* split to fields */
      int nfields = 0;
      char *fields[MAX_SENTENCE_FIELDS];

      while (nfields < MAX_SENTENCE_FIELDS) {
            char *comma = strchr(sentence, ',');
            if (!comma)
                  break;
            *comma = 0;
            fields[nfields++] = sentence;
            sentence = comma+1;
      }

      /* need at least 1 field */
      if (nfields == 0)
            return 0;

      /* parse variuos sentences */
      if (strcmp(fields[0], "GPRMC") == 0)
            return ParseGPRMC(fields+1, nfields-1, target);

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index