From b4bd12a8d6e242cbf96a4ffec1312d2d6f203427 Mon Sep 17 00:00:00 2001 From: Andy Lindsay Date: Wed, 22 May 2019 10:13:59 -0700 Subject: [PATCH] Update gps parser for new NMEA protocol #182 --- .../Sensor/libgps/cmm/libgps.a | Bin 14860 -> 15796 bytes Learn/Simple Libraries/Sensor/libgps/gps.h | 20 ++++--- .../Simple Libraries/Sensor/libgps/gps_run.c | 49 +++++++++++++++--- .../Sensor/libgps/gps_sources.c | 39 ++++++++++++++ Learn/Simple Libraries/Sensor/libgps/libgps.c | 6 +-- .../Sensor/libgps/libgps.side | 1 + version.txt | 2 +- 7 files changed, 99 insertions(+), 18 deletions(-) create mode 100644 Learn/Simple Libraries/Sensor/libgps/gps_sources.c diff --git a/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a b/Learn/Simple Libraries/Sensor/libgps/cmm/libgps.a index a0806064d0d7785349c5222cc2997b76f7f780b7..e3a9c15233237993449b3b5a3fbcc5d6e5c5b375 100644 GIT binary patch delta 3504 zcmbW4Yiv|i5XWawq*u%r`?m1eMiAE!_#i2wbE<{j3tgR4)}!_c#%>#*;xqRD1Nn+VBMtv?-~yg%|(7+QCUcqhqX<+$1;>XeUS8 z*)u-Z_M*-4_?i`R)ZQwu`aSZN{kXSpFg4USv^~9Z^OhkpjDh~)e!0(axX!F#Oo(VO z%+(4TB@6|Fu}EY*;PKjRDcN1nm1p3wf)Yp51J@EF-Vv7V&New!)M87G*A)L@pde%e#ZN-(|d@BY#CvCE~I>`xrSlyMc5Yc#y z3vqpXswROFEUN8k&QrQjFr1J083 zt?p}s>xx%J7E;Vl@h;)%^=wQ3G)Q#DJHoAd#6B+O{b;LsU7YCNM6{LfO(I-AU3}3P zAuC!}WKM~z0k?Z3J$a^n!ut!4sJawiCU%#_SBu@=_+w%vQKp<{dH2Rvhy!mfJ77$$ z+8bXl(hclqdPJmWD_SnnB~0$UypGz8FR#WL>beEHmA5uK_)#K$6i_$oT2`JT?-%T_ zPub;DRZRuXBB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qOxL*32 zh}SF5iqNZ;IUYVPLa)IR^vH=3t{Qr0Y$t`07J8*WLM9kH;D}&!3U{yzxnFUu@Yn>`HNT#egw?d~v#|f%{kAoSzBwJs0}- z)_XD$UEkvVl5+-HRx+7Nsc%EEni~OB3rpF@n3PCRiicaT7^Me9J{%A!`%E2Lb>AcB zt?$-WS05ey=5B@_QD^4V^aDb+_`;|J@)ta zs+HZt#(=sIYYDwxA~Lc_O_wzX$B~nza>16s`GA_PZR7Aku&pw+NaRnPTa3%Y>T
(diH{i#o1fZm~Zhy{Ml`;U7jzV}^l$)~SC|Kf?i2F;4y9l?w6HeHHX z@A(>iEyC;_>22`^#C`g1-vwKIdbb*l_peII+HDzlqLT-k)`94ox_C(AkV>ejcN!W{~Z`Z&828f zj2Oh^Nf`dA#EjS|O=R8c&13{dF}9M+ae%RF%%Elq?)1n%;4WImy=F}T@iqZ}ja_!DH7 z4a5Jpn9FUHlVlWt*My9dbpdaa`4Iqn4{jI0mOMkDD_~E%TYZkqR|xDAxLd)OWL?2U zvQFp+5C2To1+b0X0;W7MH^2qAg1>n}SMV;SpR;e(#}j#P4u{mtwi67zlx m*k6gNx{IHQ&v(s!A 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