// skyview dumping gpsd client // compile this way: // gcc skydump.c -o skydump -lgps #include int main(int argc, char *argv[]) { struct gps_data_t gps_data; struct satellite_t sat; gps_mask_t req_bits = MODE_SET | SATELLITE_SET; if (0 != gps_open("localhost", "2947", &gps_data)) { printf("Open error. Bye, bye\n"); return 1; } (void)gps_stream(&gps_data, WATCH_ENABLE | WATCH_JSON, NULL); while (gps_waiting(&gps_data, 5000000)) { if (-1 == gps_read(&gps_data, NULL, 0)) { printf("Read error. Bye, bye\n"); break; } if (req_bits != (req_bits & gps_data.set)) { // did not get valid? skyview, nothing to see here continue; } printf("\nsats: %d / %d\n\n", gps_data.satellites_used, gps_data.satellites_visible); printf("use s# con sig frq hlt sn az el\n"); printf("=== === === === === === === === ===\n"); for (int i=0; i < gps_data.satellites_visible; i++) { sat = gps_data.skyview[i]; printf("%3s %3d %3d %3d %3d %3c %3.0f %3.0f %3.0f\n", sat.used ? "y" : "n", sat.svid, sat.gnssid, sat.sigid, sat.freqid, "?YN"[sat.health], sat.ss, sat.elevation, sat.azimuth ); } } // When you are done... (void)gps_stream(&gps_data, WATCH_DISABLE, NULL); (void)gps_close(&gps_data); return 0; }