diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-02-08 18:09:31 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-02-08 18:09:31 +0000 |
commit | d9e04f9c0c30be31f601cd038057af88936ea2c7 (patch) | |
tree | 714ec880b03f260489e453960105408e707f1750 /gpsctl.c | |
parent | 7d9de0cec1464487ed6d889054db8188d57fc917 (diff) | |
download | gpsd-d9e04f9c0c30be31f601cd038057af88936ea2c7.tar.gz |
Add a packet_type member to the device structure.
This is so we can easily map from a driver to its binary packet type.
gpsctl uses this to check whether a mode change has succeesded; no
changes to gpsd logic. All regression tests pass.
Diffstat (limited to 'gpsctl.c')
-rw-r--r-- | gpsctl.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -388,25 +388,30 @@ int main(int argc, char **argv) /*@ -nullderef @*/ if (to_nmea || to_binary) { if (session.device_type->mode_switcher == NULL) { - (void)fprintf(stderr, - "gpsctl: %s devices have no mode switch.\n", + gpsd_report(LOG_SHOUT, + "%s devices have no mode switch.\n", session.device_type->type_name); status = 1; } else { int target_mode = to_nmea ? MODE_NMEA : MODE_BINARY; + int target_type = to_nmea ? NMEA_PACKET : session.device_type->packet_type; + gpsd_report(LOG_SHOUT, + "switching to mode %s.\n", + to_nmea ? "NMEA" : "BINARY"); session.device_type->mode_switcher(&session, target_mode); /* hunt for packet type again (mode might have changed) */ if (!echo) { + (void)sleep(1); (void) alarm(timeout); for (;;) { if (get_packet(&session) == ERROR_SET) { - (void)gpsd_report(LOG_ERROR, "autodetection failed.\n"); - exit(2); - } else if (session.gpsdata.driver_mode == target_mode) + continue; + } else if (session.packet.type == target_type) { alarm(0); - break; + break; + } } } gpsd_report(LOG_SHOUT, "after mode change, %s looks like a %s at %d.\n", |