diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-03-02 13:39:41 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-03-02 13:39:41 +0000 |
commit | f737c390dbe646441329d19f31af8ff8f86afc31 (patch) | |
tree | adca3231d056b4c43764663592ad07c4c998003c /gpsmon.c | |
parent | 4f9e8b2ee2bc6cd8071cefc4f51a3b41129df7b4 (diff) | |
download | gpsd-f737c390dbe646441329d19f31af8ff8f86afc31.tar.gz |
Full support for setting parity and stop bits.
Needs to be tested for non-8N1 modes on the devices that can support it:
SiRF, UBX, Zodiac.
Diffstat (limited to 'gpsmon.c')
-rw-r--r-- | gpsmon.c | 62 |
1 files changed, 47 insertions, 15 deletions
@@ -644,30 +644,62 @@ int main (int argc, char **argv) goto quit; case 's': /* change speed */ - monitor_dump_send(); if (active == NULL) monitor_complain("No device defined yet"); else if (serial) { - v = (unsigned)atoi(arg); + speed_t speed; + char parity = (char)session.gpsdata.parity; + unsigned int stopbits = session.gpsdata.stopbits; + char *modespec; + + modespec = strchr(arg, ':'); + /*@ +charint @*/ + if (modespec!=NULL) { + if (*++modespec !='8') { + monitor_complain("No support for word length != 8."); + break; + } + parity = *++modespec; + if (strchr("NOE", parity) == NULL) { + monitor_complain("What parity is '%c'?.", parity); + break; + } + stopbits = (unsigned int)*++modespec; + if (strchr("12", (char)stopbits) == NULL) { + monitor_complain("Stop bits must be 1 or 2."); + break; + } + stopbits = (unsigned int)(stopbits-'0'); + } + /*@ -charint @*/ + speed = (unsigned)atoi(arg); /* Ugh...should have a controlfd slot * in the session structure, really */ if ((*active)->driver->speed_switcher) { int dfd = session.gpsdata.gps_fd; session.gpsdata.gps_fd = controlfd; - (void)(*active)->driver->speed_switcher(&session, v, 'N', 1); - /* - * See the comment attached to the 'B' command in gpsd. - * Allow the control string time to register at the - * GPS before we do the baud rate switch, which - * effectively trashes the UART's buffer. - */ - (void)tcdrain(session.gpsdata.gps_fd); - (void)usleep(50000); - session.gpsdata.gps_fd = dfd; - (void)gpsd_set_speed(&session, v, - (unsigned char)session.gpsdata.parity, - session.gpsdata.stopbits); + if ((*active)->driver->speed_switcher(&session, + speed, + parity, + (int)stopbits)) { + monitor_dump_send(); + /* + * See the comment attached to the 'B' + * command in gpsd. Allow the control + * string time to register at the GPS + * before we do the baud rate switch, + * which effectively trashes the UART's + * buffer. + */ + (void)tcdrain(session.gpsdata.gps_fd); + (void)usleep(50000); + session.gpsdata.gps_fd = dfd; + (void)gpsd_set_speed(&session, speed, + (unsigned char)parity, + stopbits); + } else + monitor_complain("Speed/mode cobination not supported."); } else monitor_complain("Device type has no speed switcher"); } else { |