I'm not sure if its gpsd that's causing my problems, but here's what I tried when I was checking on this.
I pretty much extracted the gps related code from obdgpslogger and came up with this:
note: I don't usually use C, so if there's anything wrong here, let me know.
Code:
#include <stdlib.h>
#include <gps.h>
static struct gps_data_t *gpsdata;
int main(int argc, char * argv[]){
int mustexit = 0;
double lat,lon;
printf("Starting gps client\n");
gpsdata = gps_open("127.0.0.1", "2947");
if(gpsdata == NULL){
printf("Error: Unable to connect\n");
mustexit = 1;
}
else{
printf("Connection established\n");
gps_stream(gpsdata, WATCH_ENABLE, NULL);
}
if(mustexit)
exit(1);
gps_poll(gpsdata);
if(gpsdata->fix.mode < MODE_2D){
printf("location available\n");
lon = gpsdata->fix.longitude;
lat = gpsdata->fix.latitude;
}
printf("lat: %f\n",(float)lat);
printf("lon: %f\n",(float)lon);
gps_close(gpsdata);
return 0;
}
I then tested it out with gpsfake running on a test log I found from the gpsd svn. Approximately 1 out of 20 times, I get to the end of the code(but the numbers are always "nan"). Most of the time though, it'll stop at "connection established", and my cpu utilization would skyrocket because of the client.
I tried to look for a guide on how to use the C library properly, but I couldn't find any.
I tested this out on three systems, all running gentoo, gpsd 2.90, two are 64bit, 1 is 32bit. I'm guessing this is a gpsd problem?
Bookmarks