1
\$\begingroup\$

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");
    }

}
}
\$\endgroup\$
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

I have now partially fixed this issue. Instead of writing to the internal storage which was problematic, I am now writing to a usb stick using the library from here:

http://mbed.org/users/igorsk/notebook/interfacing-usb-mass-storage-devices-aka-usb-flash/

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.