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 05:52:43 2012 +0000
Revision:
8:59acef1c795b
Parent:
7:01a8379370e4
parser return to show line parsed

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 7:01a8379370e4 44 int get_satellites();
tylerjw 5:94daced1e61a 45 float get_altitude_ft();
tylerjw 7:01a8379370e4 46
tylerjw 5:94daced1e61a 47 // navigational functions
tylerjw 5:94daced1e61a 48 float calc_course_to(float, float);
tylerjw 5:94daced1e61a 49 double calc_dist_to_mi(float, float);
tylerjw 5:94daced1e61a 50 double calc_dist_to_ft(float, float);
tylerjw 5:94daced1e61a 51 double calc_dist_to_km(float, float);
tylerjw 5:94daced1e61a 52 double calc_dist_to_m(float, float);
tylerjw 7:01a8379370e4 53
tylerjw 5:94daced1e61a 54 private:
tylerjw 5:94daced1e61a 55 float nmea_to_dec(float, char);
tylerjw 5:94daced1e61a 56 float trunc(float v);
tylerjw 7:01a8379370e4 57 char *my_token(char *,char);
tylerjw 7:01a8379370e4 58
tylerjw 7:01a8379370e4 59 char stat_string[128]; // used in my_token
tylerjw 7:01a8379370e4 60 char *current;
tylerjw 5:94daced1e61a 61
tylerjw 7:01a8379370e4 62 char *field[50]; // used by parse nmea
tylerjw 7:01a8379370e4 63
tylerjw 5:94daced1e61a 64 // calculated values
tylerjw 5:94daced1e61a 65 volatile float dec_longitude;
tylerjw 5:94daced1e61a 66 volatile float dec_latitude;
tylerjw 5:94daced1e61a 67 volatile float altitude_ft;
tylerjw 7:01a8379370e4 68
tylerjw 5:94daced1e61a 69 // GGA - Global Positioning System Fixed Data
tylerjw 5:94daced1e61a 70 volatile float nmea_longitude;
tylerjw 7:01a8379370e4 71 volatile float nmea_latitude;
tylerjw 5:94daced1e61a 72 volatile float utc_time;
tylerjw 5:94daced1e61a 73 volatile char ns, ew;
tylerjw 5:94daced1e61a 74 volatile int lock;
tylerjw 7:01a8379370e4 75 volatile int satellites;
tylerjw 5:94daced1e61a 76 volatile float hdop;
tylerjw 5:94daced1e61a 77 volatile float msl_altitude;
tylerjw 5:94daced1e61a 78 volatile char msl_units;
tylerjw 7:01a8379370e4 79
tylerjw 5:94daced1e61a 80 // RMC - Recommended Minimmum Specific GNS Data
tylerjw 5:94daced1e61a 81 volatile char rmc_status;
tylerjw 5:94daced1e61a 82 volatile float speed_k;
tylerjw 5:94daced1e61a 83 volatile float course_d;
tylerjw 5:94daced1e61a 84 volatile int date;
tylerjw 5:94daced1e61a 85 };
tylerjw 5:94daced1e61a 86
tylerjw 5:94daced1e61a 87 #endif