diff options
-rw-r--r-- | gpsd.h-tail | 1 | ||||
-rw-r--r-- | gpsdecode.c | 2 | ||||
-rw-r--r-- | libgpsd_core.c | 47 |
3 files changed, 28 insertions, 22 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail index a443a0b7..b870977d 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -645,6 +645,7 @@ extern unsigned char hc(unsigned char); extern void gpsd_init(struct gps_device_t *, struct gps_context_t *, /*@null@*/char *); +extern void gpsd_clear(struct gps_device_t *); extern int gpsd_activate(struct gps_device_t *); extern void gpsd_deactivate(struct gps_device_t *); extern gps_mask_t gpsd_poll(struct gps_device_t *); diff --git a/gpsdecode.c b/gpsdecode.c index 70d6cde8..cadc8202 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -360,7 +360,7 @@ static void aivdm_csv_dump(struct ais_t *ais, char *buf, size_t buflen) /*@ -compdestroy -compdef -usedef @*/ static void decode(FILE * fpin, FILE * fpout) -/* RTCM or AIS packets on fpin to dump format on fpout */ +/* sensor data on fpin to dump format on fpout */ { struct gps_packet_t lexer; #ifdef RTCM104V2_ENABLE diff --git a/libgpsd_core.c b/libgpsd_core.c index 3264883d..d17075e1 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -667,6 +667,31 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) /*@+mustfreefresh +type +unrecog@*/ #endif /* PPS_ENABLE */ +void gpsd_clear(struct gps_device_t *session) +{ + session->gpsdata.online = timestamp(); +#ifdef SIRF_ENABLE + session->driver.sirf.satcounter = 0; +#endif /* SIRF_ENABLE */ + packet_init(&session->packet); + gpsd_report(LOG_INF, + "gpsd_activate(): opened GPS (fd %d)\n", + session->gpsdata.gps_fd); + // session->gpsdata.online = 0; + session->gpsdata.fix.mode = MODE_NOT_SEEN; + session->gpsdata.status = STATUS_NO_FIX; + session->gpsdata.fix.track = NAN; + session->gpsdata.separation = NAN; + session->mag_var = NAN; + session->releasetime = 0; + session->getcount = 0; + + /* clear the private data union */ + memset(&session->driver, '\0', sizeof(session->driver)); + + session->opentime = timestamp(); +} + /*@ -branchstate @*/ int gpsd_activate(struct gps_device_t *session) /* acquire a connection to the GPS device */ @@ -750,25 +775,7 @@ int gpsd_activate(struct gps_device_t *session) gpsd_report(LOG_PROG, "no probe matched...\n"); foundit: #endif /* NON_NMEA_ENABLE */ - session->gpsdata.online = timestamp(); -#ifdef SIRF_ENABLE - session->driver.sirf.satcounter = 0; -#endif /* SIRF_ENABLE */ - packet_init(&session->packet); - gpsd_report(LOG_INF, - "gpsd_activate(): opened GPS (fd %d)\n", - session->gpsdata.gps_fd); - // session->gpsdata.online = 0; - session->gpsdata.fix.mode = MODE_NOT_SEEN; - session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.fix.track = NAN; - session->gpsdata.separation = NAN; - session->mag_var = NAN; - session->releasetime = 0; - session->getcount = 0; - - /* clear the private data union */ - memset(&session->driver, '\0', sizeof(session->driver)); + gpsd_clear(session); /* * We might know the device's type, but we shoudn't assume it has * retained its settings. A revert hook might well have undone @@ -779,8 +786,6 @@ int gpsd_activate(struct gps_device_t *session) && session->device_type->event_hook != NULL) session->device_type->event_hook(session, event_reactivate); } - - session->opentime = timestamp(); return session->gpsdata.gps_fd; } |