Compare commits
No commits in common. "master" and "master" have entirely different histories.
|
@ -1,3 +0,0 @@
|
||||||
/gps-watchdog
|
|
||||||
/gpsdate
|
|
||||||
/*.o
|
|
|
@ -55,13 +55,8 @@ static void callback(struct gps_data_t *gpsdata)
|
||||||
{
|
{
|
||||||
/* we received some data but gpsd itself believes the receiver
|
/* we received some data but gpsd itself believes the receiver
|
||||||
* to be offline */
|
* to be offline */
|
||||||
#if GPSD_API_MAJOR_VERSION >= 9 && GPSD_API_MINOR_VERSION >= 0
|
|
||||||
if (gpsdata->online.tv_sec == 0)
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (gpsdata->online == 0)
|
if (gpsdata->online == 0)
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* re-set the alarm to the timeout */
|
/* re-set the alarm to the timeout */
|
||||||
alarm(timeout);
|
alarm(timeout);
|
||||||
|
@ -114,18 +109,6 @@ static int osmo_daemonize(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int compat_gps_read(struct gps_data_t *data)
|
|
||||||
{
|
|
||||||
/* API break in gpsd 6bba8b329fc7687b15863d30471d5af402467802 */
|
|
||||||
#if GPSD_API_MAJOR_VERSION >= 7 && GPSD_API_MINOR_VERSION >= 0
|
|
||||||
return gps_read(data, NULL, 0);
|
|
||||||
#elif GPSD_API_MAJOR_VERSION >= 5
|
|
||||||
return gps_read(data);
|
|
||||||
#else
|
|
||||||
return gps_poll(data);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* local copy, as the libgps official version ignores gps_read() result */
|
/* local copy, as the libgps official version ignores gps_read() result */
|
||||||
static int my_gps_mainloop(struct gps_data_t *gdata,
|
static int my_gps_mainloop(struct gps_data_t *gdata,
|
||||||
int timeout,
|
int timeout,
|
||||||
|
@ -137,7 +120,7 @@ static int my_gps_mainloop(struct gps_data_t *gdata,
|
||||||
if (!gps_waiting(gdata, timeout)) {
|
if (!gps_waiting(gdata, timeout)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
rc = compat_gps_read(gdata);
|
rc = gps_read(gdata);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
(*hook)(gdata);
|
(*hook)(gdata);
|
||||||
|
|
30
gpsdate.c
30
gpsdate.c
|
@ -55,19 +55,13 @@ static void callback(struct gps_data_t *gpsdata)
|
||||||
time_t time;
|
time_t time;
|
||||||
char *timestr, *lf;
|
char *timestr, *lf;
|
||||||
int rc;
|
int rc;
|
||||||
int status;
|
|
||||||
|
|
||||||
if (!(gpsdata->set & TIME_SET))
|
if (!(gpsdata->set & TIME_SET))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if GPSD_API_MAJOR_VERSION >= 9 && GPSD_API_MINOR_VERSION >= 0
|
|
||||||
tv.tv_sec = gpsdata->fix.time.tv_sec;
|
|
||||||
tv.tv_usec = gpsdata->fix.time.tv_nsec / 1000;
|
|
||||||
#else
|
|
||||||
tv.tv_sec = gpsdata->fix.time;
|
tv.tv_sec = gpsdata->fix.time;
|
||||||
/* FIXME: use the fractional part for microseconds */
|
/* FIXME: use the fractional part for microseconds */
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
time = tv.tv_sec;
|
time = tv.tv_sec;
|
||||||
timestr = ctime(&time);
|
timestr = ctime(&time);
|
||||||
|
@ -80,16 +74,10 @@ static void callback(struct gps_data_t *gpsdata)
|
||||||
if (lf)
|
if (lf)
|
||||||
*lf = '\0';
|
*lf = '\0';
|
||||||
|
|
||||||
#if GPSD_API_MAJOR_VERSION >= 10 && GPSD_API_MINOR_VERSION >= 0
|
|
||||||
status = gpsdata->fix.status;
|
|
||||||
#else
|
|
||||||
status = gpsdata->status;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "%s: gpsdate->set=0x%08"PRIu64"x status=%u sats_used=%u\n",
|
syslog(LOG_DEBUG, "%s: gpsdate->set=0x%08"PRIu64"x status=%u sats_used=%u\n",
|
||||||
timestr, gpsdata->set, status, gpsdata->satellites_used);
|
timestr, gpsdata->set, gpsdata->status, gpsdata->satellites_used);
|
||||||
|
|
||||||
if (status == 0) {
|
if (gpsdata->status == 0) {
|
||||||
syslog(LOG_INFO, "%s: discarding; no fix yet\n", timestr);
|
syslog(LOG_INFO, "%s: discarding; no fix yet\n", timestr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -161,18 +149,6 @@ static int osmo_daemonize(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int compat_gps_read(struct gps_data_t *data)
|
|
||||||
{
|
|
||||||
/* API break in gpsd 6bba8b329fc7687b15863d30471d5af402467802 */
|
|
||||||
#if GPSD_API_MAJOR_VERSION >= 7 && GPSD_API_MINOR_VERSION >= 0
|
|
||||||
return gps_read(data, NULL, 0);
|
|
||||||
#elif GPSD_API_MAJOR_VERSION >= 5
|
|
||||||
return gps_read(data);
|
|
||||||
#else
|
|
||||||
return gps_poll(data);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* local copy, as the libgps official version ignores gps_read() result */
|
/* local copy, as the libgps official version ignores gps_read() result */
|
||||||
static int my_gps_mainloop(struct gps_data_t *gdata,
|
static int my_gps_mainloop(struct gps_data_t *gdata,
|
||||||
int timeout,
|
int timeout,
|
||||||
|
@ -184,7 +160,7 @@ static int my_gps_mainloop(struct gps_data_t *gdata,
|
||||||
if (!gps_waiting(gdata, timeout)) {
|
if (!gps_waiting(gdata, timeout)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
rc = compat_gps_read(gdata);
|
rc = gps_read(gdata);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
(*hook)(gdata);
|
(*hook)(gdata);
|
||||||
|
|
Loading…
Reference in New Issue