nmea gps library - without any serial

Dependents:   HARP2 HARP3 20180621_FT813

Fork of GPS_parser by Tyler Weaver

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

Committer:
tylerjw
Date:
Thu Dec 13 04:57:10 2012 +0000
Revision:
7:01a8379370e4
Parent:
6:4ed12067a314
Child:
8:59acef1c795b
tokenizer replaces sscanf :)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tylerjw 5:94daced1e61a 1 #include "mbed.h"
tylerjw 5:94daced1e61a 2
tylerjw 5:94daced1e61a 3 #ifndef MBED_GPS_PARSER_H
tylerjw 5:94daced1e61a 4 #define MBED_GPS_PARSER_H
tylerjw 5:94daced1e61a 5
tylerjw 5:94daced1e61a 6 #define NO_LOCK 1
tylerjw 5:94daced1e61a 7 #define NOT_PARSED 2
tylerjw 5:94daced1e61a 8 #define GGA 3
tylerjw 5:94daced1e61a 9 #define GLL 4
tylerjw 5:94daced1e61a 10 #define RMC 5
tylerjw 5:94daced1e61a 11 #define VTG 6
tylerjw 5:94daced1e61a 12
tylerjw 5:94daced1e61a 13 #define PI (3.141592653589793)
tylerjw 5:94daced1e61a 14
tylerjw 5:94daced1e61a 15 /** A GPS_parser interface for reading from a Globalsat EM-406 GPS Module */
tylerjw 7:01a8379370e4 16 class GPS_Parser
tylerjw 7:01a8379370e4 17 {
tylerjw 5:94daced1e61a 18 public:
tylerjw 5:94daced1e61a 19
tylerjw 5:94daced1e61a 20 GPS_Parser();
tylerjw 7:01a8379370e4 21
tylerjw 7:01a8379370e4 22 /** Parse the incoming GPS data, returning whether there is a lock
tylerjw 7:01a8379370e4 23 *
tylerjw 7:01a8379370e4 24 * @param line the nmea string to parse, uses tokenizer vs sscanf
tylerjw 5:94daced1e61a 25 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
tylerjw 5:94daced1e61a 26 */
tylerjw 7:01a8379370e4 27 int parse(char *);
tylerjw 7:01a8379370e4 28 int get_lock() {
tylerjw 7:01a8379370e4 29 return lock;
tylerjw 7:01a8379370e4 30 }
tylerjw 7:01a8379370e4 31 int get_date() {
tylerjw 7:01a8379370e4 32 return date;
tylerjw 7:01a8379370e4 33 }
tylerjw 7:01a8379370e4 34 float get_time() {
tylerjw 7:01a8379370e4 35 return utc_time;
tylerjw 7:01a8379370e4 36 }
tylerjw 5:94daced1e61a 37 float get_nmea_longitude();
tylerjw 5:94daced1e61a 38 float get_nmea_latitude();
tylerjw 5:94daced1e61a 39 float get_dec_longitude();
tylerjw 5:94daced1e61a 40 float get_dec_latitude();
tylerjw 5:94daced1e61a 41 float get_msl_altitude();
tylerjw 7:01a8379370e4 42 float get_course_d();
tylerjw 5:94daced1e61a 43 float get_speed_k();
tylerjw 5:94daced1e61a 44 float get_speed_km();
tylerjw 7:01a8379370e4 45 int get_satellites();
tylerjw 5:94daced1e61a 46 float get_altitude_ft();
tylerjw 7:01a8379370e4 47
tylerjw 5:94daced1e61a 48 // navigational functions
tylerjw 5:94daced1e61a 49 float calc_course_to(float, float);
tylerjw 5:94daced1e61a 50 double calc_dist_to_mi(float, float);
tylerjw 5:94daced1e61a 51 double calc_dist_to_ft(float, float);
tylerjw 5:94daced1e61a 52 double calc_dist_to_km(float, float);
tylerjw 5:94daced1e61a 53 double calc_dist_to_m(float, float);
tylerjw 7:01a8379370e4 54
tylerjw 5:94daced1e61a 55 private:
tylerjw 5:94daced1e61a 56 float nmea_to_dec(float, char);
tylerjw 5:94daced1e61a 57 float trunc(float v);
tylerjw 7:01a8379370e4 58 char *my_token(char *,char);
tylerjw 7:01a8379370e4 59
tylerjw 7:01a8379370e4 60 char stat_string[128]; // used in my_token
tylerjw 7:01a8379370e4 61 char *current;
tylerjw 5:94daced1e61a 62
tylerjw 7:01a8379370e4 63 char *field[50]; // used by parse nmea
tylerjw 7:01a8379370e4 64
tylerjw 5:94daced1e61a 65 // calculated values
tylerjw 5:94daced1e61a 66 volatile float dec_longitude;
tylerjw 5:94daced1e61a 67 volatile float dec_latitude;
tylerjw 5:94daced1e61a 68 volatile float altitude_ft;
tylerjw 7:01a8379370e4 69
tylerjw 5:94daced1e61a 70 // GGA - Global Positioning System Fixed Data
tylerjw 5:94daced1e61a 71 volatile float nmea_longitude;
tylerjw 7:01a8379370e4 72 volatile float nmea_latitude;
tylerjw 5:94daced1e61a 73 volatile float utc_time;
tylerjw 5:94daced1e61a 74 volatile char ns, ew;
tylerjw 5:94daced1e61a 75 volatile int lock;
tylerjw 7:01a8379370e4 76 volatile int satellites;
tylerjw 5:94daced1e61a 77 volatile float hdop;
tylerjw 5:94daced1e61a 78 volatile float msl_altitude;
tylerjw 5:94daced1e61a 79 volatile char msl_units;
tylerjw 7:01a8379370e4 80
tylerjw 5:94daced1e61a 81 // RMC - Recommended Minimmum Specific GNS Data
tylerjw 5:94daced1e61a 82 volatile char rmc_status;
tylerjw 5:94daced1e61a 83 volatile float speed_k;
tylerjw 5:94daced1e61a 84 volatile float course_d;
tylerjw 5:94daced1e61a 85 volatile int date;
tylerjw 5:94daced1e61a 86 };
tylerjw 5:94daced1e61a 87
tylerjw 5:94daced1e61a 88 #endif