Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class
SerialGPS.h@1:214714f54773, 2021-02-15 (annotated)
- Committer:
- runesla
- Date:
- Mon Feb 15 20:32:48 2021 +0100
- Revision:
- 1:214714f54773
- Parent:
- 0:1a8299deb917
- Child:
- 2:e7f24389167b
switched to unbufferedserial, fixed getline
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
runesla |
0:1a8299deb917 | 1 | /* mbed GPS Module Library |
runesla |
0:1a8299deb917 | 2 | * Copyright (c) 2008-2010, sford |
runesla |
0:1a8299deb917 | 3 | * Copyright (c) 2013, B.Adryan |
runesla |
0:1a8299deb917 | 4 | * |
runesla |
0:1a8299deb917 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
runesla |
0:1a8299deb917 | 6 | * of this software and associated documentation files (the "Software"), to deal |
runesla |
0:1a8299deb917 | 7 | * in the Software without restriction, including without limitation the rights |
runesla |
0:1a8299deb917 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
runesla |
0:1a8299deb917 | 9 | * copies of the Software, and to permit persons to whom the Software is |
runesla |
0:1a8299deb917 | 10 | * furnished to do so, subject to the following conditions: |
runesla |
0:1a8299deb917 | 11 | * |
runesla |
0:1a8299deb917 | 12 | * The above copyright notice and this permission notice shall be included in |
runesla |
0:1a8299deb917 | 13 | * all copies or substantial portions of the Software. |
runesla |
0:1a8299deb917 | 14 | * |
runesla |
0:1a8299deb917 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
runesla |
0:1a8299deb917 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
runesla |
0:1a8299deb917 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
runesla |
0:1a8299deb917 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
runesla |
0:1a8299deb917 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
runesla |
0:1a8299deb917 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
runesla |
0:1a8299deb917 | 21 | * THE SOFTWARE. |
runesla |
0:1a8299deb917 | 22 | */ |
runesla |
0:1a8299deb917 | 23 | |
runesla |
0:1a8299deb917 | 24 | #include "mbed.h" |
runesla |
0:1a8299deb917 | 25 | |
runesla |
0:1a8299deb917 | 26 | #ifndef MBED_GPS_H |
runesla |
0:1a8299deb917 | 27 | #define MBED_GPS_H |
runesla |
0:1a8299deb917 | 28 | |
runesla |
0:1a8299deb917 | 29 | /** |
runesla |
0:1a8299deb917 | 30 | * A SerialGPS interface for reading from a serial GPS module |
runesla |
0:1a8299deb917 | 31 | */ |
runesla |
1:214714f54773 | 32 | class SerialGPS { |
runesla |
0:1a8299deb917 | 33 | public: |
runesla |
0:1a8299deb917 | 34 | |
runesla |
0:1a8299deb917 | 35 | /** Create the SerialGPS interface, connected to the specified serial port and speed. |
runesla |
0:1a8299deb917 | 36 | * for example, GlobalSat EM406-A (e.g. on SparkFun GPS Shield) is 4800 Baud, |
runesla |
0:1a8299deb917 | 37 | * Adafruit Ultimate GPSv3 (connected to serial) is 9600 Baud |
runesla |
0:1a8299deb917 | 38 | */ |
runesla |
0:1a8299deb917 | 39 | SerialGPS(PinName tx, PinName rx, int baud); |
runesla |
0:1a8299deb917 | 40 | |
runesla |
0:1a8299deb917 | 41 | /** Sample the incoming GPS data, returning whether there is a lock |
runesla |
0:1a8299deb917 | 42 | * |
runesla |
0:1a8299deb917 | 43 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
runesla |
0:1a8299deb917 | 44 | */ |
runesla |
0:1a8299deb917 | 45 | int sample(); |
runesla |
0:1a8299deb917 | 46 | |
runesla |
0:1a8299deb917 | 47 | /** |
runesla |
0:1a8299deb917 | 48 | * The longitude (call sample() to set) |
runesla |
0:1a8299deb917 | 49 | */ |
runesla |
0:1a8299deb917 | 50 | float longitude; |
runesla |
0:1a8299deb917 | 51 | |
runesla |
0:1a8299deb917 | 52 | /** |
runesla |
0:1a8299deb917 | 53 | * The latitude (call sample() to set) |
runesla |
0:1a8299deb917 | 54 | */ |
runesla |
0:1a8299deb917 | 55 | float latitude; |
runesla |
0:1a8299deb917 | 56 | |
runesla |
0:1a8299deb917 | 57 | /** |
runesla |
0:1a8299deb917 | 58 | * The time (call sample() to set) |
runesla |
0:1a8299deb917 | 59 | */ |
runesla |
0:1a8299deb917 | 60 | float time; |
runesla |
0:1a8299deb917 | 61 | |
runesla |
0:1a8299deb917 | 62 | /** |
runesla |
0:1a8299deb917 | 63 | * Number of satellites received (call sample() to set) |
runesla |
0:1a8299deb917 | 64 | */ |
runesla |
0:1a8299deb917 | 65 | int sats; |
runesla |
0:1a8299deb917 | 66 | |
runesla |
0:1a8299deb917 | 67 | /** Horizontal dilusion of precision (call sample() to set) */ |
runesla |
0:1a8299deb917 | 68 | float hdop; |
runesla |
0:1a8299deb917 | 69 | |
runesla |
0:1a8299deb917 | 70 | /** The altitude (call sample() to set) |
runesla |
0:1a8299deb917 | 71 | * Note that the accurate altitude is corrected by the geoid |
runesla |
0:1a8299deb917 | 72 | * See http://homepages.slingshot.co.nz/~geoff36/datum.htm |
runesla |
0:1a8299deb917 | 73 | */ |
runesla |
0:1a8299deb917 | 74 | float alt; |
runesla |
0:1a8299deb917 | 75 | |
runesla |
0:1a8299deb917 | 76 | /** The geoid (call sample() to set) */ |
runesla |
0:1a8299deb917 | 77 | float geoid; |
runesla |
0:1a8299deb917 | 78 | |
runesla |
0:1a8299deb917 | 79 | /** |
runesla |
0:1a8299deb917 | 80 | * The NMEA sentence |
runesla |
0:1a8299deb917 | 81 | */ |
runesla |
0:1a8299deb917 | 82 | char msg[256]; |
runesla |
0:1a8299deb917 | 83 | |
runesla |
0:1a8299deb917 | 84 | |
runesla |
0:1a8299deb917 | 85 | private: |
runesla |
0:1a8299deb917 | 86 | float trunc(float v); |
runesla |
0:1a8299deb917 | 87 | void getline(); |
runesla |
0:1a8299deb917 | 88 | |
runesla |
1:214714f54773 | 89 | UnbufferedSerial* _gps_p; |
runesla |
1:214714f54773 | 90 | UnbufferedSerial& _gps; |
runesla |
0:1a8299deb917 | 91 | }; |
runesla |
0:1a8299deb917 | 92 | |
runesla |
0:1a8299deb917 | 93 | #endif |