local copy of gps code
Fork of GPS by
GPS.h@1:d2ea48d59900, 2015-06-16 (annotated)
- Committer:
- ftagius
- Date:
- Tue Jun 16 11:52:07 2015 +0000
- Revision:
- 1:d2ea48d59900
- Parent:
- 0:15611c7938a3
local updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:15611c7938a3 | 1 | /* mbed EM-406 GPS Module Library |
simon | 0:15611c7938a3 | 2 | * Copyright (c) 2008-2010, sford |
simon | 0:15611c7938a3 | 3 | * |
simon | 0:15611c7938a3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
simon | 0:15611c7938a3 | 5 | * of this software and associated documentation files (the "Software"), to deal |
simon | 0:15611c7938a3 | 6 | * in the Software without restriction, including without limitation the rights |
simon | 0:15611c7938a3 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
simon | 0:15611c7938a3 | 8 | * copies of the Software, and to permit persons to whom the Software is |
simon | 0:15611c7938a3 | 9 | * furnished to do so, subject to the following conditions: |
simon | 0:15611c7938a3 | 10 | * |
simon | 0:15611c7938a3 | 11 | * The above copyright notice and this permission notice shall be included in |
simon | 0:15611c7938a3 | 12 | * all copies or substantial portions of the Software. |
simon | 0:15611c7938a3 | 13 | * |
simon | 0:15611c7938a3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
simon | 0:15611c7938a3 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
simon | 0:15611c7938a3 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
simon | 0:15611c7938a3 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
simon | 0:15611c7938a3 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
simon | 0:15611c7938a3 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
simon | 0:15611c7938a3 | 20 | * THE SOFTWARE. |
simon | 0:15611c7938a3 | 21 | */ |
simon | 0:15611c7938a3 | 22 | |
simon | 0:15611c7938a3 | 23 | #include "mbed.h" |
simon | 0:15611c7938a3 | 24 | |
simon | 0:15611c7938a3 | 25 | #ifndef MBED_GPS_H |
simon | 0:15611c7938a3 | 26 | #define MBED_GPS_H |
ftagius | 1:d2ea48d59900 | 27 | #define GGA 3 |
ftagius | 1:d2ea48d59900 | 28 | #define GLL 4 |
ftagius | 1:d2ea48d59900 | 29 | #define RMC 5 |
ftagius | 1:d2ea48d59900 | 30 | #define VTG 6 |
simon | 0:15611c7938a3 | 31 | |
simon | 0:15611c7938a3 | 32 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
simon | 0:15611c7938a3 | 33 | class GPS { |
simon | 0:15611c7938a3 | 34 | public: |
simon | 0:15611c7938a3 | 35 | |
simon | 0:15611c7938a3 | 36 | /** Create the GPS interface, connected to the specified serial port |
simon | 0:15611c7938a3 | 37 | */ |
simon | 0:15611c7938a3 | 38 | GPS(PinName tx, PinName rx); |
simon | 0:15611c7938a3 | 39 | |
simon | 0:15611c7938a3 | 40 | /** Sample the incoming GPS data, returning whether there is a lock |
simon | 0:15611c7938a3 | 41 | * |
simon | 0:15611c7938a3 | 42 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
simon | 0:15611c7938a3 | 43 | */ |
simon | 0:15611c7938a3 | 44 | int sample(); |
ftagius | 1:d2ea48d59900 | 45 | void flushSerialBuffer(void); |
simon | 0:15611c7938a3 | 46 | |
simon | 0:15611c7938a3 | 47 | /** The longitude (call sample() to set) */ |
ftagius | 1:d2ea48d59900 | 48 | float l_longitude; // local longitude |
ftagius | 1:d2ea48d59900 | 49 | float r_longitude; // remote longitude |
simon | 0:15611c7938a3 | 50 | /** The latitude (call sample() to set) */ |
ftagius | 1:d2ea48d59900 | 51 | float l_latitude; // local latitude |
ftagius | 1:d2ea48d59900 | 52 | float r_latitude; // remote latitude |
ftagius | 1:d2ea48d59900 | 53 | float nmea_longitude; |
ftagius | 1:d2ea48d59900 | 54 | float nmea_latitude; |
ftagius | 1:d2ea48d59900 | 55 | float utc_time; |
ftagius | 1:d2ea48d59900 | 56 | char rmc_status; |
ftagius | 1:d2ea48d59900 | 57 | float speed_k; |
ftagius | 1:d2ea48d59900 | 58 | float course_d; |
ftagius | 1:d2ea48d59900 | 59 | int date; |
ftagius | 1:d2ea48d59900 | 60 | float distance; |
ftagius | 1:d2ea48d59900 | 61 | bool lock_valid; |
ftagius | 1:d2ea48d59900 | 62 | // GLL |
ftagius | 1:d2ea48d59900 | 63 | char gll_status; |
simon | 0:15611c7938a3 | 64 | |
ftagius | 1:d2ea48d59900 | 65 | // VTG - Course over ground, ground speed |
ftagius | 1:d2ea48d59900 | 66 | float course_t; // ground speed true |
ftagius | 1:d2ea48d59900 | 67 | char course_t_unit; |
ftagius | 1:d2ea48d59900 | 68 | float course_m; // magnetic |
ftagius | 1:d2ea48d59900 | 69 | char course_m_unit; |
ftagius | 1:d2ea48d59900 | 70 | char speed_k_unit; |
ftagius | 1:d2ea48d59900 | 71 | float speed_km; // speek km/hr |
ftagius | 1:d2ea48d59900 | 72 | char speed_km_unit; |
ftagius | 1:d2ea48d59900 | 73 | void sendCommand(char *str); |
ftagius | 1:d2ea48d59900 | 74 | void setBaud57600(void); |
ftagius | 1:d2ea48d59900 | 75 | int sentences; |
ftagius | 1:d2ea48d59900 | 76 | int sentence_index; |
ftagius | 1:d2ea48d59900 | 77 | int satelites; |
ftagius | 1:d2ea48d59900 | 78 | int sat_data0id; |
ftagius | 1:d2ea48d59900 | 79 | int sat_data0elv; |
ftagius | 1:d2ea48d59900 | 80 | int sat_data0azimuth; |
ftagius | 1:d2ea48d59900 | 81 | int sat_data0sig; |
ftagius | 1:d2ea48d59900 | 82 | int sat_data1id; |
ftagius | 1:d2ea48d59900 | 83 | int sat_data1elv; |
ftagius | 1:d2ea48d59900 | 84 | int sat_data1azimuth; |
ftagius | 1:d2ea48d59900 | 85 | int sat_data1sig; |
ftagius | 1:d2ea48d59900 | 86 | int sat_data2id; |
ftagius | 1:d2ea48d59900 | 87 | int sat_data2elv; |
ftagius | 1:d2ea48d59900 | 88 | int sat_data2azimuth; |
ftagius | 1:d2ea48d59900 | 89 | int sat_data2sig; |
ftagius | 1:d2ea48d59900 | 90 | int sat_data3id; |
ftagius | 1:d2ea48d59900 | 91 | int sat_data3elv; |
ftagius | 1:d2ea48d59900 | 92 | int sat_data3azimuth; |
ftagius | 1:d2ea48d59900 | 93 | int sat_data3sig; |
ftagius | 1:d2ea48d59900 | 94 | |
simon | 0:15611c7938a3 | 95 | private: |
simon | 0:15611c7938a3 | 96 | float trunc(float v); |
simon | 0:15611c7938a3 | 97 | void getline(); |
ftagius | 1:d2ea48d59900 | 98 | |
simon | 0:15611c7938a3 | 99 | Serial _gps; |
ftagius | 1:d2ea48d59900 | 100 | char msg[1024]; |
simon | 0:15611c7938a3 | 101 | |
simon | 0:15611c7938a3 | 102 | }; |
simon | 0:15611c7938a3 | 103 | |
ftagius | 1:d2ea48d59900 | 104 | //extern GPS gps; |
ftagius | 1:d2ea48d59900 | 105 | |
simon | 0:15611c7938a3 | 106 | #endif |