From e84f08734721e1924783fd249ed5d2b3ec428685 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 15 Oct 2013 13:35:33 -0400 Subject: More efficiebt sticky-flagging. --- driver_evermore.c | 2 +- driver_garmin.c | 6 +++--- driver_geostar.c | 2 +- driver_italk.c | 2 +- driver_navcom.c | 2 +- driver_nmea2000.c | 2 +- driver_oncore.c | 2 +- driver_sirf.c | 2 +- driver_superstar2.c | 2 +- driver_tsip.c | 2 +- driver_ubx.c | 2 +- driver_zodiac.c | 2 +- drivers.c | 24 ++++++++++++------------ gpsd.h-tail | 6 ++++-- libgpsd_core.c | 2 +- test_packet.c | 4 ++-- 16 files changed, 33 insertions(+), 31 deletions(-) diff --git a/driver_evermore.c b/driver_evermore.c index 536d1fc6..50b4823f 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -616,7 +616,7 @@ const struct gps_type_t evermore_binary = { .type_name = "EverMore binary", /* full name of type */ .packet_type = EVERMORE_PACKET, /* lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* recognize the type */ .channels = EVERMORE_CHANNELS, /* consumer-grade GPS */ .probe_detect = NULL, /* no probe */ diff --git a/driver_garmin.c b/driver_garmin.c index 5263163b..32015573 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -1374,7 +1374,7 @@ const struct gps_type_t garmin_usb_binary_old = { .type_name = "Garmin USB binary", /* full name of type */ .packet_type = GARMIN_PACKET; /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* no trigger, it has a probe */ .channels = GARMIN_CHANNELS, /* consumer-grade GPS */ .probe_detect = garmin_usb_detect,/* how to detect at startup time */ @@ -1403,7 +1403,7 @@ const struct gps_type_t garmin_usb_binary = { .type_name = "Garmin USB binary", /* full name of type */ .packet_type = GARMIN_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* no trigger, it has a probe */ .channels = GARMIN_CHANNELS, /* consumer-grade GPS */ .probe_detect = garmin_usb_detect,/* how to detect at startup time */ @@ -1431,7 +1431,7 @@ const struct gps_type_t garmin_ser_binary = { .type_name = "Garmin Serial binary", /* full name of type */ .packet_type = GARMIN_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* no trigger, it has a probe */ .channels = GARMIN_CHANNELS, /* consumer-grade GPS */ .probe_detect = NULL, /* how to detect at startup time */ diff --git a/driver_geostar.c b/driver_geostar.c index a65d168a..d819e4ad 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -612,7 +612,7 @@ const struct gps_type_t geostar_binary = { .type_name = "GeoStar binary", /* full name of type */ .packet_type = GEOSTAR_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* no trigger */ .channels = GEOSTAR_CHANNELS, /* consumer-grade GPS/GLONASS */ .probe_detect = geostar_detect, /* probe for device */ diff --git a/driver_italk.c b/driver_italk.c index 01e350ce..2521351f 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -401,7 +401,7 @@ const struct gps_type_t italk_binary = { .type_name = "iTalk binary", /* full name of type */ .packet_type = ITALK_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* no rollover or other flags */ .trigger = NULL, /* recognize the type */ .channels = 12, /* consumer-grade GPS */ .probe_detect = NULL, /* how to detect at startup time */ diff --git a/driver_navcom.c b/driver_navcom.c index 03a984ad..5c6fbd24 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -1279,7 +1279,7 @@ const struct gps_type_t navcom_binary = { .type_name = "Navcom binary", /* full name of type */ .packet_type = NAVCOM_PACKET, /* lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* none */ .channels = NAVCOM_CHANNELS, /* 12 L1 + 12 L2 + 2 Inmarsat L-Band */ .probe_detect = NULL, /* no probe */ diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 01a652f1..f2378df2 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -1296,7 +1296,7 @@ void nmea2000_close(struct gps_device_t *session) const struct gps_type_t nmea2000 = { .type_name = "NMEA2000", /* full name of type */ .packet_type = NMEA2000_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* detect their main sentence */ .channels = 12, /* not an actual GPS at all */ .probe_detect = NULL, diff --git a/driver_oncore.c b/driver_oncore.c index 5d9db3cb..0152933a 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -485,7 +485,7 @@ const struct gps_type_t oncore_binary = { .type_name = "Oncore binary", /* Full name of type */ .packet_type = ONCORE_PACKET, /* numeric packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* identifying response */ .channels = 12, /* device channel count */ .probe_detect = NULL, /* no probe */ diff --git a/driver_sirf.c b/driver_sirf.c index 2fafd4c2..48902343 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -1368,7 +1368,7 @@ const struct gps_type_t sirf_binary = { .type_name = "SiRF binary", /* full name of type */ .packet_type = SIRF_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* no flags set */ .trigger = NULL, /* no trigger */ .channels = SIRF_CHANNELS, /* consumer-grade GPS */ .probe_detect = NULL, /* no probe */ diff --git a/driver_superstar2.c b/driver_superstar2.c index 9cf22d24..31a8658c 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -546,7 +546,7 @@ const struct gps_type_t superstar2_binary = { /* Associated lexer packet type */ .packet_type = SUPERSTAR2_PACKET, /* Driver type flags */ - .flags = DRIVER_NOFLAGS, + .flags = DRIVER_STICKY, /* Response string that identifies device (not active) */ .trigger = NULL, /* Number of satellite channels supported by the device */ diff --git a/driver_tsip.c b/driver_tsip.c index 75863f2c..087dfccf 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -1257,7 +1257,7 @@ const struct gps_type_t tsip_binary = { .type_name = "Trimble TSIP binary", /* full name of type */ .packet_type = TSIP_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, /* no trigger */ .channels = TSIP_CHANNELS, /* consumer-grade GPS */ .probe_detect = tsip_detect, /* probe for 9600O81 device */ diff --git a/driver_ubx.c b/driver_ubx.c index 3dc76822..d1bda91d 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -823,7 +823,7 @@ static bool ubx_rate(struct gps_device_t *session, double cycletime) const struct gps_type_t ubx_binary = { .type_name = "uBlox UBX binary", /* Full name of type */ .packet_type = UBX_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = NULL, .channels = 50, /* Number of satellite channels supported by the device */ .probe_detect = NULL, /* Startup-time device detector */ diff --git a/driver_zodiac.c b/driver_zodiac.c index 30ab0a58..3d9bca9c 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -471,7 +471,7 @@ const struct gps_type_t zodiac_binary = { .type_name = "Zodiac binary", /* full name of type */ .packet_type = ZODIAC_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* no flags set */ .trigger = NULL, /* no trigger */ .channels = 12, /* consumer-grade GPS */ .probe_detect = NULL, /* no probe */ diff --git a/drivers.c b/drivers.c index fceff6a3..c94dbf8b 100644 --- a/drivers.c +++ b/drivers.c @@ -244,7 +244,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) const struct gps_type_t nmea = { .type_name = "Generic NMEA", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_NOFLAGS, /* remember this */ .trigger = NULL, /* it's the default */ .channels = 12, /* consumer-grade GPS */ .probe_detect = NULL, /* no probe */ @@ -349,7 +349,7 @@ static void garmin_nmea_event_hook(struct gps_device_t *session, const struct gps_type_t garmin = { .type_name = "Garmin NMEA", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PGRMC,", /* Garmin private */ .channels = 12, /* not used by this driver */ .probe_detect = NULL, /* no probe */ @@ -411,7 +411,7 @@ static void ashtech_event_hook(struct gps_device_t *session, event_t event) const struct gps_type_t ashtech = { .type_name = "Ashtech", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PASHR,RID,", /* Ashtech receivers respond thus */ .channels = 24, /* not used, GG24 has 24 channels */ .probe_detect = NULL, /* no probe */ @@ -462,7 +462,7 @@ static void fv18_event_hook(struct gps_device_t *session, event_t event) const struct gps_type_t fv18 = { .type_name = "San Jose Navigation FV18", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PFEC,GPint,", /* FV18s should echo the probe */ .channels = 12, /* not used by this driver */ .probe_detect = NULL, /* no probe */ @@ -516,7 +516,7 @@ static void gpsclock_event_hook(struct gps_device_t *session, event_t event) const struct gps_type_t gpsclock = { .type_name = "Furuno Electric GH-79L4", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PFEC,GPssd", /* GPSclock should return this */ .channels = 12, /* not used by this driver */ .probe_detect = NULL, /* no probe */ @@ -571,7 +571,7 @@ static void tripmate_event_hook(struct gps_device_t *session, event_t event) static const struct gps_type_t tripmate = { .type_name = "Delorme TripMate", /* full name of type */ .packet_type = NMEA_PACKET, /* lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* no rollover or other flags */ .trigger ="ASTRAL", /* tells us to switch */ .channels = 12, /* consumer-grade GPS */ .probe_detect = NULL, /* no probe */ @@ -622,7 +622,7 @@ static void earthmate_event_hook(struct gps_device_t *session, event_t event) static const struct gps_type_t earthmate = { .type_name = "Pre-2003 Delorme EarthMate", .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* no rollover or other flags */ .trigger = "EARTHA", /* Earthmate trigger string */ .channels = 12, /* not used by NMEA parser */ .probe_detect = NULL, /* no probe */ @@ -745,7 +745,7 @@ static void tnt_event_hook(struct gps_device_t *session, event_t event) const struct gps_type_t trueNorth = { .type_name = "True North", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PTNTHTM", /* their proprietary sentence */ .channels = 0, /* not an actual GPS at all */ .probe_detect = NULL, /* no probe in run mode */ @@ -823,7 +823,7 @@ static void oceanserver_event_hook(struct gps_device_t *session, static const struct gps_type_t oceanServer = { .type_name = "OceanServer Digital Compass OS5000", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* no rollover or other flags */ .trigger = "$OHPR,", /* detect their main sentence */ .channels = 0, /* not an actual GPS at all */ .probe_detect = NULL, @@ -890,7 +890,7 @@ static void fury_event_hook(struct gps_device_t *session, event_t event) static const struct gps_type_t fury = { .type_name = "Jackson Labs Fury", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no rollover or other flags */ + .flags = DRIVER_STICKY, /* no rollover or other flags */ .trigger = NULL, /* detect their main sentence */ .channels = 0, /* not an actual GPS at all */ .probe_detect = NULL, @@ -1113,7 +1113,7 @@ static bool mtk3301_rate_switcher(struct gps_device_t *session, double rate) const struct gps_type_t mtk3301 = { .type_name = "MTK-3301", /* full name of type */ .packet_type = NMEA_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_STICKY, /* remember this */ .trigger = "$PMTK705,", /* firmware release name and version */ .channels = 12, /* not used by this driver */ .probe_detect = NULL, /* no probe */ @@ -1445,7 +1445,7 @@ static gps_mask_t json_pass_packet(struct gps_device_t *session UNUSED) const struct gps_type_t json_passthrough = { .type_name = "JSON slave driver", /* full name of type */ .packet_type = JSON_PACKET, /* associated lexer packet type */ - .flags = DRIVER_NOFLAGS, /* no flags set */ + .flags = DRIVER_NOFLAGS, /* don't remember this */ .trigger = NULL, /* it's the default */ .channels = 0, /* not used */ .probe_detect = NULL, /* no probe */ diff --git a/gpsd.h-tail b/gpsd.h-tail index 5692f1c5..1cebdd6e 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -296,6 +296,7 @@ typedef enum { typedef /*@unsignedintegraltype@*/ unsigned int driver_mask_t; #define DRIVER_NOFLAGS 0x00000000u +#define DRIVER_STICKY 0x00000001u /* * True if a device type is non-null and has control methods. @@ -304,10 +305,11 @@ typedef /*@unsignedintegraltype@*/ unsigned int driver_mask_t; ((dp)->speed_switcher != NULL \ || (dp)->mode_switcher != NULL \ || (dp)->rate_switcher != NULL)) + /* - * True if a driver is salient and selection of it should be sticky. + * True if a driver selection of it should be sticky. */ -#define SALIENT(dp) (CONTROLLABLE(dp) || (((dp)->packet_type == NMEA_PACKET) && strcmp((dp)->type_name, "Generic NMEA") != 0)) +#define STICKY(dp) (((dp)->flags & DRIVER_STICKY) != 0) struct gps_type_t { /* GPS method table, describes how to talk to a particular GPS type */ diff --git a/libgpsd_core.c b/libgpsd_core.c index 8c7fe45f..a6da204b 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -189,7 +189,7 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name) session->device_type->event_hook(session, event_driver_switch); #ifdef RECONFIGURE_ENABLE - if (SALIENT(*dp)) + if (STICKY(*dp)) session->last_controller = *dp; #endif /* RECONFIGURE_ENABLE */ /* clients should be notified */ diff --git a/test_packet.c b/test_packet.c index 52f24042..c91e55bf 100644 --- a/test_packet.c +++ b/test_packet.c @@ -361,8 +361,8 @@ static int property_check(void) else (void)fputs("NMEA\t", stdout); #ifdef CONTROLSEND_ENABLE - if (SALIENT(*dp)) - (void)fputs("salient\t", stdout); + if (STICKY(*dp)) + (void)fputs("sticky\t", stdout); else (void)fputs(".\t", stdout); #endif /* CONTROLSEND_ENABLE */ -- cgit v1.2.1