summaryrefslogtreecommitdiff
path: root/gpsctl.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-02-08 18:09:31 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-02-08 18:09:31 +0000
commitd9e04f9c0c30be31f601cd038057af88936ea2c7 (patch)
tree714ec880b03f260489e453960105408e707f1750 /gpsctl.c
parent7d9de0cec1464487ed6d889054db8188d57fc917 (diff)
downloadgpsd-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.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/gpsctl.c b/gpsctl.c
index 9e5b7bce..13ae9d80 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -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",