diff --git a/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a b/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a index a0806064..e3a9c152 100644 Binary files a/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a and b/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a differ diff --git a/Learn/Simple Libraries/Sensor/libgps/gps.h b/Learn/Simple Libraries/Sensor/libgps/gps.h index 3e83e95e..1308ac6d 100644 --- a/Learn/Simple Libraries/Sensor/libgps/gps.h +++ b/Learn/Simple Libraries/Sensor/libgps/gps.h @@ -1,15 +1,14 @@ /** * @file gps.h * - * @author Daniel Harris + * @author Daniel Harris, Matthew Matz * * @copyright - * Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed. + * Copyright (C) Parallax, Inc. 2019. All Rights MIT Licensed. * * @brief This library provides basic NMEA parsing capabilities. It is designed to take raw NMEA strings, - parse the data out of them, and make the data available to a parent application through accessor - functions. - + * parse the data out of them, and make the data available to a parent application through accessor + * functions. * * @par Core Usage * Each call to rfid_open launches a serial communication process into another core. @@ -17,7 +16,7 @@ * @par Memory Models * Use with CMM or LMM. * - * @version 0.50 + * @version 0.6 */ #ifndef __SIMPLE_NMEA_PARSER__ @@ -57,6 +56,7 @@ typedef struct nmea_data_s float date; //current date, raw format with tenths of second, as float int time; //current UTC time, raw format, as integer float mag_var; //current magnetic variation, as float + char talker_ids[65]; //constellation ('P'=GPS, 'N'=GLONASS, Galileo, BeiDou, etc.) codes from the last positioning reads) } nmea_data; @@ -194,6 +194,14 @@ float gps_magneticVariation(); */ void gps_txByte(int txByte); + +/** + * @brief Provides the caller with a string containing the sources (Talker IDs) of the last 64 positioning reads. The most recent read is stored at character 0. + * + * @returns A string of length 65 (including null terminator) containing the second letter of the source's talker-ID. See http://catb.org/gpsd/NMEA.html#_talker_ids for more info. + */ +char* gps_sources(); + #if defined(__cplusplus) } #endif diff --git a/Learn/Simple Libraries/Sensor/libgps/gps_run.c b/Learn/Simple Libraries/Sensor/libgps/gps_run.c index 2e1e2b9a..58f56b65 100644 --- a/Learn/Simple Libraries/Sensor/libgps/gps_run.c +++ b/Learn/Simple Libraries/Sensor/libgps/gps_run.c @@ -21,7 +21,7 @@ gps_byte_t *ptrBuff; fdserial *gps_ser; - +void ParseTID(char tid); void ParseRMC(); void ParseGGA(); void PrepBuff(); @@ -31,6 +31,10 @@ void gps_run(void *par) gps_byte_t tempBuff[16]; gps_byte_t ch; int idx; + + // Set the string of constellation sources read to all characters + memset(gps_data.talker_ids, ' ', sizeof(gps_data.talker_ids)); + gps_data.talker_ids[64] = 0; gps_ser = fdserial_open(_gps_rx_pin, _gps_tx_pin, 0, _gps_baud); for(;;) @@ -54,20 +58,51 @@ void gps_run(void *par) { ch = fdserial_rxChar(gps_ser); inBuff[idx++] = ch; - }while(ch != 13); + } while(ch != 13); inBuff[idx] = 0; //null terminate //got the full sentence, do a little prep work to get ready for parsing. //modifies inBuff! PrepBuff(); - if(strncmp(inBuff, "GPRMC", 5) == 0) - ParseRMC(); - if(strncmp(inBuff, "GPGGA", 5) == 0) - ParseGGA(); + // Determine Constellation/Transmission Source: + // More info here: http://catb.org/gpsd/NMEA.html#_talker_ids + if(inBuff[0] == 'G' || inBuff[0] == 'B' || inBuff[0] == 'Q') + { + if(inBuff[0] == 'B' && inBuff[1] == 'D') + { + // BeiDou has two different codes + // this sets the second char to 'B' if it's BeiDou. + inBuff[1] = 'B'; + } + + if(inBuff[2] == 'R' && inBuff[3] == 'M' && inBuff[4] == 'C') + { + ParseTID(inBuff[1]); + ParseRMC(); + } + + if(inBuff[2] == 'G' && inBuff[3] == 'G' && inBuff[4] == 'A') + { + ParseTID(inBuff[1]); + ParseGGA(); + } + } } } +void ParseTID(char tid) +{ + int gcr; + // Copy the letter-code for the constellation read from into the string + for (gcr = 0; gcr < 64; gcr++) + { + gps_data.talker_ids[gcr + 1] = gps_data.talker_ids[gcr]; + } + gps_data.talker_ids[64] = 0; + gps_data.talker_ids[0] = tid; +} + void ParseRMC() { int i; @@ -131,8 +166,6 @@ void ParseRMC() ptrBuff = strtok(NULL,","); i++; } - - } void ParseGGA() diff --git a/Learn/Simple Libraries/Sensor/libgps/gps_sources.c b/Learn/Simple Libraries/Sensor/libgps/gps_sources.c new file mode 100644 index 00000000..abd9baff --- /dev/null +++ b/Learn/Simple Libraries/Sensor/libgps/gps_sources.c @@ -0,0 +1,39 @@ +/** + * @author Matthew Matz + * + * @copyright + * Copyright (C) Parallax, Inc. 2019. All Rights MIT Licensed. + * + * @version 0.60 + */ + +#include "gps.h" + +volatile nmea_data gps_data; + +char* gps_sources() +{ + return(gps_data.talker_ids); +} + +/** + * TERMS OF USE: MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ \ No newline at end of file diff --git a/Learn/Simple Libraries/Sensor/libgps/libgps.c b/Learn/Simple Libraries/Sensor/libgps/libgps.c index 10d56583..2cea137f 100644 --- a/Learn/Simple Libraries/Sensor/libgps/libgps.c +++ b/Learn/Simple Libraries/Sensor/libgps/libgps.c @@ -22,8 +22,8 @@ //#define ENABLE_LCD #define ENABLE_PC -#define GPS_RXIN_PIN 0 -#define GPS_TXOUT_PIN 1 +#define GPS_RXIN_PIN 13 +#define GPS_TXOUT_PIN -1 #define GPS_BAUD 9600 #define LCD_PIN 14 @@ -86,7 +86,7 @@ int main() // main() function print("%f %f", gps_latitude(), gps_longitude()); //sleep for 1/4 second - usleep(250000); + pause(250); #endif //end ENABLE_PC diff --git a/Learn/Simple Libraries/Sensor/libgps/libgps.side b/Learn/Simple Libraries/Sensor/libgps/libgps.side index 4db58bc5..34625520 100644 --- a/Learn/Simple Libraries/Sensor/libgps/libgps.side +++ b/Learn/Simple Libraries/Sensor/libgps/libgps.side @@ -16,6 +16,7 @@ gps_satsTracked.c gps_velocity.c gps.h gps_txByte.c +gps_sources.c >compiler=C >memtype=cmm main ram compact >optimize=-Os diff --git a/version.txt b/version.txt index 04d6a070..7e08346d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.4.116 +v1.4.117