summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2012-04-13 00:10:25 -0400
committerEric S. Raymond <esr@thyrsus.com>2012-04-13 00:10:25 -0400
commit7fe62d3a075614ddbb7e0e60195dd0967476885a (patch)
tree76465422e5d92f86852e0bb9c96df1a31ed1f457 /gpsd.c
parentb811e3911da46870cbd974d6690d20a9ced44d87 (diff)
downloadgpsd-7fe62d3a075614ddbb7e0e60195dd0967476885a.tar.gz
Attempt a fix to the reported bug of RTCM packets getting lost.
All regression tests pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/gpsd.c b/gpsd.c
index 50bced5b..4bcc5cad 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1517,8 +1517,7 @@ static void consume_packets(struct gps_device_t *device)
#endif /* SOCKET_EXPORT_ENABLE */
/*
- * If the device provided an RTCM packet, stash it
- * in the context structure for use as a future correction.
+ * If the device provided an RTCM packet, repeat it to all devices.
*/
if ((changed & RTCM2_SET) != 0 || (changed & RTCM3_SET) != 0) {
if (device->packet.outbuflen > RTCM_MAX) {
@@ -1526,11 +1525,23 @@ static void consume_packets(struct gps_device_t *device)
"overlong RTCM packet (%zd bytes)\n",
device->packet.outbuflen);
} else {
- context.rtcmbytes = device->packet.outbuflen;
- memcpy(context.rtcmbuf,
- device->packet.outbuffer,
- context.rtcmbytes);
- context.rtcmtime = timestamp();
+ struct gps_device_t *dp;
+ for (dp = devices; dp < devices+MAXDEVICES; dp++) {
+ if (allocated_device(dp)) {
+/* *INDENT-OFF* */
+ if (dp->device_type->rtcm_writer != NULL) {
+ if (dp->device_type->rtcm_writer(dp,
+ (const char *)dp->packet.outbuffer,
+ dp->packet.outbuflen) == 0)
+ gpsd_report(LOG_ERROR, "Write to RTCM sink failed\n");
+ else {
+ gpsd_report(LOG_IO, "<= DGPS: %zd bytes of RTCM relayed.\n",
+ dp->packet.outbuflen);
+ }
+ }
+/* *INDENT-ON* */
+ }
+ }
}
}
@@ -2313,27 +2324,6 @@ int main(int argc, char *argv[])
if (!allocated_device(device))
continue;
-/* *INDENT-OFF* */
- /* pass the current RTCM correction to the GPS if new */
- if (device->device_type != NULL) {
- if (device->gpsdata.gps_fd != -1
- && device->context->rtcmbytes > 0
- && device->rtcmtime < device->context->rtcmtime
- && device->device_type->rtcm_writer != NULL) {
- if (device->device_type->rtcm_writer(device,
- device->context->rtcmbuf,
- device->context->rtcmbytes) ==
- 0)
- gpsd_report(LOG_ERROR, "Write to RTCM sink failed\n");
- else {
- device->rtcmtime = timestamp();
- gpsd_report(LOG_IO, "<= DGPS: %zd bytes of RTCM relayed.\n",
- device->context->rtcmbytes);
- }
- }
- }
-/* *INDENT-ON* */
-
if (device->gpsdata.gps_fd >= 0) {
if (FD_ISSET(device->gpsdata.gps_fd, &rfds))
/* get data from the device */