summaryrefslogtreecommitdiff
path: root/driver_ubx.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-09 21:24:53 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-09 21:24:53 -0400
commit55008b066ba5fb681c7a0c6e60a453f0b987b559 (patch)
treea5de7eab4cce05b38aa1cf5b84d8bfa68b69208c /driver_ubx.c
parent3be9146cf2cb91e6ed2c3f1b71bd334b89bc4c18 (diff)
downloadgpsd-55008b066ba5fb681c7a0c6e60a453f0b987b559.tar.gz
Yet another bug due to wacky CFG-PRT semantics.
Diffstat (limited to 'driver_ubx.c')
-rw-r--r--driver_ubx.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/driver_ubx.c b/driver_ubx.c
index fc83924b..f382e9f3 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -627,12 +627,13 @@ static void ubx_event_hook(struct gps_device_t *session, event_t event)
}
#ifdef RECONFIGURE_ENABLE
-static void ubx_gen_cfg(struct gps_device_t *session,
- speed_t speed, const char parity, const int stopbits,
- /*@out@*/unsigned char *buf)
-/* set configuration block */
+static void ubx_cfg_prt(struct gps_device_t *session,
+ speed_t speed, const char parity, const int stopbits,
+ const mode)
+/* generare and send a configuration block */
{
unsigned long usart_mode = 0;
+ unsigned char buf[UBX_CFG_LEN];
memset(buf, '\0', UBX_CFG_LEN);
@@ -705,22 +706,10 @@ static void ubx_gen_cfg(struct gps_device_t *session,
break;
}
- /* enable all input and output protocols by default */
- buf[12] = buf[14] = NMEA_PROTOCOL_MASK | UBX_PROTOCOL_MASK | RTCM_PROTOCOL_MASK;
- /*@ -ignoresigns -charint @*/
-}
-
-static void ubx_mode(struct gps_device_t *session, int mode)
-{
- unsigned char buf[UBX_CFG_LEN];
+ /* enable all input protocols by default */
+ buf[12] = NMEA_PROTOCOL_MASK | UBX_PROTOCOL_MASK | RTCM_PROTOCOL_MASK;
- ubx_gen_cfg(session,
- gpsd_get_speed(session),
- gpsd_get_parity(session),
- gpsd_get_stopbits(session),
- buf);
-
- /*@+charint@*/
+ /* selectively enable input protocols */
if (mode == MODE_NMEA) {
buf[outProtoMask] &= ~UBX_PROTOCOL_MASK;
buf[outProtoMask] |= NMEA_PROTOCOL_MASK;
@@ -754,19 +743,29 @@ static void ubx_mode(struct gps_device_t *session, int mode)
buf[outProtoMask] &= ~NMEA_PROTOCOL_MASK;
buf[outProtoMask] |= UBX_PROTOCOL_MASK;
- }
- /*@ -charint @*/
+ }
+ /*@ -ignoresigns -charint @*/
+
(void)ubx_write(session, 0x06u, 0x00, buf, sizeof(buf));
}
+static void ubx_mode(struct gps_device_t *session, int mode)
+{
+ ubx_cfg_prt(session,
+ gpsd_get_speed(session),
+ gpsd_get_parity(session),
+ gpsd_get_stopbits(session),
+ mode);
+}
+
static bool ubx_speed(struct gps_device_t *session,
speed_t speed, char parity, int stopbits)
{
- unsigned char buf[UBX_CFG_LEN];
-
- ubx_gen_cfg(session, speed, parity, stopbits, buf);
-
- (void)ubx_write(session, 0x06, 0x00, buf, sizeof(buf));
+ ubx_cfg_prt(session,
+ speed,
+ parity,
+ stopbits,
+ session->packet.type == UBX_PACKET);
return true;
}