I use a GPS dongle (Bluenext - BN903S) connected to the USB port of a TP-Link TL-WR703N running OpenWRT (Attitude Adjustment 12.09) and GPSD (3.7) along with my C program to receive and display coordinates.
When I go out to test it, clear sky and all, the GPS dongle's LED flashes, which indicates it has a fix, and while running my application, the coordinates displayed every 5-7 seconds or so seem to be constantly changing. However, as you can see in the screenshot below, even though I move around the area (displayed in red line in the image), the program logged that I was in the spots where there are markers. So the coordinates change, but they are wrong and all concentrated in one small area...
GPS coords image: http://i40.tinypic.com/2ex5x7d.jpg
This is the source code I had last. Nothing complex as far as the source-code goes, that's why I am wondering that it might not even be the source code's fault. I have tried so many "techniques" to receive them but all have similar result.
Can anyone help out what might the problem be here?
Help is much appreciated.
if(gps_open("127.0.0.1", "2947", &gpsdata)<0) {
printf("GPS open failed with error: %d\n", gps_open("127.0.0.1", "2947", &gpsdata));
exit(EXIT_FAILURE);
}
else
{
printf("GPS open OK\n");
if(gps_stream(&gpsdata, WATCH_ENABLE, NULL) != 0)
{
printf("Data stream failed\n");
}
else
{
printf("GPS stream OK\n");
}
}
AGAIN:while(1)
{
double lat, longi;
if(gps_waiting(&gpsdata, 2000)) {
printf("there is data waiting\n");
if(gps_read(&gpsdata) == -1)
{
printf("gps_read error\n");
}
else if(gpsdata.status > 0) {
printf("Using %d satellites of %d visible\n", gpsdata.satellites_used, gpsdata.satellites_visible);
lat = gpsdata.fix.latitude;
longi = gpsdata.fix.longitude;
if((isnan(lat) != 0) && (isnan(longi) != 0)) {
curTime = time(NULL); printf("Time %s : GPS fix is NaN %f, %f\n", ctime(&curTime), lat, longi);
}
else
{
printf("MY Latitude %f and Longitude %f\n", lat, longi);
}
}
} sleep(5);
}