gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-users] [gpsd newbie] Latitude/longitude/altitude are not reported


From: Kumar Vijay Mishra
Subject: [gpsd-users] [gpsd newbie] Latitude/longitude/altitude are not reported in gps_data_t structure
Date: Tue, 20 Dec 2011 17:47:11 -0700
User-agent: Thunderbird 2.0.0.24 (X11/20111109)

Hello All,

I am new to gpsd, so it is possible that my query may sound very basic to other users. I am trying to acquire latitude, longitude and altitude via a GPS device plugged into the serial port of my computer. The output of the command 'gpspipe -r' gives out the location data correctly and I can see that mode is set to "3":

{"class":"TPV","tag":"GGA","device":"/dev/ttyS0","time":1324427430.002,"ept":0.005,"lat":60.446417250,"lon":-50.637503467,"alt":1425.818,"track":14.1200,"speed":0.003,"mode":3}
$GPRMC,003031.026,A,4026.785177,N,10438.250224,W,0.007,6.26,211211,,,A*4A
$GPGGA,003031.026,4026.785177,N,10438.250224,W,1,11,0.74,1425.878,M,-21.535,M,,*66

However when I use the following code (that I wrote following the guidelines in the documentation) in C, I get NaN as latitude, longitude and altitude. Also, both gpsdata->fix.mode and gpsdata->fix.status are reported as 0. Am I missing anything here?

   char gpsserver[] = "127.0.0.1";
   char gpsport[]   = "2947";
   struct gps_data_t *gpsdata;

   gpsdata = gps_open(gpsserver, gpsport);
   (void) gps_stream(gpsdata, WATCH_ENABLE | WATCH_JSON, NULL);
       if (gps_waiting (gpsdata))
       {
           errno = 0;
           if (gps_poll (gpsdata) == -1)
           {
                   printf("gpsd has a problem\n");
           }
           else
           {
                   if(gpsdata->fix.mode == MODE_3D)
                   {
                       printf("Latitude: %d\n", gpsdata->fix.latitude);
                       printf("Longtitude: %f\n", gpsdata->fix.longitude);
                       printf("Altitude: %f\n", gpsdata->fix.altitude);
                   }
           }
       }
   (void) gps_stream(gpsdata, WATCH_DISABLE, NULL);
   gps_close(gpsdata);

--
Regards,

Kumar Vijay Mishra





reply via email to

[Prev in Thread] Current Thread [Next in Thread]