Demo module gps par scrutation
Ce programme permet d'afficher les données GPS reçues par gpsd.
Le programme scrute si des données GPS sont disponibles avant de les afficher.
Voilà ce que ça donne :
Press Ctrl+C to abort ...
Fix,Date/Time,Latitude,Longitude
ON,Sat Mar 11 16:29:44 2017,43.1615,5.93072
ON,Sat Mar 11 16:29:45 2017,43.1615,5.93071
ON,Sat Mar 11 16:29:46 2017,43.1616,5.9307
ON,Sat Mar 11 16:29:47 2017,43.1616,5.9307
ON,Sat Mar 11 16:29:48 2017,43.1616,5.9307
ON,Sat Mar 11 16:29:48 2017,43.1616,5.9307
ON,Sat Mar 11 16:29:49 2017,43.1616,5.93071
ON,Sat Mar 11 16:29:50 2017,43.1616,5.93072
ON,Sat Mar 11 16:29:51 2017,43.1616,5.93072
ON,Sat Mar 11 16:29:52 2017,43.1616,5.93071
ON,Sat Mar 11 16:29:53 2017,43.1616,5.9307
^C
Gps closed.
Have a nice day !
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <sysio/gps.h>
void vSigIntHandler (int sig);
static struct xGps * gps;
int main (void) {
gps =
xGpsNew (
"localhost", DEFAULT_GPSD_PORT);
signal (SIGINT, vSigIntHandler);
printf ("Press Ctrl+C to abort ...\n");
printf("\nFix,Date/Time,Latitude,Longitude\n");
timestamp_t t;
double latitude, longitude;
bool fix;
}
}
vSigIntHandler (SIGQUIT);
return 0;
}
void
vSigIntHandler (int sig) {
printf ("\nGps closed.\nHave a nice day !\n");
exit (EXIT_SUCCESS);
}