Electronic – using mbed with gps

gpsmbedprogramming

I am trying to program an mbed micro controller to work with a GlobalSat EM 406 GPS receiver and have got it outputting long and lat to a host computer using the information on:
https://mbed.org/cookbook/GlobalSat-EM-406-GPS-Module

However I am having trouble getting the mbed to write the data to a text file. When I add the code from: http://mbed.org/handbook/LocalFileSystem it seemingly breaks the code that receives the gps data, as it no longer loops the lat and long to the screen, and instead outputs one instance of zeros, then does nothing else.

Has anyone had any experience with this?

Thanks

The code that works for printing to the screen is:

#include "mbed.h"
#include "GPS.h"

Serial pc(USBTX, USBRX);
GPS gps(p9, p10);

int main() {

while(true) 
{

   if(gps.sample()) 
    {
        pc.printf("%f, %f\r", gps.longitude, gps.latitude);
    } 

    else 
    {
        pc.printf("Oh Dear! No lock :(\n");
    }

}
}

And it breaks when I add:

#include "mbed.h"
#include "GPS.h"

Serial pc(USBTX, USBRX);
GPS gps(p9, p10);
LocalFileSystem local("local"); 

int main() {

while(true) 
{

   if(gps.sample()) 
    {
        pc.printf("%f, %f\r", gps.longitude, gps.latitude);
        FILE *fp = fopen("/local/out.txt", "w"); 
        fprintf(fp, "%f \n", gps.longitude);
        fprintf(fp, "%f \n", gps.latitude);
        fclose(fp);
    } 

    else 
    {
        pc.printf("Oh Dear! No lock :(\n");
    }

}
}

Best Answer

if you read the class documentation you'll see it only works with specific boards https://developer.mbed.org/handbook/LocalFileSystem

Warning

As the FRDM-KL25Z does not have external flash to store files, the LocalFileSystem is not available for this board. It works at the NXP LPC1768 and LPC11U24 only.

Related Topic