This library (beta release) parses the GPS data coming from the TD1204. Beware, not all functionality has been fully tested.

Dependents:   QW-TEMP_GPS-NMEA

Committer:
quicksand
Date:
Wed May 18 14:47:17 2016 +0000
Revision:
0:67f22e813b74
Version for NMEA message parsing on the QW boards

Who changed what in which revision?

UserRevisionLine numberNew contents of line
quicksand 0:67f22e813b74 1 #include "mbed.h"
quicksand 0:67f22e813b74 2
quicksand 0:67f22e813b74 3 #ifndef MBED_GPS_H
quicksand 0:67f22e813b74 4 #define MBED_GPS_H
quicksand 0:67f22e813b74 5
quicksand 0:67f22e813b74 6 #define NO_LOCK 1
quicksand 0:67f22e813b74 7 #define NOT_PARSED 2
quicksand 0:67f22e813b74 8 #define GGA 3
quicksand 0:67f22e813b74 9 #define GLL 4
quicksand 0:67f22e813b74 10 #define RMC 5
quicksand 0:67f22e813b74 11 #define VTG 6
quicksand 0:67f22e813b74 12 #define ESTIMATE 7
quicksand 0:67f22e813b74 13 #define GSA 8
quicksand 0:67f22e813b74 14
quicksand 0:67f22e813b74 15 #define PI (3.141592653589793)
quicksand 0:67f22e813b74 16
quicksand 0:67f22e813b74 17 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */
quicksand 0:67f22e813b74 18 class GPS {
quicksand 0:67f22e813b74 19 public:
quicksand 0:67f22e813b74 20
quicksand 0:67f22e813b74 21 /** Create the GPS interface, connected to the specified serial port
quicksand 0:67f22e813b74 22 */
quicksand 0:67f22e813b74 23 GPS(PinName tx, PinName rx);
quicksand 0:67f22e813b74 24
quicksand 0:67f22e813b74 25 /** Sample the incoming GPS data, returning whether there is a lock
quicksand 0:67f22e813b74 26 *
quicksand 0:67f22e813b74 27 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
quicksand 0:67f22e813b74 28 */
quicksand 0:67f22e813b74 29 int sample();
quicksand 0:67f22e813b74 30 char operating_mode;
quicksand 0:67f22e813b74 31 int navigation_mode;
quicksand 0:67f22e813b74 32 int satellites[12];
quicksand 0:67f22e813b74 33 float pdop;
quicksand 0:67f22e813b74 34 float hdop;
quicksand 0:67f22e813b74 35 float vdop;
quicksand 0:67f22e813b74 36 char gprmc_status;
quicksand 0:67f22e813b74 37
quicksand 0:67f22e813b74 38 float get_nmea_longitude();
quicksand 0:67f22e813b74 39 float get_nmea_latitude();
quicksand 0:67f22e813b74 40 float get_dec_longitude();
quicksand 0:67f22e813b74 41 float get_dec_latitude();
quicksand 0:67f22e813b74 42 float get_msl_altitude();
quicksand 0:67f22e813b74 43 float get_course_t();
quicksand 0:67f22e813b74 44 float get_course_m();
quicksand 0:67f22e813b74 45 float get_speed_k();
quicksand 0:67f22e813b74 46 float get_speed_km();
quicksand 0:67f22e813b74 47 int get_satelites();
quicksand 0:67f22e813b74 48 float get_altitude_ft();
quicksand 0:67f22e813b74 49 char * get_nmea_to_td();
quicksand 0:67f22e813b74 50 char tdformat[32];
quicksand 0:67f22e813b74 51
quicksand 0:67f22e813b74 52 // navigational functions
quicksand 0:67f22e813b74 53 float calc_course_to(float, float);
quicksand 0:67f22e813b74 54 double calc_dist_to_mi(float, float);
quicksand 0:67f22e813b74 55 double calc_dist_to_ft(float, float);
quicksand 0:67f22e813b74 56 double calc_dist_to_km(float, float);
quicksand 0:67f22e813b74 57 double calc_dist_to_m(float, float);
quicksand 0:67f22e813b74 58
quicksand 0:67f22e813b74 59 private:
quicksand 0:67f22e813b74 60 float nmea_to_dec(float, char);
quicksand 0:67f22e813b74 61 float trunc(float v);
quicksand 0:67f22e813b74 62 void getline();
quicksand 0:67f22e813b74 63 void format_for_log(void);
quicksand 0:67f22e813b74 64
quicksand 0:67f22e813b74 65 Serial _gps;
quicksand 0:67f22e813b74 66 char msg[1024];
quicksand 0:67f22e813b74 67 char bfr[1030];
quicksand 0:67f22e813b74 68
quicksand 0:67f22e813b74 69 // calculated values
quicksand 0:67f22e813b74 70 float dec_longitude;
quicksand 0:67f22e813b74 71 float dec_latitude;
quicksand 0:67f22e813b74 72 float altitude_ft;
quicksand 0:67f22e813b74 73
quicksand 0:67f22e813b74 74 // GGA - Global Positioning System Fixed Data
quicksand 0:67f22e813b74 75 float nmea_longitude;
quicksand 0:67f22e813b74 76 float nmea_latitude;
quicksand 0:67f22e813b74 77 float utc_time;
quicksand 0:67f22e813b74 78 char ns, ew;
quicksand 0:67f22e813b74 79 int lock;
quicksand 0:67f22e813b74 80 int satelites;
quicksand 0:67f22e813b74 81 float msl_altitude;
quicksand 0:67f22e813b74 82 char msl_units;
quicksand 0:67f22e813b74 83
quicksand 0:67f22e813b74 84 // RMC - Recommended Minimmum Specific GNS Data
quicksand 0:67f22e813b74 85 char rmc_status;
quicksand 0:67f22e813b74 86 float speed_k;
quicksand 0:67f22e813b74 87 float course_d;
quicksand 0:67f22e813b74 88 int date;
quicksand 0:67f22e813b74 89
quicksand 0:67f22e813b74 90 // GLL
quicksand 0:67f22e813b74 91 char gll_status;
quicksand 0:67f22e813b74 92
quicksand 0:67f22e813b74 93 // VTG - Course over ground, ground speed
quicksand 0:67f22e813b74 94 float course_t; // ground speed true
quicksand 0:67f22e813b74 95 char course_t_unit;
quicksand 0:67f22e813b74 96 float course_m; // magnetic
quicksand 0:67f22e813b74 97 char course_m_unit;
quicksand 0:67f22e813b74 98 char speed_k_unit;
quicksand 0:67f22e813b74 99 float speed_km; // speek km/hr
quicksand 0:67f22e813b74 100 char speed_km_unit;
quicksand 0:67f22e813b74 101 };
quicksand 0:67f22e813b74 102
quicksand 0:67f22e813b74 103 #endif