src/sensesp_nmea0183/nmea_parser.cpp
/// Reconstruct the original NMEA sentence for debugging purposes.
Reconstruct the original NMEA sentence for debugging purposes.
Reconstruct the original NMEA sentence for debugging purposes .
static void ReconstructNMEASentence(char* sentence, const char* buffer,
                                    int field_offsets[], int num_fields) {
  int last_field_loc = field_offsets[num_fields - 1];
  int last_field_len = strlen(buffer + field_offsets[num_fields - 1]);
  int sentence_len = last_field_loc + last_field_len + 1;
  sentence[0] = '$';
  memcpy(sentence + 1, buffer, sentence_len);
  for (int i = 1; i < num_fields - 1; i++) {
    sentence[field_offsets[i]] = ',';
  }
  sentence[field_offsets[num_fields - 1]] = '*';
}
static void ReconstructNMEASentence ( char * sentence , const char * buffer , int field_offsets [ ] , int num_fields ) { int last_field_loc = field_offsets [ num_fields - 1 ] ; int last_field_len = strlen ( buffer + field_offsets [ num_fields - 1 ] ) ; int sentence_len = last_field_loc + last_field_len + 1 ; sentence [ 0 ] = ' ' ; memcpy ( sentence + 1 , buffer , sentence_len ) ; for ( int i = 1 ; i < num_fields - 1 ; i ++ ) { sentence [ field_offsets [ i ] ] = ' ' ; } sentence [ field_offsets [ num_fields - 1 ] ] = ' ' ; }
Reconstruct the original NMEA sentence for debugging purposes.
Reconstruct the original NMEA sentence for debugging purposes .
// get the total length of the sentence // include the final \0 // beginning $ // copy the buffer contents // fill in the gaps with commas // the final gap has an asterisk