Problems with reading GPS

16 Mar 2011

I am trying to read GPS data from a UsGlobalSat BU-353 with NMEA format output using the following code and the GPS library.

  1. include "mbed.h"
  2. include "GPS.h"

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

int main() { while(1) { if(gps.sample()) { pc.printf("The time is %i, and I'm at %f, %f\n", gps.time, gps.longitude, gps.latitude); } else { pc.printf("Oh Dear! No lock :(\n"); } } }

When I run the program, it calls the gps.sample() function, which in turn calls the gps.getline() function. However, when it gets to wait for the start of a line, the program stops. I checked what GPS data was coming in using gps.getc(), but it didn't show any data coming in. I know that there is data coming into the correct pin because I wrote a program to light an LED when there was data on that pin. Does anyone know why there doesn't appear to be any data coming in from the GPS?

16 Mar 2011

The BU-353 has a USB interface. Are you using an outboard USB-to-serial adapter before connecting it to the serial port at pins 9 and 10?

16 Mar 2011

Could be wrong baudrate or maybe rx pin is connected to 1 pulse/sec output from GPS and it only seemed that data was coming in. Have you checked GPS output with an oscilloscope to see if it is serial datastream? Perhaps data from GPS is not NMEA but some proprietary format and GPS needs to be reconfigured first.

16 Mar 2011

Assuming you are using a serial port to connect to the GPS device (following from Hexley's observation) you might like to try using MODGPS library:-

MODGPS Cookbook page

Import libraryMODGPS

Allows for a GPS module to be connected to a serial port and exposes an easy to use API to get the GPS data. New feature, added Mbed/LPC17xx RTC synchronisation

17 Mar 2011

No, I did not use a USB-to-serial adapter. I wanted to use the USB pins (D+ and D-), but I couldn't find anything about how to read or write to these pins. I will try to use the MODGPS library to make it work. Would the MSCFileSystem library maybe help?

17 Mar 2011

MODSERIAL requires a serial port and doesn't support USB.

21 Mar 2011

Is there any way to convert the USB data into serial data in the software, without a USB-to-serial adapter?

21 Mar 2011

Bradley Pomerleau wrote:

Is there any way to convert the USB data into serial data in the software, without a USB-to-serial adapter?

use usb host and figure out how to read the endpoint

16 May 2015

I am trying to do this exact same thing, I found this project http://mbed.org/users/va009039/code/GPSUSBHost/ which gets most of the way there but the output is all scrambled. Did you have any luck with it?