nmea gps library - without any serial
Dependents: HARP2 HARP3 20180621_FT813
Fork of GPS_parser by
NMEA GPS Serial Output parser.
Routine taken from NMEA Software Standard (NMEA 0183) http://www.winsystems.com/software/nmea.pdf
Only handles GGA and RMC Messages
Diff: GPS_parser.h
- Revision:
- 7:01a8379370e4
- Parent:
- 6:4ed12067a314
- Child:
- 8:59acef1c795b
--- a/GPS_parser.h Wed Dec 12 17:53:50 2012 +0000 +++ b/GPS_parser.h Thu Dec 13 04:57:10 2012 +0000 @@ -13,75 +13,76 @@ #define PI (3.141592653589793) /** A GPS_parser interface for reading from a Globalsat EM-406 GPS Module */ -class GPS_Parser { +class GPS_Parser +{ public: GPS_Parser(); - - /** Sample the incoming GPS data, returning whether there is a lock - * + + /** Parse the incoming GPS data, returning whether there is a lock + * + * @param line the nmea string to parse, uses tokenizer vs sscanf * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 */ - int sample(char *); - int get_lock() { return lock; } - int get_date() { return date; } - float get_time() { return utc_time; } + int parse(char *); + int get_lock() { + return lock; + } + int get_date() { + return date; + } + float get_time() { + return utc_time; + } float get_nmea_longitude(); float get_nmea_latitude(); float get_dec_longitude(); float get_dec_latitude(); float get_msl_altitude(); - float get_course_t(); - float get_course_m(); + float get_course_d(); float get_speed_k(); float get_speed_km(); - int get_satelites(); + int get_satellites(); float get_altitude_ft(); - + // navigational functions float calc_course_to(float, float); double calc_dist_to_mi(float, float); double calc_dist_to_ft(float, float); double calc_dist_to_km(float, float); double calc_dist_to_m(float, float); - + private: float nmea_to_dec(float, char); float trunc(float v); + char *my_token(char *,char); + + char stat_string[128]; // used in my_token + char *current; + char *field[50]; // used by parse nmea + // calculated values volatile float dec_longitude; volatile float dec_latitude; volatile float altitude_ft; - + // GGA - Global Positioning System Fixed Data volatile float nmea_longitude; - volatile float nmea_latitude; + volatile float nmea_latitude; volatile float utc_time; volatile char ns, ew; volatile int lock; - volatile int satelites; + volatile int satellites; volatile float hdop; volatile float msl_altitude; volatile char msl_units; - + // RMC - Recommended Minimmum Specific GNS Data volatile char rmc_status; volatile float speed_k; volatile float course_d; volatile int date; - - // GLL - volatile char gll_status; - - // VTG - Course over ground, ground speed - volatile float course_t; // ground speed true - volatile char course_t_unit; - volatile float course_m; // magnetic - volatile char course_m_unit; - volatile char speed_k_unit; - volatile float speed_km; // speek km/hr - volatile char speed_km_unit; }; #endif