library for parsing GPS NMEA strings using serial receive interrupt

Fork of GPSINT by Joseph Bradshaw

You are viewing an older revision! See the latest version

Homepage

Table of Contents

  1. GPSINT library

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

All wikipages