From 2f7a78002f012c7ed322767cf3e413b961a640b4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 25 Aug 2014 07:35:41 -0400 Subject: Split firmwqre version query out of the init method. This enables us to force readonly off while it's being called. The practical effect is that gpsmon can get a firmware version (if this is possible) without reconfiguring the device. --- driver_sirf.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'driver_sirf.c') diff --git a/driver_sirf.c b/driver_sirf.c index d0506e7f..0a81781c 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -1373,6 +1373,13 @@ static gps_mask_t sirfbin_parse_input(struct gps_device_t *session) return 0; } +static void sirfbin_init_query(struct gps_device_t *session) +{ + gpsd_report(session->context->debug, LOG_PROG, + "SiRF: Probing for firmware version.\n"); + (void)sirf_write(session, versionprobe); +} + static void sirfbin_event_hook(struct gps_device_t *session, event_t event) { if (session->context->readonly) @@ -1401,9 +1408,11 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) return; case 1: + /* disable navigation debug messages (the value 5 is magic) */ gpsd_report(session->context->debug, LOG_PROG, - "SiRF: Probing for firmware version.\n"); - (void)sirf_write(session, versionprobe); + "SiRF: disable MID 7, 28, 29, 30, 31.\n"); + putbyte(unsetmidXX, 5, 0x05); + (void)sirf_write(session, unsetmidXX); break; case 2: @@ -1484,14 +1493,6 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) } break; - case 12: - /* disable navigation debug messages (the value 5 is magic) */ - gpsd_report(session->context->debug, LOG_PROG, - "SiRF: disable MID 7, 28, 29, 30, 31.\n"); - putbyte(unsetmidXX, 5, 0x05); - (void)sirf_write(session, unsetmidXX); - break; - #endif /* RECONFIGURE_ENABLE */ default: /* initialization is done */ @@ -1546,6 +1547,7 @@ const struct gps_type_t driver_sirf = .get_packet = generic_get, /* be prepared for SiRF or NMEA */ .parse_packet = sirfbin_parse_input,/* parse message packets */ .rtcm_writer = gpsd_write, /* send RTCM data straight */ + .init_query = sirfbin_init_query,/* non-perturbing initial qury */ .event_hook = sirfbin_event_hook,/* lifetime event handler */ #ifdef RECONFIGURE_ENABLE .speed_switcher = sirfbin_speed, /* we can change baud rate */ -- cgit v1.2.1