gpsd-users
[Top][All Lists]
Advanced

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

[gpsd-users] Help requested...


From: David J Taylor
Subject: [gpsd-users] Help requested...
Date: Thu, 8 Mar 2018 19:59:16 -0000

Folks,

I had a very short program which used to work, but needs updating for gpsd
3.15.  I can see that there have been changes, but my C simply isn't good
enough to update the program.  It seems the structures have changed in a way
I can't quite understand.  Any guidance would be very much appreciated!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <gps.h>
#include <stdio.h>

int main (int argc, char **argv) {
 int status, used, visible;
 struct gps_data_t gpsdata;
 #define OID_VISIBLE ".1.3.6.1.2.1.25.1.31"
 #define OID_USED ".1.3.6.1.2.1.25.1.32"
 #define OID_SNR_AVG ".1.3.6.1.2.1.25.1.33"

 if ((argc > 2) && (strcmp ("-g", argv[1]) == 0))
 {
   status = gps_open (GPSD_SHARED_MEMORY, DEFAULT_GPSD_PORT, &gpsdata);
   status = gps_read (&gpsdata);
   used  = gpsdata.satellites_used;
   visible = gpsdata.satellites_visible;
   int i; double snr_total=0;
   for(i=0;i<=used;i++) {
       if (gpsdata.used[i] > 0 && gpsdata.ss[i] > 1) {
//            printf ("i: %d, P:%d, ss: %f\n", i, gpsdata.PRN[i],
gpsdata.ss[i]);
           snr_total+=gpsdata.ss[i];
       }
   }
   gps_close (&gpsdata);
   double snr_avg = 0.0;
   if (used > 0) {
       snr_avg = snr_total / used;
   }
   if (strcmp (OID_VISIBLE, argv[2]) == 0) {
     printf (OID_VISIBLE);
     printf ("\n");
     printf ("gauge\n");
     printf ("%d\n", visible);
   }
   if (strcmp (OID_USED, argv[2]) == 0) {
     printf (OID_USED);
     printf ("\n");
     printf ("gauge\n");
     printf ("%d\n", used);
   }
   if (strcmp (OID_SNR_AVG, argv[2]) == 0) {
     printf (OID_SNR_AVG);
     printf ("\n");
     printf ("gauge\n");
     printf ("%lf\n", snr_avg);
   }
 }
 return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Many thanks,
David
--
SatSignal Software - Quality software written to your requirements
Web: http://www.satsignal.eu
Email: address@hidden
Twitter: @gm8arv



reply via email to

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