[Top][All Lists]

[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 (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":


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[] = "";
   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");
                   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);


Kumar Vijay Mishra

reply via email to

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