summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-10-26 17:31:15 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-10-26 17:31:15 +0000
commit8c4c1b38e7db2adc24528912d20486d386764327 (patch)
tree2b7e4d0a8acd1617eacaabab0fd15283857f3fcd /serial.c
parent0ad0dbab0d5a5b0d52bdcd1998a71b7eb924a5e3 (diff)
downloadgpsd-8c4c1b38e7db2adc24528912d20486d386764327.tar.gz
OK, I'm slow today.
If we don't already know the type of a device, we have to send it *every* driver's wakeups on a baud-rate change. This does, basically, the same thing the old probe function in the TrueNorth driver did since at the moment only that driver has a wakeup. Also, move the send so it gets done when we change baud rates without closing the device.
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/serial.c b/serial.c
index c041d23f..319d2a10 100644
--- a/serial.c
+++ b/serial.c
@@ -158,6 +158,21 @@ void gpsd_set_speed(struct gps_device_t *session,
session->gpsdata.baudrate = (unsigned int)speed;
session->gpsdata.parity = (unsigned int)parity;
session->gpsdata.stopbits = stopbits;
+
+ /*
+ * The device might need a wakeup string before it will send data.
+ * If we don't know the device type, ship it every driver's wakeup
+ * in hopes it will respond.
+ */
+ if (isatty(session->gpsdata.gps_fd)!=0) {
+ struct gps_type_t **dp;
+ if (session->device_type == NULL)
+ session->device_type->wakeup(session);
+ else
+ for (dp = gpsd_drivers; *dp; dp++)
+ if ((*dp)->wakeup != NULL)
+ (*dp)->wakeup(session);
+ }
packet_reset(session);
}
@@ -223,8 +238,6 @@ int gpsd_open(struct gps_device_t *session)
session->baudindex = 0;
gpsd_set_speed(session,
gpsd_get_speed(&session->ttyset_old), 'N', 1);
- if (session->device_type->wakeup != NULL)
- session->device_type->wakeup(session);
}
return session->gpsdata.gps_fd;
}
@@ -271,8 +284,6 @@ bool gpsd_next_hunt_setting(struct gps_device_t *session)
gpsd_set_speed(session,
rates[session->baudindex],
'N', session->gpsdata.stopbits);
- if (session->device_type->wakeup != NULL)
- session->device_type->wakeup(session);
}
return true; /* keep hunting */