8 years, 5 months ago.

Interrupt driven Serial GPS

Hi guys,

I wrote some lightweight code to interpret a U-blox Neo 6M GPS. I made the GPS serial interrupt driven so it doesn't take up time in the main code.

I'm running into problem debugging this GPS library with the pc serial or a bluetooth serial. I've added other libraries to the main code but I've stripped them all out right now, only the main.c, GPS.cpp and GPS.h file remains.

Here's the code:

/media/uploads/AlpNov/main.cpp

/media/uploads/AlpNov/gps.h

/media/uploads/AlpNov/gps.cpp

The trouble is that in the serial interrupt routine, I cannot get anything to run without the pc.putc('a') line. When I run it without that line, the first printf in main.cpp (swim GPS) will not even display. Resetting the mbed doesn't seem to load or run the program, since the main blue light doesn't flash as many times or at all. It doesn't have to be putc, just any function that send something to the serial is fine, which means it also doesn't have to be the letter a. Where that line is I used to have a pc.printf("%s",GPSbuffer) to print out the full sentence. Not the best idea putting a long printf in the interrupt, but I was doing some quick debugging. It worked but I didn't let it stay there long afterward. The parse function was supposed to replace it.

If I tried to switch to the BT serial, it's the same thing. I cannot print anything out to the bluetooth without a BT.putc('a') line.

I also cannot just print out to the pc serial in the interrupt and then print the rest of the NMEA log to the bluetooth, or vice versa.

Basically, there are three times printf/putc is invoked in the program:

main.cpp:13 to print the first hello world/swim GPS

GPS.cpp:8 shouldn't be there, but the rest of the printf doesn't work without it, even the one at main.cpp:13

GPS.cpp:30 in the parse function, where eventually I would replace it with just a sscanf for the buffer

I've actually finished the library before, about a month ago. I moved on to work on some other peripherals, like the magnetometer and an LED ring, for the same device. When I came back the GPS library I wrote was basically broken.

Tomorrow I will inspect the wiring for the device, abmaybe something is sorted. I will also start a new program from scratch and try to write the whole thing from scratch, to a certain extent.

I'm entertaining the idea that through some transport problem when I carry the circuit in my backpack the mbed broke somehow. Or maybe something got zapped in the mbed, and I might need a new one. But I just don't understand how hardware problems can manifest like this.

Sorry for the long post, any opinions or advice will help greatly.

Thanks.

Be the first to answer this question.