diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-11 17:36:29 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-11 17:36:29 -0500 |
commit | b7c78cd06603e3b3946f57c89785ec944921e229 (patch) | |
tree | 4da4065bc870e40d1656fb592c1d22130c48204d /driver_ubx.c | |
parent | 26931bc7567cdfec2784088f3100fae7239d798d (diff) | |
download | gpsd-b7c78cd06603e3b3946f57c89785ec944921e229.tar.gz |
Fix a truly stupid u-blox driver bug. Make baud rate change effective.
Diffstat (limited to 'driver_ubx.c')
-rw-r--r-- | driver_ubx.c | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/driver_ubx.c b/driver_ubx.c index 461e86d4..b213a675 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -662,60 +662,6 @@ static void ubx_cfg_prt(struct gps_device_t *session, switch(session->sourcetype) { case source_rs232: buf[0] = USART1_ID; - - putle32(buf, 8, speed); - - /* - * u-blox tech support explains the default contents of the mode - * field as follows: - * - * D0 08 00 00 mode (LSB first) - * - * re-ordering bytes: 000008D0 - * dividing into fields: 000000000000000000 00 100 0 11 0 1 0000 - * nStopbits = 00 = 1 - * parity = 100 = none - * charLen = 11 = 8-bit - * reserved1 = 1 - * - * The protocol reference further gives the following subfield values: - * 01 = 1.5 stop bits (?) - * 10 = 2 stopbits - * 000 = even parity - * 001 = odd parity - * 10x = no parity - * 10 = 7 bits - * - * Some UBX reference code amplifies this with: - * - * prtcfg.mode = (1<<4) | // compatibility with ANTARIS 4 - * (1<<7) | // charLen = 11 = 8 bit - * (1<<6) | // charLen = 11 = 8 bit - * (1<<11); // parity = 10x = none - */ - usart_mode |= (1<<4); /* reserved1 Antaris 4 compatibility bit */ - usart_mode |= (1<<7); /* high bit of charLen */ - - switch (parity) { - case (int)'E': - case 2: - usart_mode |= (1<<7); /* 7E */ - break; - case (int)'O': - case 1: - usart_mode |= (1<<9) | (1<<7); /* 7O */ - break; - case (int)'N': - case 0: - default: - usart_mode |= (1<<11) | (3<<6); /* 8N */ - break; - } - - if (stopbits == 2) - usart_mode |= (1<<13); - - putle32(buf, 4, usart_mode); break; case source_usb: buf[0] = USB_ID; @@ -724,9 +670,63 @@ static void ubx_cfg_prt(struct gps_device_t *session, gpsd_report(session->context->debug, LOG_WARN, "UBX driver sees unexpected source type %d.", session->sourcetype); + return; + } + + putle32(buf, 8, speed); + + /* + * u-blox tech support explains the default contents of the mode + * field as follows: + * + * D0 08 00 00 mode (LSB first) + * + * re-ordering bytes: 000008D0 + * dividing into fields: 000000000000000000 00 100 0 11 0 1 0000 + * nStopbits = 00 = 1 + * parity = 100 = none + * charLen = 11 = 8-bit + * reserved1 = 1 + * + * The protocol reference further gives the following subfield values: + * 01 = 1.5 stop bits (?) + * 10 = 2 stopbits + * 000 = even parity + * 001 = odd parity + * 10x = no parity + * 10 = 7 bits + * + * Some UBX reference code amplifies this with: + * + * prtcfg.mode = (1<<4) | // compatibility with ANTARIS 4 + * (1<<7) | // charLen = 11 = 8 bit + * (1<<6) | // charLen = 11 = 8 bit + * (1<<11); // parity = 10x = none + */ + usart_mode |= (1<<4); /* reserved1 Antaris 4 compatibility bit */ + usart_mode |= (1<<7); /* high bit of charLen */ + + switch (parity) { + case (int)'E': + case 2: + usart_mode |= (1<<7); /* 7E */ + break; + case (int)'O': + case 1: + usart_mode |= (1<<9) | (1<<7); /* 7O */ + break; + case (int)'N': + case 0: + default: + usart_mode |= (1<<11) | (3<<6); /* 8N */ break; } + if (stopbits == 2) + usart_mode |= (1<<13); + + putle32(buf, 4, usart_mode); + /* enable all input protocols by default */ buf[12] = NMEA_PROTOCOL_MASK | UBX_PROTOCOL_MASK | RTCM_PROTOCOL_MASK; |