diff options
-rw-r--r-- | driver_evermore.c | 12 | ||||
-rw-r--r-- | driver_garmin.c | 17 | ||||
-rw-r--r-- | driver_italk.c | 4 | ||||
-rw-r--r-- | driver_navcom.c | 2 | ||||
-rw-r--r-- | driver_oncore.c | 2 | ||||
-rw-r--r-- | driver_proto.c | 28 | ||||
-rw-r--r-- | driver_sirf.c | 145 | ||||
-rw-r--r-- | driver_superstar2.c | 4 | ||||
-rw-r--r-- | driver_tsip.c | 18 | ||||
-rw-r--r-- | driver_ubx.c | 27 | ||||
-rw-r--r-- | driver_zodiac.c | 2 | ||||
-rw-r--r-- | drivers.c | 32 | ||||
-rw-r--r-- | gpsd.h-tail | 6 | ||||
-rw-r--r-- | libgpsd_core.c | 6 | ||||
-rw-r--r-- | www/writing-a-driver.xml | 37 |
15 files changed, 125 insertions, 217 deletions
diff --git a/driver_evermore.c b/driver_evermore.c index 60950558..05b40afa 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -494,6 +494,10 @@ static void evermore_event_hook(struct gps_device_t *session, event_t event) (void) evermore_mode(session, 1); /* switch GPS to binary mode */ session->back_to_nmea = true; } + if (event == event_revert) { + gpsd_report(LOG_PROG, "evermore_revert\n"); + (void) evermore_nmea_config(session, 0); /* configure NMEA messages to default */ + } } @@ -517,12 +521,6 @@ static bool evermore_rate_switcher(struct gps_device_t *session, double rate) } /*@ -charint @*/ } - -static void evermore_revert(struct gps_device_t *session) -{ - gpsd_report(LOG_PROG, "evermore_revert\n"); - (void) evermore_nmea_config(session, 0); /* configure NMEA messages to default */ -} #endif /* ALLOW_RECONFIGURE */ @@ -547,8 +545,6 @@ const struct gps_type_t evermore_binary = .mode_switcher = evermore_mode, /* there is a mode switcher */ .rate_switcher = evermore_rate_switcher, /* change sample rate */ .min_cycle = 1, /* ignore, no rate switch */ - .revert = evermore_revert, /* reversion code */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* wrapup method */ }; #endif /* defined(EVERMORE_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_garmin.c b/driver_garmin.c index 2f9139f6..99075639 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -875,14 +875,9 @@ static void garmin_event_hook(struct gps_device_t *session, event_t event) , GARMIN_PKTID_L001_COMMAND_DATA, 2, CMND_START_RM_DATA); #endif } -} - -static void garmin_close(struct gps_device_t *session UNUSED) -{ - /* FIXME -- do we need to put the garmin to sleep? or is closing the port - sufficient? */ - gpsd_report(LOG_PROG, "garmin_close()\n"); - return; + if (event == event_revert) + /* FIXME: is any action needed, or is closing the port sufficient? */ + gpsd_report(LOG_PROG, "garmin_close()\n"); } #define Send_ACK() Build_Send_SER_Packet(session, 0, ACK, 0, 0) @@ -1224,9 +1219,7 @@ const struct gps_type_t garmin_usb_binary_old = .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = garmin_close, /* close hook */ }; #endif /* __UNUSED__ */ @@ -1250,9 +1243,7 @@ const struct gps_type_t garmin_usb_binary = .mode_switcher = garmin_switcher, /* how to change modes */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = garmin_close, /* close hook */ }; const struct gps_type_t garmin_ser_binary = @@ -1275,9 +1266,7 @@ const struct gps_type_t garmin_ser_binary = .mode_switcher = garmin_switcher, /* how to change modes */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* close hook */ }; #endif /* GARMIN_ENABLE */ diff --git a/driver_italk.c b/driver_italk.c index 113e1250..98347d9f 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -434,9 +434,7 @@ const struct gps_type_t italk_binary = .mode_switcher = italk_mode, /* there is a mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no close hook */ }; #endif /* defined(ITRAX_ENABLE) && defined(BINARY_ENABLE) */ @@ -559,9 +557,7 @@ const static struct gps_type_t itrax = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = itrax_rate, /* there's a sample-rate switcher */ .min_cycle = 0, /* no hard limit */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = itrax_wrap, /* sleep the receiver */ }; /*@ -redef @*/ #endif /* ITRAX_ENABLE */ diff --git a/driver_navcom.c b/driver_navcom.c index 8b3d18f6..103d866d 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -1281,9 +1281,7 @@ const struct gps_type_t navcom_binary = .mode_switcher = NULL, /* there is not a mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* ignore, no rate switch */ - .revert = NULL, /* no reversion code */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* ignore, no wrapup */ }; #endif /* defined(NAVCOM_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_oncore.c b/driver_oncore.c index 77d45aa1..a214ca7d 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -492,10 +492,8 @@ const struct gps_type_t oncore_binary = { /* Minimum cycle time of the device */ .min_cycle = 1, /* Undo actions at configure_event time */ - .revert = NULL, #endif /* ALLOW_RECONFIGURE */ /* Puts device back to original settings */ - .wrapup = NULL, }; #endif /* defined(ONCORE_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_proto.c b/driver_proto.c index e03ab721..ccdc2bc5 100644 --- a/driver_proto.c +++ b/driver_proto.c @@ -72,8 +72,6 @@ static void _proto__probe_wakeup(struct gps_device_t *); static void _proto__event_hook(struct gps_device_t *, event_t); static bool _proto__set_speed(struct gps_device_t *, speed_t, char, int); static void _proto__set_mode(struct gps_device_t *, int); -static void _proto__revert(struct gps_device_t *); -static void _proto__wrapup(struct gps_device_t *); /* * Decode the navigation solution message @@ -317,7 +315,7 @@ static void _proto__event_hook(struct gps_device_t *session, event_t event) { /* * Remember that session->packet.counter is available when yoo write - these hooks; session->packet.counter == 0 is often a useful condition. + * these hooks; session->packet.counter == 0 is often a useful condition. */ if (event == event_configure) { /* @@ -332,6 +330,15 @@ static void _proto__event_hook(struct gps_device_t *session, event_t event) * anything, but conditionalizing probes on them gives the device * time to respond to each one. */ + } else if (event == event_revert) { + /* + * Reverse whatever was done art configure_event time. + */ + } else if (event == event_wrapup) { + /* + * Do release actions that are independent of whether the + * event_configure hook ran or not. + */ } } @@ -387,21 +394,10 @@ static void _proto__set_mode(struct gps_device_t *session, int mode) session->gpsdata.driver_mode = MODE_BINARY; } } - -static void _proto__revert(struct gps_device_t *session) -{ - /* - * Reverse whatever was done art configure_event time. - */ -} #endif /* ALLOW_RECONFIGURE */ static void _proto__wrapup(struct gps_device_t *session) { - /* - * Do release actions that are independent of whether the event_configure - * hook ran or not. - */ } /* The methods in this code take parameters and have */ @@ -453,11 +449,7 @@ const struct gps_type_t _proto__binary = { .rate_switcher = NULL, /* Minimum cycle time of the device */ .min_cycle = 1, - /* Undo the actions at configure_event time */ - .revert = _proto__revert, #endif /* ALLOW_RECONFIGURE */ - /* Puts device back to original settings */ - .wrapup = _proto__wrapup, }; #endif /* defined(_PROTO__ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_sirf.c b/driver_sirf.c index d9013001..5632e7ab 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -939,83 +939,82 @@ static gps_mask_t sirfbin_parse_input(struct gps_device_t *session) #ifdef ALLOW_RECONFIGURE static void sirfbin_event_hook(struct gps_device_t *session, event_t event) { - if (event != event_configure || session->packet.counter != 0) - return; - if (session->packet.type == NMEA_PACKET) { - gpsd_report(LOG_PROG, "Switching chip mode to SiRF binary.\n"); - (void)nmea_send(session, - "$PSRF100,0,%d,8,1,0", session->gpsdata.dev.baudrate); + if (event == event_configure || session->packet.counter == 0) { + if (session->packet.type == NMEA_PACKET) { + gpsd_report(LOG_PROG, "Switching chip mode to SiRF binary.\n"); + (void)nmea_send(session, + "$PSRF100,0,%d,8,1,0", session->gpsdata.dev.baudrate); + } + /* do this every time*/ + { + /*@ +charint @*/ + static unsigned char navparams[] = {0xa0, 0xa2, 0x00, 0x02, + 0x98, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + static unsigned char dgpscontrol[] = {0xa0, 0xa2, 0x00, 0x07, + 0x85, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + static unsigned char sbasparams[] = {0xa0, 0xa2, 0x00, 0x06, + 0xaa, 0x00, 0x01, 0x00, + 0x00, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + static unsigned char versionprobe[] = {0xa0, 0xa2, 0x00, 0x02, + 0x84, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + static unsigned char requestecef[] = {0xa0, 0xa2, 0x00, 0x08, + 0xa6, 0x00, 0x02, 0x01, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + static unsigned char requesttracker[] = {0xa0, 0xa2, 0x00, 0x08, + 0xa6, 0x00, 0x04, 0x03, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xb0, 0xb3}; + /*@ -charint @*/ + gpsd_report(LOG_PROG, "Requesting periodic ecef reports...\n"); + (void)sirf_write(session->gpsdata.gps_fd, requestecef); + gpsd_report(LOG_PROG, "Requesting periodic tracker reports...\n"); + (void)sirf_write(session->gpsdata.gps_fd, requesttracker); + gpsd_report(LOG_PROG, "Setting DGPS control to use SBAS...\n"); + (void)sirf_write(session->gpsdata.gps_fd, dgpscontrol); + gpsd_report(LOG_PROG, "Setting SBAS to auto/integrity mode...\n"); + (void)sirf_write(session->gpsdata.gps_fd, sbasparams); + gpsd_report(LOG_PROG, "Probing for firmware version...\n"); + (void)sirf_write(session->gpsdata.gps_fd, versionprobe); + gpsd_report(LOG_PROG, "Requesting navigation parameters...\n"); + (void)sirf_write(session->gpsdata.gps_fd, navparams); + } } - /* do this every time*/ - { + if (event == event_revert) { + /*@ +charint @*/ - static unsigned char navparams[] = {0xa0, 0xa2, 0x00, 0x02, - 0x98, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - static unsigned char dgpscontrol[] = {0xa0, 0xa2, 0x00, 0x07, - 0x85, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - static unsigned char sbasparams[] = {0xa0, 0xa2, 0x00, 0x06, - 0xaa, 0x00, 0x01, 0x00, - 0x00, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - static unsigned char versionprobe[] = {0xa0, 0xa2, 0x00, 0x02, - 0x84, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - static unsigned char requestecef[] = {0xa0, 0xa2, 0x00, 0x08, - 0xa6, 0x00, 0x02, 0x01, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - static unsigned char requesttracker[] = {0xa0, 0xa2, 0x00, 0x08, - 0xa6, 0x00, 0x04, 0x03, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xb0, 0xb3}; - /*@ -charint @*/ - gpsd_report(LOG_PROG, "Requesting periodic ecef reports...\n"); - (void)sirf_write(session->gpsdata.gps_fd, requestecef); - gpsd_report(LOG_PROG, "Requesting periodic tracker reports...\n"); - (void)sirf_write(session->gpsdata.gps_fd, requesttracker); - gpsd_report(LOG_PROG, "Setting DGPS control to use SBAS...\n"); - (void)sirf_write(session->gpsdata.gps_fd, dgpscontrol); - gpsd_report(LOG_PROG, "Setting SBAS to auto/integrity mode...\n"); - (void)sirf_write(session->gpsdata.gps_fd, sbasparams); - gpsd_report(LOG_PROG, "Probing for firmware version...\n"); - (void)sirf_write(session->gpsdata.gps_fd, versionprobe); - gpsd_report(LOG_PROG, "Requesting navigation parameters...\n"); - (void)sirf_write(session->gpsdata.gps_fd, navparams); + static unsigned char moderevert[] = {0xa0, 0xa2, 0x00, 0x0e, + 0x88, + 0x00, 0x00, /* pad bytes */ + 0x00, /* degraded mode */ + 0x00, 0x00, /* pad bytes */ + 0x00, 0x00, /* altitude source */ + 0x00, /* altitude hold mode */ + 0x00, /* use last computed alt */ + 0x00, /* reserved */ + 0x00, /* degraded mode timeout */ + 0x00, /* dead reckoning timeout */ + 0x00, /* track smoothing */ + 0x00, 0x00, 0xb0, 0xb3}; + /*@ -charint -shiftimplementation @*/ + putbyte(moderevert, 7, session->driver.sirf.degraded_mode); + putbeword(moderevert, 10, session->driver.sirf.altitude_source_input); + putbyte(moderevert, 12, session->driver.sirf.altitude_hold_mode); + putbyte(moderevert, 13, session->driver.sirf.altitude_hold_source); + putbyte(moderevert, 15, session->driver.sirf.degraded_timeout); + putbyte(moderevert, 16, session->driver.sirf.dr_timeout); + putbyte(moderevert, 17, session->driver.sirf.track_smooth_mode); + /*@ +shiftimplementation @*/ + gpsd_report(LOG_PROG, "Reverting navigation parameters...\n"); + (void)sirf_write(session->gpsdata.gps_fd, moderevert); } } -static void sirfbin_revert(struct gps_device_t *session) -{ - /*@ +charint @*/ - static unsigned char moderevert[] = {0xa0, 0xa2, 0x00, 0x0e, - 0x88, - 0x00, 0x00, /* pad bytes */ - 0x00, /* degraded mode */ - 0x00, 0x00, /* pad bytes */ - 0x00, 0x00, /* altitude source */ - 0x00, /* altitude hold mode */ - 0x00, /* use last computed alt */ - 0x00, /* reserved */ - 0x00, /* degraded mode timeout */ - 0x00, /* dead reckoning timeout */ - 0x00, /* track smoothing */ - 0x00, 0x00, 0xb0, 0xb3}; - /*@ -charint -shiftimplementation @*/ - putbyte(moderevert, 7, session->driver.sirf.degraded_mode); - putbeword(moderevert, 10, session->driver.sirf.altitude_source_input); - putbyte(moderevert, 12, session->driver.sirf.altitude_hold_mode); - putbyte(moderevert, 13, session->driver.sirf.altitude_hold_source); - putbyte(moderevert, 15, session->driver.sirf.degraded_timeout); - putbyte(moderevert, 16, session->driver.sirf.dr_timeout); - putbyte(moderevert, 17, session->driver.sirf.track_smooth_mode); - /*@ +shiftimplementation @*/ - gpsd_report(LOG_PROG, "Reverting navigation parameters...\n"); - (void)sirf_write(session->gpsdata.gps_fd, moderevert); -} - static bool sirfbin_speed(struct gps_device_t *session, speed_t speed, char parity, int stopbits) { @@ -1044,8 +1043,6 @@ const struct gps_type_t sirf_binary = .mode_switcher = sirfbin_mode, /* there's a mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = sirfbin_revert, /* no reversion code */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no close hook */ }; #endif /* defined(SIRF_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_superstar2.c b/driver_superstar2.c index a0a9c7de..97dd495e 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -652,10 +652,6 @@ const struct gps_type_t superstar2_binary = { .rate_switcher = NULL, /* Minimum cycle time (not used) */ .min_cycle = 1, - /* Undo the actions of event_configure */ - .revert = NULL, #endif /* ALLOW_RECONFIGURE */ - /* Puts device back to original settings */ - .wrapup = NULL, }; #endif /* defined(SUPERSTAR2_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_tsip.c b/driver_tsip.c index dba8c617..958088b2 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -51,15 +51,6 @@ static int tsip_write(struct gps_device_t *session, return 0; } -static void tsip_wrapup(struct gps_device_t *session) -{ - /* restore saved parity and stopbits when leaving TSIP mode */ - gpsd_set_speed(session, - session->gpsdata.dev.baudrate, - session->driver.tsip.parity, - session->driver.tsip.stopbits); -} - static gps_mask_t tsip_analyze(struct gps_device_t *session) { int i, j, len, count; @@ -808,6 +799,13 @@ static void tsip_event_hook(struct gps_device_t *session, event_t event) break; } } + if (event == event_revert) { + /* restore saved parity and stopbits when leaving TSIP mode */ + gpsd_set_speed(session, + session->gpsdata.dev.baudrate, + session->driver.tsip.parity, + session->driver.tsip.stopbits); + } } static bool tsip_speed_switch(struct gps_device_t *session, @@ -914,9 +912,7 @@ const struct gps_type_t tsip_binary = .mode_switcher = tsip_mode, /* there is a mode switcher */ .rate_switcher = NULL, /* no rate switcher */ .min_cycle = 1, /* not relevant, no rate switcher */ - .revert = NULL, /* FIXME: revert sentence mix */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = tsip_wrapup, /* restore comms parameters */ }; #endif /* TSIP_ENABLE */ diff --git a/driver_ubx.c b/driver_ubx.c index 3899fec6..3fca7947 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -610,21 +610,20 @@ static void ubx_event_hook(struct gps_device_t *session, event_t event) (void)ubx_write(session, 0x06u, 0x01, msg, 3); /*@ +type @*/ } -} - -static void ubx_revert(struct gps_device_t *session) -{ - /*@ -type @*/ - unsigned char msg[4] = { - 0x00, 0x00, /* hotstart */ - 0x01, /* controlled software reset */ - 0x00}; /* reserved */ - /*@ +type @*/ + if (event == event_revert) + { + /*@ -type @*/ + unsigned char msg[4] = { + 0x00, 0x00, /* hotstart */ + 0x01, /* controlled software reset */ + 0x00}; /* reserved */ + /*@ +type @*/ - gpsd_report(LOG_IO, "UBX revert\n"); + gpsd_report(LOG_IO, "UBX revert\n"); - /* Reverting all in one fast and reliable reset */ - (void)ubx_write(session, 0x06, 0x04, msg, 4); /* CFG-RST */ + /* Reverting all in one fast and reliable reset */ + (void)ubx_write(session, 0x06, 0x04, msg, 4); /* CFG-RST */ + } } static void ubx_nmea_mode(struct gps_device_t *session, int mode) @@ -739,8 +738,6 @@ const struct gps_type_t ubx_binary = { .mode_switcher = ubx_nmea_mode, /* Switch to NMEA mode */ .rate_switcher = ubx_rate, /* Message delivery rate switcher */ .min_cycle = 0.25, /* Maximum 4Hz sample rate */ - .revert = ubx_revert, /* Undo the actions of event_configure */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* Puts device back to original settings */ }; #endif /* defined(UBX_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/driver_zodiac.c b/driver_zodiac.c index 9f1193ed..1ec5e425 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -510,9 +510,7 @@ const struct gps_type_t zodiac_binary = .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no reversion hook */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* caller might supply a close hook */ }; #endif /* ZODIAC_ENABLE */ @@ -234,9 +234,7 @@ const struct gps_type_t nmea = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #if defined(GARMIN_ENABLE) && defined(NMEA_ENABLE) @@ -324,9 +322,7 @@ const struct gps_type_t garmin = { .mode_switcher = garmin_mode_switch, /* mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /*ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* GARMIN_ENABLE && NMEA_ENABLE */ @@ -385,9 +381,7 @@ const struct gps_type_t ashtech = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* ASHTECH_ENABLE */ @@ -430,9 +424,7 @@ const struct gps_type_t fv18 = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* FV18_ENABLE */ @@ -478,9 +470,7 @@ const struct gps_type_t gpsclock = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* sample rate is fixed */ .min_cycle = 1, /* sample rate is fixed */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* GPSCLOCK_ENABLE */ @@ -530,9 +520,7 @@ static const struct gps_type_t tripmate = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* no rate switch */ - .revert = NULL, /* no reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* TRIPMATE_ENABLE */ @@ -568,7 +556,7 @@ static const struct gps_type_t earthmate = { .parse_packet = nmea_parse_input, /* how to interpret a packet */ .rtcm_writer = NULL, /* don't send RTCM data */ #ifdef ALLOW_CONTROLSEND - .control_send = nmea_write, /* how to send control strings */ + .control_send = nmea_write, /* how to send control strings */ #endif /* ALLOW_CONTROLSEND */ #ifdef ALLOW_RECONFIGURE .event_hook = earthmate_event_hook, /* no configuration here */ @@ -576,9 +564,7 @@ static const struct gps_type_t earthmate = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* no rate switch */ - .revert = NULL, /* no reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup code */ }; /*@ -redef @*/ #endif /* EARTHMATE_ENABLE */ @@ -752,9 +738,7 @@ static const struct gps_type_t trueNorth = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no wrapup */ .min_cycle = 0.5, /* fixed at 20 samples per second */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif @@ -824,9 +808,7 @@ static const struct gps_type_t oceanServer = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no wrapup */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif @@ -866,9 +848,7 @@ static const struct gps_type_t rtcm104v2 = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup code */ }; #endif /* RTCM104V2_ENABLE */ #ifdef RTCM104V3_ENABLE @@ -908,9 +888,7 @@ static const struct gps_type_t rtcm104v3 = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup code */ }; #endif /* RTCM104V3_ENABLE */ @@ -947,9 +925,7 @@ static const struct gps_type_t garmintxt = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup code */ }; #endif /* GARMINTXT_ENABLE */ @@ -1040,9 +1016,7 @@ const struct gps_type_t mkt3301 = { .mode_switcher = NULL, /* no mode switcher */ .rate_switcher = NULL, /* no sample-rate switcher */ .min_cycle = 1, /* not relevant, no rate switch */ - .revert = NULL, /* no setting-reversion method */ #endif /* ALLOW_RECONFIGURE */ - .wrapup = NULL, /* no wrapup */ }; #endif /* MKT3301_ENABLE */ @@ -1099,11 +1073,7 @@ static const struct gps_type_t aivdm = { .rate_switcher = NULL, /* Minimum cycle time of the device */ .min_cycle = 1, - /* Undo the actions of configure_event */ - .revert = NULL, #endif /* ALLOW_RECONFIGURE */ - /* Puts device back to original settings */ - .wrapup = NULL, }; #endif /* AIVDM_ENABLE */ diff --git a/gpsd.h-tail b/gpsd.h-tail index d3fa5646..d56f767e 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -193,7 +193,7 @@ struct gps_device_t; #define MODE_BINARY 1 typedef enum {ANY, GPS, RTCM2, RTCM3, AIS} gnss_type; -typedef enum {event_configure, event_probe_subtype} event_t; +typedef enum {event_configure, event_probe_subtype, event_revert} event_t; struct gps_type_t { /* GPS method table, describes how to talk to a particular GPS type */ @@ -215,10 +215,8 @@ struct gps_type_t { speed_t speed, char parity, int stopbits); /*@null@*/void (*mode_switcher)(struct gps_device_t *session, int mode); /*@null@*/bool (*rate_switcher)(struct gps_device_t *session, double rate); - double min_cycle; - /*@null@*/void (*revert)(struct gps_device_t *session); #endif /* ALLOW_RECONFIGURE */ - /*@null@*/void (*wrapup)(struct gps_device_t *session); + double min_cycle; }; struct gps_device_t { diff --git a/libgpsd_core.c b/libgpsd_core.c index d557963d..c530d221 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -120,15 +120,13 @@ void gpsd_deactivate(struct gps_device_t *session) #ifdef ALLOW_RECONFIGURE if (session->enable_reconfigure && session->device_type != NULL - && session->device_type->revert != NULL) { - session->device_type->revert(session); + && session->device_type->event_hook != NULL) { + session->device_type->event_hook(session, event_revert); session->enable_reconfigure = false; } if (session->device_type!=NULL) { if (session->back_to_nmea && session->device_type->mode_switcher!=NULL) session->device_type->mode_switcher(session, 0); - if (session->device_type->wrapup!=NULL) - session->device_type->wrapup(session); } #endif /* ALLOW_RECONFIGURE */ gpsd_report(LOG_INF, "closing GPS=%s (%d)\n", diff --git a/www/writing-a-driver.xml b/www/writing-a-driver.xml index 69ea7454..7a375c15 100644 --- a/www/writing-a-driver.xml +++ b/www/writing-a-driver.xml @@ -638,6 +638,19 @@ number is set to zero and passed to both these calls. <listitem><para> Whenever a full packet is received, with event type 'event_probe_subtype'. </para></listitem> + +<listitem><para> +When the device is closed, with event type 'event_revert'. (Closes +happen when all clients have disconnected and the +<quote><option>-n</option> </quote> switch is not active.) The premise +is that there may be a special mode you initialized the device into +for <application>gpsd</application> operation which should be turned +off otherwise. It allows for changing the device to a low power mode, +for instance. Any changes you made when 'configure_event' fitred +should be undone here.This is also where you should undo any port +parameter changes you made in <structfield>.probe_detect</structfield>above. +</para></listitem> + </itemizedlist> <para>The 'event_probe_subtype' event is normally used to send probe @@ -705,30 +718,6 @@ possible, assemble your packet in <structfield>session->msgbuflen</structfield>; this will allow gpsmon to display the control messages it sends for you.</para> -<!-- deleted by ESR, 2009 --> -<!-- <para><structfield>.cycle_chars</structfield> is explained in -<quote>Throughput computation for baud rate changes</quote> in the -<quote>Hacker's Guide to GPSD</quote> in the general -documentation. It's only necessary to fill this in if you have -<structfield>.rate_switcher</structfield> capability</para> --> - -<para><structfield>.revert</structfield> points to a block of -code that is conditionally run each time the device is closed if -device reconfiguration was enabled. (Closes happen when all clients -have disconnected and the <quote><option>-n</option> </quote> switch -is not active.) The premise is that there may be a special mode you -initialized the device into for <application>gpsd</application> -operation which should be turned off otherwise. It allows for changing -the device to a low power mode, for instance. Any changes you made in -the <structfield>.configurator</structfield> method should be undone -here.</para> - -<para><structfield>.wrapup</structfield> points to a block of code -which is run unconditionally each time the device is to be closed. -(Closes happen when all clients have disconnected and the -<quote><option>-n</option> </quote> switch is not active.) This is -also where you should undo any port parameter changes you made in -<structfield>.probe_detect</structfield>above.</para> </sect1> <sect1><title>Details of the driver parser</title> |