bool Gps::encode(char c) { bool valid_sentence = false; #ifndef _GPS_NO_STATS ++_encoded_characters; #endif switch (c) { case ',': // term terminators _parity ^= (byte)c; case '\r': case '\n': case '*': if (_term_offset < sizeof(_term)) { _term[_term_offset] = 0; valid_sentence = term_complete(); } ++_term_number; _term_offset = 0; _is_checksum_term = c == '*'; return valid_sentence; case '$': // sentence begin _term_number = _term_offset = 0; _parity = 0; _sentence_type = _GPS_SENTENCE_OTHER; _is_checksum_term = false; _gps_data_good = false; return valid_sentence; default: break; } // ordinary characters if (_term_offset < sizeof(_term) - 1) { _term[_term_offset++] = c; } if (!_is_checksum_term) { _parity ^= (byte)c; } return valid_sentence; }
bool CopTinyGps::encode(char c) { bool valid_sentence = false; #ifndef _GPS_NO_STATS ++_encoded_characters; #endif switch(c) { case ',': // term terminators _parity ^= c; case '\r': case '\n': case '*': if (_term_offset < sizeof(_term)) { _term[_term_offset] = 0; valid_sentence = term_complete(); } ++_term_number; _term_offset = 0; _is_checksum_term = c == '*'; return valid_sentence; case '$': // sentence begin if (debug) Serial.print( " <! "); _term_number = _term_offset = 0; _parity = 0; _sentence_type = _GPS_SENTENCE_OTHER; _is_checksum_term = false; _gps_data_good = false; return valid_sentence; } // ordinary characters if (_term_offset < sizeof(_term) - 1) _term[_term_offset++] = c; if (!_is_checksum_term) _parity ^= c; return valid_sentence; }
uint8_t Nordic::encode(char c) { uint8_t valid_sentence = _SENTENCE_NONE; if (_started == true) ++_encoded_characters; switch (c) { case ',': // term terminators _parity ^= c; // no break; case '\r': case '\n': if (_started == true) { if (_term_offset < sizeof (_term) - 1) { _term[_term_offset] = 0; valid_sentence = term_complete(); } ++_term_number; } _term_offset = 0; if (valid_sentence != _SENTENCE_NONE && valid_sentence != _SENTENCE_OTHER) { _started = false; } _is_checksum_term = false; return valid_sentence; case '$': // sentence begin memset(_term, 0, MAX_SIZE * sizeof(char)); _term_number = _term_offset = 0; _parity = 0; _started = true; _sentence_type = _SENTENCE_OTHER; _is_checksum_term = false; return valid_sentence; } // ordinary characters if (_term_offset < sizeof (_term) - 1 && _started == true) _term[_term_offset++] = c; if (!_is_checksum_term) _parity ^= c; return valid_sentence; }
/* Recebe caractere por caractere da sentenca e monta a variavel _term, seguindo o protocolo NMEA0183. Retorna a informacao de validade da sentenca a cada caractere lido. */ bool ParserNMEA::encode(char c) { bool valid_sentence = false; #ifndef _GPS_NO_STATS ++_encoded_characters; #endif switch(c) { case ',': // Caractere que delimita os termos _parity ^= c; case '\r': case '\n': case '*': if (_term_offset < sizeof(_term)) { _term[_term_offset] = 0; valid_sentence = term_complete(); } ++_term_number; _term_offset = 0; _is_checksum_term = c == '*'; return valid_sentence; case '$': // Caractere que identifica o inicio de uma sentenca _term_number = _term_offset = 0; _parity = 0; _sentence_type = _GPS_SENTENCE_OTHER; _is_checksum_term = false; _gps_data_good = false; return valid_sentence; } // Caracteres ordinarios if (_term_offset < sizeof(_term) - 1) _term[_term_offset++] = c; if (!_is_checksum_term) _parity ^= c; return valid_sentence; }
bool TinyGPS::encode(char c) { bool valid_sentence = false; ++_encoded_characters; switch(c) { case ',': // term terminators _parity ^= c; case '\r': case '\n': case '*': if (_term_offset < sizeof(_term)) { _term[_term_offset] = 0; valid_sentence = term_complete(); } ++_term_number; _term_offset = 0; _is_checksum_term = c == '*'; return valid_sentence; case '$': // sentence begin _term_number = _term_offset = 0; _parity = 0; _sentence_type = _GPS_SENTENCE_OTHER; _is_checksum_term = false; _gps_data_good = false; return valid_sentence; } // ordinary characters if (_term_offset < sizeof(_term) - 1) _term[_term_offset++] = c; if (!_is_checksum_term) _parity ^= c; return valid_sentence; }