diff options
-rw-r--r-- | gpsd.h-tail | 1 | ||||
-rw-r--r-- | gpsdecode.c | 32 | ||||
-rw-r--r-- | gpsdecode.xml | 5 |
3 files changed, 37 insertions, 1 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail index a2fc5a11..6cd760b3 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -173,6 +173,7 @@ struct gps_lexer_t { #define RTCM2_PACKET 16 #define RTCM3_PACKET 17 #define JSON_PACKET 18 +#define PACKET_TYPES 19 /* increment this as necessary */ #define TEXTUAL_PACKET_TYPE(n) ((((n)>=NMEA_PACKET) && ((n)<=MAX_TEXTUAL_TYPE)) || (n)==JSON_PACKET) #define GPS_PACKET_TYPE(n) (((n)>=NMEA_PACKET) && ((n)<=MAX_GPSPACKET_TYPE)) #define LOSSLESS_PACKET_TYPE(n) (((n)>=RTCM2_PACKET) && ((n)<=RTCM3_PACKET)) diff --git a/gpsdecode.c b/gpsdecode.c index f9d6965e..8f7ace12 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -21,6 +21,7 @@ static bool scaled = true; static bool json = true; static bool pseudonmea = false; static bool split24 = false; +static bool minlength = false; static unsigned int ntypes = 0; static unsigned int typelist[32]; static struct gps_context_t context; @@ -534,9 +535,11 @@ static void decode(FILE *fpin, FILE*fpout) { struct gps_device_t session; struct policy_t policy; + unsigned int minima[PACKET_TYPES+1]; #if defined(SOCKET_EXPORT_ENABLE) || defined(AIVDM_ENABLE) char buf[GPS_JSON_RESPONSE_MAX * 4]; #endif + int i; //This looks like a good idea, but it breaks regression tests //(void)strlcpy(session.gpsdata.dev.path, "stdin", sizeof(session.gpsdata.dev.path)); @@ -554,6 +557,8 @@ static void decode(FILE *fpin, FILE*fpout) (void)strlcpy(session.gpsdata.dev.path, "stdin", sizeof(session.gpsdata.dev.path)); + for (i = 0; i < (int)(sizeof(minima)/sizeof(minima[0])); i++) + minima[i] = MAX_PACKET_LENGTH+1; for (;;) { @@ -565,6 +570,8 @@ static void decode(FILE *fpin, FILE*fpout) gpsd_set_century(&session); if (verbose >= 1 && TEXTUAL_PACKET_TYPE(session.lexer.type)) (void)fputs((char *)session.lexer.outbuffer, fpout); + if (session.lexer.outbuflen < minima[session.lexer.type+1]) + minima[session.lexer.type+1] = session.lexer.outbuflen; /* mask should match what's in report_data() */ if ((changed & (REPORT_IS|GST_SET|SATELLITE_SET|SUBFRAME_SET|ATTITUDE_SET|RTCM2_SET|RTCM3_SET|AIS_SET|PASSTHROUGH_IS)) == 0) continue; @@ -600,6 +607,24 @@ static void decode(FILE *fpin, FILE*fpout) if (policy.nmea) pseudonmea_report(changed, &session); } + + if (minlength) + { + for (i = 0; i < (int)(sizeof(minima)/sizeof(minima[0])); i++) { + const struct gps_type_t **dp; + /* dump all minima, ignoring comments */ + if (i != 1 && minima[i] < MAX_PACKET_LENGTH+1) { + char *np = "Unknown"; + for (dp = gpsd_drivers; *dp; dp++) { + if ((*dp)->packet_type == i-1) { + np = (*dp)->type_name; + break; + } + } + printf("%s (%d): %d\n", np, i-1, minima[i]); + } + } + } } #ifdef SOCKET_EXPORT_ENABLE @@ -654,7 +679,7 @@ int main(int argc, char **argv) gps_context_init(&context, "gpsdecode"); - while ((c = getopt(argc, argv, "cdejnpst:uvVD:")) != EOF) { + while ((c = getopt(argc, argv, "cdejmnpst:uvVD:")) != EOF) { switch (c) { case 'c': json = false; @@ -672,6 +697,11 @@ int main(int argc, char **argv) json = true; break; + case 'm': + minlength = true; + json = false; + break; + case 'n': pseudonmea = true; break; diff --git a/gpsdecode.xml b/gpsdecode.xml index cbbd4eaa..2d44513d 100644 --- a/gpsdecode.xml +++ b/gpsdecode.xml @@ -26,6 +26,7 @@ BSD terms apply: see the file COPYING in the distribution root for details. <arg choice='opt'>-d</arg> <arg choice='opt'>-e</arg> <arg choice='opt'>-j</arg> + <arg choice='opt'>-m</arg> <arg choice='opt'>-n</arg> <arg choice='opt'>-s</arg> <arg choice='opt'>-t <replaceable>typelist</replaceable></arg> @@ -70,6 +71,10 @@ default behavior.</para> <para>The <option>-j</option> explicitly sets the output dump format to JSON (the default behavior).</para> +<para>With the <option>-m</option> option, dump minimum lengths for +each packet type in the input. This is probably of interest only +to GSD developers.</para> + <para>The <option>-n</option> enables dumping in generated pseudo-NME0183.</para> |