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. --- drivers.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers.c') 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* */ -- cgit v1.2.1