1 #ifndef LIBPROPELLER_GPSPARSER_H_ 
    2 #define LIBPROPELLER_GPSPARSER_H_ 
   25     bool Start(
const int rx_pin, 
const int tx_pin, 
const int baud) {
 
   27         next_character_position_ = 0;
 
   30         recording_sentence_ = 
false;
 
   54         return Get(internal_buffer_);
 
   69     char * 
Get(
char string[], 
const int maxBytes = kNmeaMaxLength) {
 
   73             if (byte == -1) 
return NULL;
 
   75             if (next_character_position_ == 6) {
 
   76                 CheckForPGTOP(
string);
 
   80             if (recording_sentence_ == 
false && byte != kSentenceStartCharacter) {
 
   82             } 
else if (byte == 
'\r' || byte == 
'\n') {
 
   83                 return TerminateString(
string);
 
   86                 recording_sentence_ = 
true;
 
   87                 string[next_character_position_++] = byte;
 
   90             if (next_character_position_ == maxBytes - 1) {
 
   91                 return TerminateString(
string);
 
  100     static const int kNmeaMaxLength = 85;
 
  101     static const int kBufferSize = kNmeaMaxLength;
 
  102     static const char kSentenceStartCharacter = 
'$';
 
  104     int next_character_position_;
 
  105     char internal_buffer_[kBufferSize]; 
 
  106     bool recording_sentence_;
 
  108     char * TerminateString(
char string[]) {
 
  109         string[next_character_position_] = 0; 
 
  110         next_character_position_ = 0; 
 
  111         recording_sentence_ = 
false;
 
  115     void CheckForPGTOP(
char string[]) {
 
  116         if (
string[1] == 
'P' &&
 
  121             next_character_position_ = 0;
 
  122             recording_sentence_ = 
false;
 
  130     Serial * getSerial(
void) {
 
  134     friend class UnityTests;
 
  139 #endif // LIBPROPELLER_GPSPARSER_H_