From 76535a3b3318266b691a12bef71db467be47282d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 29 Jan 2015 12:49:06 -0500 Subject: Add a minimum packet length to every driver. Length 0 means the minimum is unknown and the driver should use character I/O. --- driver_evermore.c | 1 + driver_garmin.c | 3 +++ driver_geostar.c | 1 + driver_italk.c | 1 + driver_navcom.c | 1 + driver_nmea2000.c | 1 + driver_oncore.c | 1 + driver_proto.c | 2 ++ driver_sirf.c | 1 + driver_superstar2.c | 1 + driver_tsip.c | 1 + driver_ubx.c | 1 + driver_zodiac.c | 1 + drivers.c | 19 +++++++++++++++++++ gpsd.h-tail | 1 + 15 files changed, 36 insertions(+) diff --git a/driver_evermore.c b/driver_evermore.c index 132d1db4..92a99044 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -637,6 +637,7 @@ const struct gps_type_t driver_evermore = #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 10, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ #endif /* defined(EVERMORE_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_garmin.c b/driver_garmin.c index d9d4888d..7450d5f7 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -1401,6 +1401,7 @@ const struct gps_type_t driver_garmin_usb_binary_old = #ifdef TIMEHINT_ENABLE .time_offset = garmin_time_offset, #endif /* TIMEHINT_ENABLE */ + .minlength = 0; /* min packet length unknown */ }; /* *INDENT-ON* */ #endif /* __UNUSED__ */ @@ -1431,6 +1432,7 @@ const struct gps_type_t driver_garmin_usb_binary = #ifdef TIMEHINT_ENABLE .time_offset = garmin_time_offset, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* min packet length unknown */ }; /* *INDENT-ON* */ @@ -1460,6 +1462,7 @@ const struct gps_type_t driver_garmin_ser_binary = #ifdef TIMEHINT_ENABLE .time_offset = garmin_time_offset, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* min packet length unknown */ }; /* *INDENT-ON* */ diff --git a/driver_geostar.c b/driver_geostar.c index 11e9ad78..06b2d563 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -640,6 +640,7 @@ const struct gps_type_t driver_geostar = #ifdef TIMEHINT_ENABLE .time_offset = geostar_time_offset, #endif /* TIMEHINT_ENABLE */ + .minlength = 24, /* min packet length for the GeoStar */ }; /* *INDENT-ON* */ diff --git a/driver_italk.c b/driver_italk.c index 051376c2..e1cdf483 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -432,6 +432,7 @@ const struct gps_type_t driver_italk = #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 30, /* min packet length for chunked output */ }; /* *INDENT-ON* */ #endif /* defined(ITRAX_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_navcom.c b/driver_navcom.c index 925b7b61..067aef0b 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -1310,6 +1310,7 @@ const struct gps_type_t driver_navcom = #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 10, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 1d25158b..fba3f967 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -1687,6 +1687,7 @@ const struct gps_type_t driver_nmea2000 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* min packet length unknown */ }; /* *INDENT-ON* */ diff --git a/driver_oncore.c b/driver_oncore.c index 8cea6e7c..569e1f4d 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -520,6 +520,7 @@ const struct gps_type_t driver_oncore = { #ifdef TIMEHINT_ENABLE .time_offset = oncore_time_offset, /* NTP offset array */ #endif /* TIMEHINT_ENABLE */ + .minlength = 38, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ #endif /* defined(ONCORE_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_proto.c b/driver_proto.c index bbbd7c0d..e8953cf8 100644 --- a/driver_proto.c +++ b/driver_proto.c @@ -533,6 +533,8 @@ const struct gps_type_t driver__proto__binary = { #ifdef TIMEHINT_ENABLE .time_offset = _proto_time_offset, #endif /* TIMEHINT_ENABLE */ + /* minimum length of packet, used for I/O optimization */ + .minlength = 0; /* *INDENT-ON* */ }; #endif /* defined(_PROTO__ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_sirf.c b/driver_sirf.c index 20e7b513..87146ce7 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -1590,6 +1590,7 @@ const struct gps_type_t driver_sirf = #ifdef TIMEHINT_ENABLE .time_offset = sirf_time_offset, #endif /* NTP_SHM_ENABLE */ + .minlength = 13, /* minimum SiRF packet length */ }; /* *INDENT-ON* */ #endif /* defined(SIRF_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_superstar2.c b/driver_superstar2.c index 94cc3320..95d69cd4 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -585,6 +585,7 @@ const struct gps_type_t driver_superstar2 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 65, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ #endif /* defined(SUPERSTAR2_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_tsip.c b/driver_tsip.c index 6134e3d9..994da718 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -1281,6 +1281,7 @@ const struct gps_type_t driver_tsip = #ifdef TIMEHINT_ENABLE .time_offset = tsip_time_offset, #endif /* TIMEHINT_ENABLE */ + .minlength = 5, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ diff --git a/driver_ubx.c b/driver_ubx.c index 2f2a7358..260c8523 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -992,6 +992,7 @@ const struct gps_type_t driver_ubx = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 17, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ #endif /* defined(UBLOX_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_zodiac.c b/driver_zodiac.c index 2a0e367e..1da18bf4 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -486,6 +486,7 @@ const struct gps_type_t driver_zodiac = #ifdef TIMEHINT_ENABLE .time_offset = zodiac_time_offset, /* compute NTO fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 40, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ diff --git a/drivers.c b/drivers.c index 0003ad11..b5c898dc 100644 --- a/drivers.c +++ b/drivers.c @@ -16,6 +16,8 @@ #include "bits.h" /* for getbeu16(), to extract big-endian words */ #include "strfuncs.h" +#define NMEA_MINLENGTH 16 /* minimum length of NMEA0183 packet */ + ssize_t generic_get(struct gps_device_t *session) { return packet_get(session->gpsdata.gps_fd, &session->lexer); @@ -102,6 +104,7 @@ const struct gps_type_t driver_unknown = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* minimum packet length is unknown */ }; /* *INDENT-ON* */ @@ -272,6 +275,7 @@ const struct gps_type_t driver_nmea0183 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ @@ -374,6 +378,7 @@ const struct gps_type_t driver_garmin = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* min packet length for chunked I/O */ }; /* *INDENT-ON* */ #endif /* GARMIN_ENABLE && NMEA_ENABLE */ @@ -437,6 +442,7 @@ const struct gps_type_t driver_ashtech = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* minimum packet length is unknown */ }; /* *INDENT-ON* */ #endif /* ASHTECH_ENABLE */ @@ -489,6 +495,7 @@ const struct gps_type_t driver_fv18 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NMEA minimum length */ }; /* *INDENT-ON* */ #endif /* FV18_ENABLE */ @@ -544,6 +551,7 @@ const struct gps_type_t driver_gpsclock = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NMEA minimum length */ }; /* *INDENT-ON* */ #endif /* GPSCLOCK_ENABLE */ @@ -600,6 +608,7 @@ static const struct gps_type_t driver_tripmate = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NME0183 minimum langth */ }; /* *INDENT-ON* */ #endif /* TRIPMATE_ENABLE */ @@ -651,6 +660,7 @@ static const struct gps_type_t driver_earthmate = { #endif /* CONTROLSEND_ENABLE */ #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ + .minlength = 40, /* use Zodiac minimum langth */ #endif /* TIMEHINT_ENABLE */ }; /*@ -redef @*/ @@ -778,6 +788,7 @@ const struct gps_type_t driver_trueNorth = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NME0183 minimum langth */ }; /* *INDENT-ON* */ #endif @@ -858,6 +869,7 @@ static const struct gps_type_t driver_oceanServer = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NME0183 minimum langth */ }; /* *INDENT-ON* */ #endif @@ -926,6 +938,7 @@ static const struct gps_type_t driver_fury = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NME0183 minimum langth */ }; /* *INDENT-ON* */ @@ -981,6 +994,7 @@ static const struct gps_type_t driver_rtcm104v2 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* raw I/O - could probably be tuned */ }; /* *INDENT-ON* */ #endif /* RTCM104V2_ENABLE */ @@ -1028,6 +1042,7 @@ static const struct gps_type_t driver_rtcm104v3 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* raw I/O - could probably be tuned */ }; /* *INDENT-ON* */ #endif /* RTCM104V3_ENABLE */ @@ -1064,6 +1079,7 @@ static const struct gps_type_t driver_garmintxt = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = 0, /* min packet length unknown */ }; /* *INDENT-ON* */ #endif /* GARMINTXT_ENABLE */ @@ -1160,6 +1176,7 @@ const struct gps_type_t driver_mtk3301 = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, #endif /* TIMEHINT_ENABLE */ + .minlength = NMEA_MINLENGTH, /* use NME0183 minimum langth */ }; /* *INDENT-ON* */ #endif /* MTK3301_ENABLE */ @@ -1403,6 +1420,7 @@ const struct gps_type_t driver_aivdm = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no NTP communication */ #endif /* TIMEHINT_ENABLE */ + .minlength = 23, /* minimum AIVDM packet length */ }; /* *INDENT-ON* */ #endif /* AIVDM_ENABLE */ @@ -1507,6 +1525,7 @@ const struct gps_type_t driver_json_passthrough = { #ifdef TIMEHINT_ENABLE .time_offset = NULL, /* no method for NTP fudge factor */ #endif /* TIMEHINT_ENABLE */ + .minlength = 43, /* minimum JSON packet length */ }; /* *INDENT-ON* */ diff --git a/gpsd.h-tail b/gpsd.h-tail index 6cd760b3..ceb2707f 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -389,6 +389,7 @@ struct gps_type_t { #ifdef TIMEHINT_ENABLE /*@null@*/double (*time_offset)(struct gps_device_t *session); #endif /* TIMEHINT_ENABLE */ + int minlength; }; /* -- cgit v1.2.1