Basic GPS message parser

Fork of GPS by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
SomeRandomBloke
Date:
Mon Feb 15 20:56:20 2016 +0000
Parent:
1:1f849dbf3b8b
Child:
3:ac28455d8e5a
Commit message:
first commit

Changed in this revision

GPS.cpp Show annotated file Show diff for this revision Revisions of this file
GPS.h Show annotated file Show diff for this revision Revisions of this file
--- a/GPS.cpp	Wed Aug 19 06:58:44 2015 +0000
+++ b/GPS.cpp	Mon Feb 15 20:56:20 2016 +0000
@@ -22,8 +22,8 @@
  
 #include "GPS.h"
 
-GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) {
-    _gps.baud(38400);    
+GPS::GPS(PinName tx, PinName rx, int baudrate) : _gps(tx, rx) {
+    _gps.baud(baudrate);    
     longitude = 0.0;
     latitude = 0.0;        
 }
@@ -66,10 +66,10 @@
 }
 
 float GPS::trunc(float v) {
-    if(v < 0.0) {
-        v*= -1.0;
+    if(v < 0.0f) {
+        v*= -1.0f;
         v = floor(v);
-        v*=-1.0;
+        v*=-1.0f;
     } else {
         v = floor(v);
     }
@@ -78,13 +78,14 @@
 
 void GPS::getline() {
     while(_gps.getc() != '$');    // wait for the start of a line
-    for(int i=0; i<256; i++) {
+    for(int i=0; i<255; i++) {
         msg[i] = _gps.getc();
+//        printf("%c",msg[i]);
         if(msg[i] == '\r') {
             msg[i] = 0;
             return;
         }
     }
-    error("Overflowed message limit");
+//    error("Overflowed message limit");
 //    printf("Overflow");
 }
--- a/GPS.h	Wed Aug 19 06:58:44 2015 +0000
+++ b/GPS.h	Mon Feb 15 20:56:20 2016 +0000
@@ -31,7 +31,7 @@
 
     /** Create the GPS interface, connected to the specified serial port
      */    
-    GPS(PinName tx, PinName rx);
+    GPS(PinName tx, PinName rx, int baudrate = 9600);
     
     /** Sample the incoming GPS data, returning whether there is a lock
      *