summaryrefslogtreecommitdiff
path: root/driver_sirf.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-09-13 09:40:29 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-09-13 09:40:29 +0000
commitbfede96dcb989353be781759f337a7b34393aac2 (patch)
tree62c6df31e74bace28c197397e348043b621e3445 /driver_sirf.c
parentcd419e26ba8bfda8ba3fa8193a792bf2b4f35e44 (diff)
downloadgpsd-bfede96dcb989353be781759f337a7b34393aac2.tar.gz
Fold the revert method into the generic event hook.
Abolish the wrapup method; there were only two users, one was trivial, and the other belonged as a revert.
Diffstat (limited to 'driver_sirf.c')
-rw-r--r--driver_sirf.c145
1 files changed, 71 insertions, 74 deletions
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) */