I am connecting the LS20031 GPS to an Orangutan328. I have tried some basic serial code to see if i am getting the ‘$’ arriving which suggests the GPS is transmitting to the controller OK.
I am now trying to get some smarter, full GPS reading code going. There is not much to choose from. TinyGPS doesn’t look right for me (I am a c, not c++ experienced person - and then only just! So it looked daunting).
I have been trying the WebBotLib which seems to have a pretty good NMEA GPS system, but I am having trouble getting that to run.
So I guess two directions here:
-
Use a more appropriate GPS library - any suggestions and hopefully example code?
-
(I think) I am very close to getting the WebBotLib going. I have had trouble with an apparent double definition of delay_ms but got around that, now I am just having trouble with the definition of the UART I think. When I define HW_UART it needs to get pointed to the UART, but I am not sure where to get that.
My code looks like:
#include <stdio.h>
// #include "uart.h"
// Following line to avoid double definition of delay_ms etc.
#define OrangutanTime_h
#include <pololu/orangutan.h>
#include "Sensors/GPS/gps.h"
#include "Sensors/GPS/NMEA/gpsNMEA.h"
#include "sys/atmega328P.h"
double longitude;
double latitude;
int main()
{
HW_UART* theUart = &UART; <-- problem line!!!!
GPS_NMEA myGPS = MAKE_GPS_NMEA(&theUart,57600);
// serial_set_baud_rate(57600);
// uartSetBaudRate(UART0, (BAUD_RATE)57600);
print("Hello");
delay_ms(1000);
while(1);
{
if( gpsNMEAprocess(&myGPS) ){
// We have received something
if(myGPS.info.valid){
// And we have a satellite fix
if( myGPS.info.changes.values.longitude &&
myGPS.info.changes.values.latitude){
// Longitude and latitude have been updated - so fetch the values
// NB It doesn't mean that the values have changed
longitude = myGPS.info.longitude;
latitude = myGPS.info.latitude;
// as a test - lets show the number of satellites we have on the LCD
clear();
print_long(myGPS.info.numSatellites);
print(" satellites");
}
}
}
}
}
produces this error:
Build started 23.4.2011 at 22:00:50
avr-gcc -I"C:\Users\Barry\Documents\Barry\Orangutan\Projects\GPS…\Lib" -I"C:\Users\Barry\Documents\Barry\Orangutan\Projects\GPS…\Lib\WebBotLib" -mmcu=atmega328p -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -f
short-enums -MD -MP -MT GPS.o -MF dep/GPS.o.d -c …/GPS.c
…/GPS.c: In function ‘main’:
…/GPS.c:20: error: expected expression before ‘UART’
…/GPS.c:21: error: request for member ‘uart’ in something not a structure or union
make: *** [GPS.o] Error 1
Build failed with 2 errors and 0 warnings…
on the line: HW_UART* theUart = &UART;
I got this line of code from the WebBotLib manual page 142 with the sample code - defining a number of UARTS:
int i;
for(i=0;i<NUM_UARTS;i++){
HW_UART* theUart = &Uarts[i];
// You can now pass in ‘theUart’ as the reference
}
I have tried all different configurations with no luck. I think I need a real pointer to the UART … not the definition UART I am using
Any suggestions down either path??
Thanks in advance.
barry.