// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool TinyGPS::term_complete() { if (_is_checksum_term) { byte checksum = 16 * from_hex(_term[0]) + from_hex(_term[1]); if (checksum == _parity) { if (_gps_data_good) { #ifndef _GPS_NO_STATS ++_good_sentences; #endif _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch(_sentence_type) { case _GPS_SENTENCE_GPRMC: _time = _new_time; _date = _new_date; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; _course = _new_course; break; case _GPS_SENTENCE_GPGGA: _altitude = _new_altitude; _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _numsats = _new_numsats; _hdop = _new_hdop; break; } return true; } } #ifndef _GPS_NO_STATS else ++_failed_checksum; #endif return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _GPRMC_TERM)) _sentence_type = _GPS_SENTENCE_GPRMC; else if (!gpsstrcmp(_term, _GPGGA_TERM)) _sentence_type = _GPS_SENTENCE_GPGGA; else _sentence_type = _GPS_SENTENCE_OTHER; return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) switch(COMBINE(_sentence_type, _term_number)) { case COMBINE(_GPS_SENTENCE_GPRMC, 1): // Time in both sentences case COMBINE(_GPS_SENTENCE_GPGGA, 1): _new_time = parse_decimal(); _new_time_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 2): // GPRMC validity _gps_data_good = _term[0] == 'A'; break; case COMBINE(_GPS_SENTENCE_GPRMC, 3): // Latitude case COMBINE(_GPS_SENTENCE_GPGGA, 2): _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 4): // N/S case COMBINE(_GPS_SENTENCE_GPGGA, 3): if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case COMBINE(_GPS_SENTENCE_GPRMC, 5): // Longitude case COMBINE(_GPS_SENTENCE_GPGGA, 4): _new_longitude = parse_degrees(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 6): // E/W case COMBINE(_GPS_SENTENCE_GPGGA, 5): if (_term[0] == 'W') _new_longitude = -_new_longitude; break; case COMBINE(_GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC) _new_speed = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 8): // Course (GPRMC) _new_course = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 9): // Date (GPRMC) _new_date = gpsatol(_term); break; case COMBINE(_GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA) _gps_data_good = _term[0] > '0'; break; case COMBINE(_GPS_SENTENCE_GPGGA, 7): // Satellites used (GPGGA) _new_numsats = (unsigned char)atoi(_term); break; case COMBINE(_GPS_SENTENCE_GPGGA, 8): // HDOP _new_hdop = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPGGA, 9): // Altitude (GPGGA) _new_altitude = parse_decimal(); break; } return false; }
// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool TinyGPS::term_complete() { if (_is_checksum_term) { byte checksum = 16 * from_hex(_term[0]) + from_hex(_term[1]); if (checksum == _parity) { if (_gps_data_good) { #ifndef _GPS_NO_STATS ++_good_sentences; #endif _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch(_sentence_type) { case _GPS_SENTENCE_GPRMC: _time = _new_time; _date = _new_date; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; _course = _new_course; _rmc_ready = true; break; case _GPS_SENTENCE_GPGGA: _altitude = _new_altitude; _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _gga_ready = true; _hdop = _new_hdop; _sat_count = _new_sat_count; case _GPS_SENTENCE_GPGSV: _gsv_ready = true; break; } return true; } } #ifndef _GPS_NO_STATS else ++_failed_checksum; #endif return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _GPRMC_TERM)) _sentence_type = _GPS_SENTENCE_GPRMC; else if (!gpsstrcmp(_term, _GPGGA_TERM)) _sentence_type = _GPS_SENTENCE_GPGGA; else if (!gpsstrcmp(_term, _GPGSV_TERM)) _sentence_type = _GPS_SENTENCE_GPGSV; else _sentence_type = _GPS_SENTENCE_OTHER; return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) switch((_sentence_type == _GPS_SENTENCE_GPGGA ? 200 : 100) + _term_number) { case 101: // Time in both sentences case 201: _new_time = parse_decimal(); _new_time_fix = millis(); break; case 102: // GPRMC validity _gps_data_good = _term[0] == 'A'; break; case 103: // Latitude case 202: _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case 104: // N/S case 203: if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case 105: // Longitude case 204: _new_longitude = parse_degrees(); break; case 106: // E/W case 205: if (_term[0] == 'W') _new_longitude = -_new_longitude; break; case 107: // Speed (GPRMC) _new_speed = parse_decimal(); break; case 108: // Course (GPRMC) _new_course = parse_decimal(); break; case 109: // Date (GPRMC) _new_date = gpsatol(_term); break; case 206: // Fix data (GPGGA) _gps_data_good = _term[0] > '0'; break; case 207: // Number of satelites tracked (GPGGA) _new_sat_count = parse_decimal(); break; case 208: // Horizontal Dilution of Position (GPGGA) _new_hdop = parse_decimal(); break; case 209: // Altitude (GPGGA) _new_altitude = parse_decimal(); break; } /* switch */ return false; }
// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool Gps::term_complete() { //Console.println("compl"); if (_is_checksum_term) { byte checksum = (byte)(16 * from_hex(_term[0]) + from_hex(_term[1])); //Console.print(checksum); //Console.print(","); //Console.println(_parity); if (checksum == _parity) { //if (1==1) if (_gps_data_good) { #ifndef _GPS_NO_STATS ++_good_sentences; #endif _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch (_sentence_type) { case _GPS_SENTENCE_GPRMC: _time = _new_time; _date = _new_date; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; _course = _new_course; break; case _GPS_SENTENCE_GPGGA: _altitude = _new_altitude; _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _numsats = _new_numsats; _hdop = _new_hdop; break; default: break; } return true; } } #ifndef _GPS_NO_STATS else { ++_failed_checksum; } #endif return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _GPRMC_TERM)) { _sentence_type = _GPS_SENTENCE_GPRMC; } else if (!gpsstrcmp(_term, _GPGGA_TERM)) { _sentence_type = _GPS_SENTENCE_GPGGA; } else { _sentence_type = _GPS_SENTENCE_OTHER; } return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) { switch (COMBINE(_sentence_type, _term_number)) { case COMBINE(_GPS_SENTENCE_GPRMC, 1): // Time in both sentences case COMBINE(_GPS_SENTENCE_GPGGA, 1): _new_time = parse_decimal(); _new_time_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 2): // GPRMC validity _gps_data_good = _term[0] == 'A'; break; case COMBINE(_GPS_SENTENCE_GPRMC, 3): // Latitude case COMBINE(_GPS_SENTENCE_GPGGA, 2): _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 4): // N/S case COMBINE(_GPS_SENTENCE_GPGGA, 3): if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case COMBINE(_GPS_SENTENCE_GPRMC, 5): // Longitude case COMBINE(_GPS_SENTENCE_GPGGA, 4): _new_longitude = parse_degrees(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 6): // E/W case COMBINE(_GPS_SENTENCE_GPGGA, 5): if (_term[0] == 'W') _new_longitude = -_new_longitude; break; case COMBINE(_GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC) _new_speed = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 8): // Course (GPRMC) _new_course = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 9): // Date (GPRMC) _new_date = gpsatol(_term); break; case COMBINE(_GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA) ; 0=invalid, 1=GPS fix, 2=DGPS fix, 6=estimation _gps_data_good = _term[0] > '0'; break; case COMBINE(_GPS_SENTENCE_GPGGA, 7): // NN-Satellites used (GPGGA): 00-12 _new_numsats = (unsigned char)atoi(_term); break; case COMBINE(_GPS_SENTENCE_GPGGA, 8): // D.D - HDOP (GPGGA) - horizontal deviation _new_hdop = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPGGA, 9): // H.H - Altitude (GPGGA) _new_altitude = parse_decimal(); break; default: break; } } return false; }
// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool ParserNMEA::term_complete() { if (_is_checksum_term) { byte checksum = 16 * from_hex(_term[0]) + from_hex(_term[1]); if (checksum == _parity) { if (_gps_data_good) { #ifndef _GPS_NO_STATS ++_good_sentences; #endif _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch(_sentence_type) { case _GPS_SENTENCE_GPRMC: _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; break; case _GPS_SENTENCE_GPVTG: _speed = _new_speed; break; case _GPS_SENTENCE_GPZDA: _time = _new_time; _day = _new_day; _month = _new_month; _year = _new_year; break; case _GPS_SENTENCE_GPGGA: _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _hdop = _new_hdop; break; } return true; } } #ifndef _GPS_NO_STATS else ++_failed_checksum; #endif return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _GPZDA_TERM)) _sentence_type = _GPS_SENTENCE_GPZDA; else if (!gpsstrcmp(_term, _GPGGA_TERM)) _sentence_type = _GPS_SENTENCE_GPGGA; else if (!gpsstrcmp(_term, _GPVTG_TERM)) _sentence_type = _GPS_SENTENCE_GPVTG; else _sentence_type = _GPS_SENTENCE_OTHER; return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) switch(COMBINE(_sentence_type, _term_number)) { case COMBINE(_GPS_SENTENCE_GPZDA, 1): // Time in ZDA _new_time = parse_decimal(); _new_time_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 2): // GPRMC validity _gps_data_good = _term[0] == 'A'; break; case COMBINE(_GPS_SENTENCE_GPRMC, 3): // Latitude _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPGGA, 2): _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 4): // N/S if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case COMBINE(_GPS_SENTENCE_GPGGA, 3): if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case COMBINE(_GPS_SENTENCE_GPGGA, 4): _new_longitude = parse_degrees(); break; case COMBINE(_GPS_SENTENCE_GPGGA, 5): if (_term[0] == 'W') _new_longitude = -_new_longitude; break; case COMBINE(_GPS_SENTENCE_GPVTG, 5): // Speed (GPVTG) _new_speed = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPRMC, 8): // Course (GPRMC) _new_course = parse_decimal(); break; case COMBINE(_GPS_SENTENCE_GPZDA, 2): // Date/day (GPZDA) _new_day = (unsigned char)atoi(_term); break; case COMBINE(_GPS_SENTENCE_GPZDA, 3): // Date/month (GPZDA) _new_month = (unsigned char)atoi(_term); break; case COMBINE(_GPS_SENTENCE_GPZDA, 4): // Date/year (GPZDA) _new_year = parse_decimal() / 100; break; case COMBINE(_GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA) _gps_data_good = _term[0] > '0'; break; case COMBINE(_GPS_SENTENCE_GPGGA, 8): // HDOP _new_hdop = parse_decimal(); break; } return false; }
// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool TinyGPS::term_complete() { if (_is_checksum_term) { byte checksum = 16 * from_hex(_term[0]) + from_hex(_term[1]); if (checksum == _parity) { _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch(_sentence_type) { case _GPS_SENTENCE_PUBX: _gps_fix_quality = _new_gps_fix_quality; _altitude = _new_altitude; _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _sats = _new_sats; _course = _new_course; _vspeed = _new_vspeed; _speed = _new_speed; break; } return true; } return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _PUBX_TERM)) _sentence_type = _GPS_SENTENCE_PUBX; else _sentence_type = _GPS_SENTENCE_OTHER; return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) { switch(400 + _term_number) { // Time case 402: _new_time = parse_decimal(); _new_time_fix = millis(); break; // Latitude case 403: _new_latitude = parse_degrees(); _new_position_fix = millis(); break; // N/S case 404: if (_term[0] == 'S') _new_latitude = -_new_latitude; break; // Longitude case 405: _new_longitude = parse_degrees(); break; // E/W case 406: if (_term[0] == 'W') _new_longitude = -_new_longitude; break; // Speed (in km/h) case 411: _new_speed = parse_decimal(); break; // Course case 412: _new_course = parse_decimal(); break; // Altitude case 407: _new_altitude = parse_decimal(); break; // Sat num case 418: _new_sats = parse_decimal()/100; break; // fix quality case 408: if (_term[0] == 'G' || _term[0] == 'D') { _gps_data_good = true; if (_term[1] == '2') _new_gps_fix_quality = 2; else if (_term[1] == '3') _new_gps_fix_quality = 3; } else { _new_gps_fix_quality = 1; _gps_data_good = false; } break; case 413: _new_vspeed = parse_decimal() * -1; // positive=downwards break; } } return false; }
// Processes a just-completed term // Returns true if new sentence has just passed checksum test and is validated bool TinyGPS::term_complete() { if (_is_checksum_term) { byte checksum = 16 * from_hex(_term[0]) + from_hex(_term[1]); if (checksum == _parity) { if (_gps_data_good) { #ifndef _GPS_NO_STATS ++_good_sentences; #endif _last_time_fix = _new_time_fix; _last_position_fix = _new_position_fix; switch(_sentence_type) { case _GPS_SENTENCE_GPRMC: _time = _new_time; _date = _new_date; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; _course = _new_course; break; case _GPS_SENTENCE_GPGGA: _altitude = _new_altitude; _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _sats = _new_sats; break; // terry case _GPS_SENTENCE_PUBX: _time = _new_time; _latitude = _new_latitude; _longitude = _new_longitude; _speed = _new_speed; _course = _new_course; _altitude = _new_altitude; _sats = _new_sats; //nigey break; // } return true; } } #ifndef _GPS_NO_STATS else ++_failed_checksum; #endif return false; } // the first term determines the sentence type if (_term_number == 0) { if (!gpsstrcmp(_term, _GPRMC_TERM)) _sentence_type = _GPS_SENTENCE_GPRMC; else if (!gpsstrcmp(_term, _GPGGA_TERM)) _sentence_type = _GPS_SENTENCE_GPGGA; // terry else if (!gpsstrcmp(_term, _PUBX_TERM)) _sentence_type = _GPS_SENTENCE_PUBX; // else _sentence_type = _GPS_SENTENCE_OTHER; return false; } if (_sentence_type != _GPS_SENTENCE_OTHER && _term[0]) // terry switch(_sentence_type) { case _GPS_SENTENCE_GPRMC: _term_id = 100 + _term_number; break; case _GPS_SENTENCE_GPGGA: _term_id = 200 + _term_number; break; case _GPS_SENTENCE_PUBX: _term_id = 300 + _term_number; break; } // switch(_term_id) // terry { case 101: // Time in both sentences case 201: case 302: // terry (time PUBX 00) _new_time = parse_decimal(); _new_time_fix = millis(); break; case 102: // GPRMC validity _gps_data_good = _term[0] == 'A'; break; case 103: // Latitude case 202: case 303: // terry (lat PUBX 00) _new_latitude = parse_degrees(); _new_position_fix = millis(); break; case 104: // N/S case 203: case 304: // terry (N/S PUBX 00) if (_term[0] == 'S') _new_latitude = -_new_latitude; break; case 105: // Longitude case 204: case 305: // terry (lon PUBX 00) _new_longitude = parse_degrees(); break; case 106: // E/W case 205: case 306: // terry (E/W PUBX 00) if (_term[0] == 'W') _new_longitude = -_new_longitude; break; case 107: // Speed (GPRMC) _new_speed = parse_decimal(); break; case 108: // Course (GPRMC) case 312: // terry (course PUBX 00) _new_course = parse_decimal(); break; case 109: // Date (GPRMC) _new_date = gpsatol(_term); break; case 206: // Fix data (GPGGA) _gps_data_good = _term[0] > '0'; break; case 209: // Altitude (GPGGA) case 307: // terry (altitude PUBX 00) _new_altitude = parse_decimal(); break; // terry case 301: // PUBX message ID (we want 0) if (_term[0] == '0' && _term[1] == '0') _gps_data_good = 1; break; case 311: // (km/h speed PUBX 00) _new_speed = parse_decimal() / _GPS_KMPH_PER_KNOT; break; case 207: // sats (GPGGA); // (nigey) sats _new_sats = atoi(_term); break; // } return false; }
void parse_gps_term(void) { if (gps_checksum_term) { unsigned char checksum = 16 * gps_from_hex(gps_term[0]) + gps_from_hex(gps_term[1]); if (checksum == gps_parity) { if (gps_data_good) { gps_last_time_fix = gps_new_time_fix; gps_last_position_fix = gps_new_position_fix; switch(gps_sentence_type) { case GPS_SENTENCE_GPRMC: gps_time = gps_new_time; gps_date = gps_new_date; gps_latitude = gps_new_latitude; gps_longitude = gps_new_longitude; gps_speed = gps_new_speed; gps_course = gps_new_course; break; case GPS_SENTENCE_GPGGA: gps_altitude = gps_new_altitude; gps_time = gps_new_time; gps_latitude = gps_new_latitude; gps_longitude = gps_new_longitude; gps_numsats = gps_new_numsats; gps_hdop = gps_new_hdop; break; } return; } } return; } // the first term determines the sentence type if (gps_term_number == 0) { if (!gpsstrcmp(gps_term, GPRMC_TERM)) gps_sentence_type = GPS_SENTENCE_GPRMC; else if (!gpsstrcmp(gps_term, GPGGA_TERM)) gps_sentence_type = GPS_SENTENCE_GPGGA; else gps_sentence_type = GPS_SENTENCE_OTHER; return; } if (gps_sentence_type != GPS_SENTENCE_OTHER && gps_term[0]) switch(COMBINE(gps_sentence_type, gps_term_number)) { case COMBINE(GPS_SENTENCE_GPRMC, 1): // Time in both sentences case COMBINE(GPS_SENTENCE_GPGGA, 1): gps_new_time = gps_parse_decimal(); gps_new_time_fix = main_get_msclock_ticks(); break; case COMBINE(GPS_SENTENCE_GPRMC, 2): // GPRMC validity gps_data_good = gps_term[0] == 'A'; break; case COMBINE(GPS_SENTENCE_GPRMC, 3): // Latitude case COMBINE(GPS_SENTENCE_GPGGA, 2): gps_new_latitude = gps_parse_degrees(); gps_new_position_fix = main_get_msclock_ticks(); break; case COMBINE(GPS_SENTENCE_GPRMC, 4): // N/S case COMBINE(GPS_SENTENCE_GPGGA, 3): if (gps_term[0] == 'S') gps_new_latitude = -gps_new_latitude; break; case COMBINE(GPS_SENTENCE_GPRMC, 5): // Longitude case COMBINE(GPS_SENTENCE_GPGGA, 4): gps_new_longitude = gps_parse_degrees(); break; case COMBINE(GPS_SENTENCE_GPRMC, 6): // E/W case COMBINE(GPS_SENTENCE_GPGGA, 5): if (gps_term[0] == 'W') gps_new_longitude = -gps_new_longitude; break; case COMBINE(GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC) gps_new_speed = gps_parse_decimal(); break; case COMBINE(GPS_SENTENCE_GPRMC, 8): // Course (GPRMC) gps_new_course = gps_parse_decimal(); break; case COMBINE(GPS_SENTENCE_GPRMC, 9): // Date (GPRMC) gps_new_date = gpsatol(gps_term); break; case COMBINE(GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA) gps_data_good = gps_term[0] > '0'; break; case COMBINE(GPS_SENTENCE_GPGGA, 7): // Satellites used (GPGGA) gps_new_numsats = (unsigned char)atoi(gps_term); break; case COMBINE(GPS_SENTENCE_GPGGA, 8): // HDOP gps_new_hdop = gps_parse_decimal(); break; case COMBINE(GPS_SENTENCE_GPGGA, 9): // Altitude (GPGGA) gps_new_altitude = gps_parse_decimal(); break; } }