diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-09-29 03:49:36 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-09-29 03:49:36 +0000 |
commit | 3d35659c4c9c85f363a165eedb6ffefb256477a2 (patch) | |
tree | 679b14ad50da57f8d7f61002dc8b59d1144ec7a4 | |
parent | b5f3674f36a32c38caa569fb3afc90d02c54fb90 (diff) | |
download | gpsd-3d35659c4c9c85f363a165eedb6ffefb256477a2.tar.gz |
Rip out most of the old profiling support.
Replace it with a new, lighter- weight version that can be configured
out.
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | driver_nmea.c | 1 | ||||
-rw-r--r-- | driver_zodiac.c | 1 | ||||
-rw-r--r-- | gps.h | 30 | ||||
-rwxr-xr-x | gps.py | 16 | ||||
-rw-r--r-- | gpsd.c | 49 | ||||
-rw-r--r-- | gpsd.h-tail | 9 | ||||
-rwxr-xr-x | gpsprof | 5 | ||||
-rw-r--r-- | libgpsd_core.c | 16 |
9 files changed, 72 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac index 5f07a063..413db375 100644 --- a/configure.ac +++ b/configure.ac @@ -675,6 +675,19 @@ else AC_MSG_RESULT([no]) fi +dnl check for latency timing support +AC_ARG_ENABLE(timing, + AC_HELP_STRING([--disable-timing], + [disable latency timing support]), + [ac_timing=$enableval], [ac_timing=yes]) +AC_MSG_CHECKING([for latency timing support]) +if test x"$ac_timing" = "xyes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE([TIMING_ENABLE], 1, [latency timing support)]) +else + AC_MSG_RESULT([no]) +fi + dnl check for support for oldstyle protocol AC_ARG_ENABLE(oldstyle, AC_HELP_STRING([--disable-oldstyle], @@ -991,6 +1004,7 @@ echo "OceanServer : $ac_oceanserver" echo "UBX : $ac_ubx" echo "GPSclock : $ac_gpsclock" echo "AIVDM support : $ac_aivdm" +echo "Timing support : $ac_timing" echo "MKT-3301 : $ac_mkt3301" dnl Below this line are non-protocol switches echo " Daemon Features" diff --git a/driver_nmea.c b/driver_nmea.c index 216df5ae..27e6cbf3 100644 --- a/driver_nmea.c +++ b/driver_nmea.c @@ -900,7 +900,6 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t *session) if (nmea_phrase[i].decoder!=NULL && (count >= nmea_phrase[i].nf)) { retval = (nmea_phrase[i].decoder)(count, session->driver.nmea.field, session); strncpy(session->gpsdata.tag, nmea_phrase[i].name, MAXTAGLEN); - session->gpsdata.sentence_length = strlen(sentence); /* * Must force this to be nz, as we're gong to rely on a zero * value to mean "no previous tag" later. diff --git a/driver_zodiac.c b/driver_zodiac.c index 02a72ed3..e833bdc0 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -220,7 +220,6 @@ static gps_mask_t handle1000(struct gps_device_t *session) gpsd_report(LOG_INF, "Separation: %f\n", getzword(33) * 1e-2); #endif - session->gpsdata.sentence_length = 55; session->cycle_state |= CYCLE_START; return TIME_SET|LATLON_SET|ALTITUDE_SET|CLIMB_SET|SPEED_SET|TRACK_SET|STATUS_SET|MODE_SET; /* |HERR_SET|VERR_SET|SPEEDERR_SET */ } @@ -944,8 +944,17 @@ struct gps_data_t { struct devconfig_t dev; /* device that shipped last update */ - /* pack things that are never reported together to reduce structure size */ + char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ + double sentence_time; /* sentence timestamp (not the fix time!) */ + + /* hook functions */ + int gps_fd; /* socket or file descriptor to GPS */ + void (*raw_hook)(struct gps_data_t *, char *, size_t len); /* Raw-mode hook for GPS data. */ + void (*thread_hook)(struct gps_data_t *, char *, size_t len);/* Thread-callback hook for GPS data. */ + + /* Private data - mmay be changed or removed */ union { + /* pack things never reported together to reduce structure size */ /* unusual forms of sensor data that might come up the pipe */ struct rtcm2_t rtcm2; struct rtcm3_t rtcm3; @@ -963,25 +972,6 @@ struct gps_data_t { char error[80]; }; - /* profiling data for last sentence */ - char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ - size_t sentence_length; /* character count of last sentence */ - double sentence_time; /* sentence timestamp */ - double d_read_time; /* Time of first sentence read that got data */ - double d_xmit_time; /* beginning of sentence transmission */ - double d_recv_time; /* daemon receipt time (-> E1+T1) */ - double d_decode_time; /* daemon end-of-decode time (-> D1) */ - double poll_time; /* daemon poll time (-> W) */ - double emit_time; /* emission time (-> E2) */ - double c_recv_time; /* client receipt time (-> T2) */ - double c_decode_time; /* client end-of-decode time (-> D2) */ - - /* hook functions */ - int gps_fd; /* socket or file descriptor to GPS */ - void (*raw_hook)(struct gps_data_t *, char *, size_t len); /* Raw-mode hook for GPS data. */ - void (*thread_hook)(struct gps_data_t *, char *, size_t len);/* Thread-callback hook for GPS data. */ - - /* Private data - mmay be changed or removed */ bool newstyle; /* have we seen a JSON response */ }; @@ -420,12 +420,8 @@ class gps(gpsdata): self.satellites_used += 1 self.valid = ONLINE_SET | SATELLITE_SET elif self.data.get("class") == "TIMING": - if self.data["timebase"] != 0: - basetime = self.data["timebase"] - else: - basetime = self.data["xmit"] - self.data["c_recv"] = self.received - basetime - self.data["c_decode"] = time.time() - basetime + self.data["c_recv"] = self.received + self.data["c_decode"] = time.time() self.timings = self.data def waiting(self): @@ -476,12 +472,8 @@ class gps(gpsdata): if self.subtype: self.gps_id += self.subtype elif self.data["class"] == "TIMING": - if payload.timebase != 0: - basetime = payload.timebase - else: - basetime = payload.xmit - payload.c_recv = self.received - basetime - payload.c_decode = time.time() - basetime + payload.c_recv = self.received + payload.c_decode = time.time() return payload def send(self, commands): @@ -2140,31 +2140,6 @@ int main(int argc, char *argv[]) if (channel->subscriber == NULL || channel->device == NULL || channel->device != device) continue; - if (channel->subscriber->policy.timing) { - char phrase[GPS_JSON_RESPONSE_MAX]; - if (channel->device->gpsdata.sentence_time!=0) - (void)snprintf(phrase, sizeof(phrase), "{\"class\":\"TIMING\",\"device\":\"%s\",\"tag\":%s,\"len\":%d,\"timebase\":%lf,\"xmit\":%lf,\"recv\":%lf,\"decode\":%lf,\"elapsed\":%lf}\r\n", - channel->device->gpsdata.dev.path, - channel->device->gpsdata.tag, - (int)channel->device->gpsdata.sentence_length, - channel->device->gpsdata.sentence_time, - channel->device->gpsdata.d_xmit_time - channel->device->gpsdata.sentence_time, - channel->device->gpsdata.d_recv_time - channel->device->gpsdata.sentence_time, - channel->device->gpsdata.d_decode_time - channel->device->gpsdata.sentence_time, - timestamp() - channel->device->gpsdata.sentence_time); - else - (void)snprintf(phrase, sizeof(phrase), "{\"class\":\"TIMING\",\"device\":\"%s\",\"tag\":%s,\"len\":%d,\"timebase\":0,\"xmit\":%lf,\"recv\":%lf,\"decode\":%lf,\"elapsed\":%lf}\r\n", - channel->device->gpsdata.dev.path, - channel->device->gpsdata.tag, - (int)channel->device->gpsdata.sentence_length, - channel->device->gpsdata.d_xmit_time, - channel->device->gpsdata.d_recv_time - channel->device->gpsdata.d_xmit_time, - channel->device->gpsdata.d_decode_time - channel->device->gpsdata.d_xmit_time, - timestamp() - channel->device->gpsdata.d_xmit_time); - (void)throttled_write(channel->subscriber, - phrase, strlen(phrase)); - } - /* * NMEA and other textual sentences are simply * copied to all clients that are in raw or nmea @@ -2356,7 +2331,8 @@ int main(int argc, char *argv[]) #endif /* AIVDM_ENABLE */ } #endif /* OLDSTYLE_ENABLE */ - if (newstyle(sub)) { + if (newstyle(sub)) { + buf2[0] = '\0'; if (report_fix) { json_tpv_dump(&device->gpsdata, &channel->fixbuffer, buf2, sizeof(buf2)); @@ -2379,8 +2355,27 @@ int main(int argc, char *argv[]) false, buf2, sizeof(buf2)); (void)throttled_write(sub, buf2, strlen(buf2)); } - } #endif /* AIVDM_ENABLE */ + +#ifdef TIMING_ENABLE + if (buf2[0] != '\0' && sub->policy.timing) { + (void)snprintf(buf2, sizeof(buf2), + "{\"class\":\"TIMING\"," + "\"tag\":%s,\"len\":%d," + "\"xmit\":%lf,\"recv\":%lf," + "\"decode\":%lf," + "\"emit\":%lf}\r\n", + device->gpsdata.tag, + (int)device->packet.outbuflen, + device->d_xmit_time, + device->d_recv_time, + device->d_decode_time, + timestamp()); + (void)throttled_write(channel->subscriber, + buf2, strlen(buf2)); + } +#endif /* TIMING_ENABLE */ + } } } /*@-nullderef@*/ diff --git a/gpsd.h-tail b/gpsd.h-tail index 887cdf03..f9ef2abf 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -396,6 +396,15 @@ struct gps_device_t { #ifdef AIVDM_ENABLE struct aivdm_context_t aivdm; #endif /* AIVDM_ENABLE */ + +#ifdef TIMING_ENABLE + /* profiling data for last sentence */ + char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ + double d_xmit_time; /* beginning of sentence transmission */ + double d_recv_time; /* daemon receipt time (-> E1+T1) */ + double d_decode_time; /* daemon end-of-decode time (-> D1) */ + double emit_time; /* emission time (-> E2) */ +#endif /* TIMING_ENABLE */ }; /* logging levels */ @@ -382,7 +382,6 @@ formatters = (spaceplot, uninstrumented, rawplot, splitplot, cycle) def plotframe(await, fname, speed, threshold, title): "Return a string containing a GNUplot script " - # FIXME: Has dependency on old protocol if fname: for formatter in formatters: if formatter.name == fname: @@ -435,6 +434,10 @@ def plotframe(await, fname, speed, threshold, title): sys.stderr.write("gpsprof: gpsd has vanished.\n") sys.exit(1) baton.twirl() + if session.data["class"] == "WATCH": + if "timing" in options and not session.data.get("timing"): + sys.stderr.write("gpsprof: timing is not enabled.\n") + sys.exit(1) # We can get some funky artifacts at start of session # apparently due to RS232 buffering effects. Ignore # them. diff --git a/libgpsd_core.c b/libgpsd_core.c index ef6c0bf5..023e2881 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -457,13 +457,14 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) gps_clear_fix(&session->gpsdata.fix); +#ifdef TIMING_ENABLE if (session->packet.outbuflen == 0) - session->gpsdata.d_read_time = timestamp(); + session->d_xmit_time = timestamp(); +#endif /* TIMING_ENABLE */ /* can we get a full packet from the device? */ if (session->device_type) { newlen = session->device_type->get_packet(session); - session->gpsdata.d_xmit_time = timestamp(); gpsd_report(LOG_RAW, "%s is known to be %s\n", session->gpsdata.dev.path, @@ -472,7 +473,6 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) const struct gps_type_t **dp; newlen = generic_get(session); - session->gpsdata.d_xmit_time = timestamp(); gpsd_report(LOG_RAW, "packet sniff on %s finds type %d\n", session->gpsdata.dev.path, @@ -519,9 +519,9 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) gpsd_report(LOG_RAW+3, "Accepted packet on %s.\n", session->gpsdata.dev.path); - /* collect profiling data */ - session->gpsdata.sentence_length = session->packet.outbuflen; - session->gpsdata.d_recv_time = timestamp(); +#ifdef TIMING_ENABLE + session->d_recv_time = timestamp(); +#endif /* TIMING_ENABLE */ /* track the packet count since achieving sync on the device */ if (first_sync) @@ -574,7 +574,9 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) if ((session->gpsdata.set & LATLON_SET )!=0 && session->gpsdata.status > STATUS_NO_FIX) session->context->fixcnt++; - session->gpsdata.d_decode_time = timestamp(); +#ifdef TIMING_ENABLE + session->d_decode_time = timestamp(); +#endif /* TIMING_ENABLE */ return session->gpsdata.set; } |