library for parsing GPS NMEA strings using serial receive interrupt

Fork of GPSINT by Joseph Bradshaw

GPSINT library

Library class for intercepting NMEA-0183 ASCII strings from a GPS using a serial interrupt at 4800 baud, error checking, and parsing using the scanf functions to update object associated variables

include the mbed library with this snippet

// mbed GPS Parse Program, tested using the Trimble Copernicus II
#include "mbed.h"
#include "GPSINT.h"

#define TIMEZONE -4 //Eastern Standard Time

Serial pc(USBTX,USBRX);
GPSINT gps(p28, p27);   //Tx,Rx
DigitalOut led1(LED1);

// ---------------- MAIN ------------------------
int main() {        
    pc.baud(921600);
  
    while(1) {
        if(gps.lock != 0){
            led1=!led1;
            
            int gpsHour = (int)((int)gps.utc_time/10000) + TIMEZONE;
            if(gpsHour < 0)
                gpsHour += 24;
            
            int gpsMin = (int)((int)gps.utc_time/100%100);
            int gpsSec = (int)gps.utc_time % 100;
      
            pc.printf("lock=%d %2d:%02d:%02d  %f %c %f %c\r\n", gps.lock, gpsHour,gpsMin,gpsSec,gps.nmea_longitude, gps.ns, gps.nmea_latitude, gps.ew);
            wait(.9);
        }
        else{
            pc.printf("No Lock\r\n");
            wait(1);    
        }        
    }//while(1)
}//main

Files at this revision

API Documentation at this revision

Comitter:
jebradshaw
Date:
Wed Nov 05 16:43:55 2014 +0000
Parent:
0:f3a7d716faea
Commit message:
Uses serial receive interrupt to extract, checksum validate, and parse gps nmea messages at 4800 baud

Changed in this revision

GPSINT.cpp Show annotated file Show diff for this revision Revisions of this file
GPSINT.h Show annotated file Show diff for this revision Revisions of this file
--- a/GPSINT.cpp	Sat Nov 01 13:27:11 2014 +0000
+++ b/GPSINT.cpp	Wed Nov 05 16:43:55 2014 +0000
@@ -1,5 +1,7 @@
 /* GPSINT.cpp
- * Copyright (c) 2014, jbradshaw (20141101)
+ * jbradshaw (20141101)
+ * GPS functions are work of Tyler Weavers mbed gps library page 
+ * (http://mbed.org/users/tylerjw/code/GPS/file/39d75e44b214/GPS.cpp)
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
--- a/GPSINT.h	Sat Nov 01 13:27:11 2014 +0000
+++ b/GPSINT.h	Wed Nov 05 16:43:55 2014 +0000
@@ -1,5 +1,7 @@
-/* GPSINT.h
- * Copyright (c) 2014, jbradshaw (20141101)
+/* GPSINT.cpp
+ * jbradshaw (20141101)
+ * GPS functions are work of Tyler Weavers mbed gps library page 
+ * (http://mbed.org/users/tylerjw/code/GPS/file/39d75e44b214/GPS.cpp)
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -46,10 +48,10 @@
      * @param gps - Serial port pins attached to the gps
      */ 
     GPSINT(PinName tx, PinName rx);
-    int nmea_validate(char *nmeastr);
-    void parseGPSString(char *GPSstrParse);
-    void GPSSerialRecvInterrupt(void);
-    float nmea_to_dec(float deg_coord, char nsew);
+    int nmea_validate(char *nmeastr);               //runs the checksum calculation on the GPS NMEA string
+    void parseGPSString(char *GPSstrParse);         //uses scanf to parse NMEA string into variables
+    void GPSSerialRecvInterrupt(void);              //fills temprpary buffer for processing
+    float nmea_to_dec(float deg_coord, char nsew);  //convert nmea format to decimal format
     float calc_course_to(float pointLat, float pontLong);
     double calc_dist_to_mi(float pointLat, float pontLong);
     double calc_dist_to_ft(float pointLat, float pontLong);