Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class

Files at this revision

API Documentation at this revision

Comitter:
runesla
Date:
Fri Apr 23 09:38:08 2021 +0200
Parent:
4:2c76f1ec13a9
Commit message:
small fixes

Changed in this revision

SerialGPS.cpp Show annotated file Show diff for this revision Revisions of this file
SerialGPS.h Show annotated file Show diff for this revision Revisions of this file
diff -r 2c76f1ec13a9 -r cc8f9d7f9bdb SerialGPS.cpp
--- a/SerialGPS.cpp	Thu Apr 01 21:18:48 2021 +0200
+++ b/SerialGPS.cpp	Fri Apr 23 09:38:08 2021 +0200
@@ -134,27 +134,17 @@
 void SerialGPS::getline() 
 {
     char ch;
-    int idx = -1;
+    uint8_t idx = 0;
 
-    if(!this->_gps_p->readable()) { return; }
+    //MBED_ASSERT(this->_gps->readable());
 
     // Wait for start of sentence
     while(read_char() != '$');
 
-    // Read from serial one char at a time until max length or read terminal
-    while(idx++ <= MAX_LINELENGTH)
+    // Read character until EOL
+    while((ch = read_char()) != '\r')
     {
-        ch = read_char();
-
-        if(ch == '\r') { break; }
-
         this->_nmea[idx] = ch;
+        idx++;
     }
-}
-
-char SerialGPS::read_char()
-{
-    char ch;
-    _gps_p->read(&ch, 1);
-    return ch;
 }
\ No newline at end of file
diff -r 2c76f1ec13a9 -r cc8f9d7f9bdb SerialGPS.h
--- a/SerialGPS.h	Thu Apr 01 21:18:48 2021 +0200
+++ b/SerialGPS.h	Fri Apr 23 09:38:08 2021 +0200
@@ -57,6 +57,18 @@
         bool fix();
 
         /**
+         * Read one character from the UART interface
+         *
+         * @return ch the character extracted from the UART interface
+         */
+        inline char read_char()
+        {
+            char ch;
+            this->_gps_p->read(&ch, 1);
+            return ch;
+        }
+
+        /**
         * Helper function for converting from Decimal Minutes Seconds (DMS) to Decimal Degrees (DD)
         *
         * @param dms float containing the DMS value
@@ -70,7 +82,7 @@
             float deg = (int) degmin / 100;
             float min = (int) degmin % 100;
 
-            float dd = deg + (min / 60.0) + (sec / 60);
+            float dd = deg + (min / 60.0) + (sec / 3600);
 
             return dd;
         };