summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-02-24 13:12:25 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-02-24 13:12:25 -0500
commit829c3a3b0295ff653e4a14f2a7087e20940a7c0f (patch)
treeb528405a4bbcd631c35aa7968149cfb67cb21fe2
parent7e0ac597b057ed4119a76f4e33f2a5a304fc1c0a (diff)
downloadgpsd-829c3a3b0295ff653e4a14f2a7087e20940a7c0f.tar.gz
The NTRIP connection state musn't be zeroed on gpsd_activate().
Andre Naujoks informed me of this.
-rw-r--r--gpsd.c10
-rw-r--r--gpsd.h-tail40
-rw-r--r--net_dgpsip.c6
-rw-r--r--net_ntrip.c30
4 files changed, 43 insertions, 43 deletions
diff --git a/gpsd.c b/gpsd.c
index b803114b..420b9cdd 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1282,17 +1282,17 @@ static void consume_packets(struct gps_device_t *device)
* may not yet be completed. Try to ratchet things forward.
*/
if (device->servicetype == service_ntrip
- && device->driver.ntrip.conn_state != ntrip_conn_established) {
+ && device->ntrip.conn_state != ntrip_conn_established) {
/* the socket descriptor might change during connection */
if (device->gpsdata.gps_fd != -1) {
FD_CLR(device->gpsdata.gps_fd, &all_fds);
}
(void)ntrip_open(device, "");
- if (device->driver.ntrip.conn_state == ntrip_conn_err) {
+ if (device->ntrip.conn_state == ntrip_conn_err) {
gpsd_report(LOG_WARN,
"connection to ntrip server failed\n");
- device->driver.ntrip.conn_state = ntrip_conn_init;
+ device->ntrip.conn_state = ntrip_conn_init;
deactivate_device(device);
} else {
FD_SET(device->gpsdata.gps_fd, &all_fds);
@@ -1322,8 +1322,8 @@ static void consume_packets(struct gps_device_t *device)
if (device->zerokill) {
/* failed timeout-and-reawake, kill it */
deactivate_device(device);
- if (device->driver.ntrip.works) {
- device->driver.ntrip.works = false; // reset so we try this once only
+ if (device->ntrip.works) {
+ device->ntrip.works = false; // reset so we try this once only
if (gpsd_activate(device) < 0) {
gpsd_report(LOG_WARN, "reconnect to ntrip server failed\n");
} else {
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 4f9fa3e9..2c139d02 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -516,27 +516,6 @@ struct gps_device_t {
unsigned int bufindex;
} isgps;
#endif /* BINARY_ENABLE */
-
- /*
- * State of an NTRIP connection. Havoc will ensue if ntrip_conn_init
- * is not 0, as this is initialized by memset(... '\0', ...).
- */
- struct {
- enum {
- ntrip_conn_init,
- ntrip_conn_sent_probe,
- ntrip_conn_sent_get,
- ntrip_conn_established,
- ntrip_conn_err
- } conn_state; /* connection state for multi stage connect */
- bool works; /* marks a working connection, so we try to reconnect once */
- bool sourcetable_parse; /* have we read the sourcetable header? */
- } ntrip;
-
- /* State of a DGPSIP connection */
- struct {
- bool reported;
- } dgpsip;
} driver;
/*
* Auxiliary structures for parsing data that can be interleaved with
@@ -556,6 +535,25 @@ struct gps_device_t {
double d_decode_time; /* daemon end-of-decode time (-> D1) */
double emit_time; /* emission time (-> E2) */
#endif /* TIMING_ENABLE */
+ /*
+ * State of an NTRIP connection. We don't want to zero this on every
+ * activation, otherwise the connection state will get lost
+ */
+ struct {
+ enum {
+ ntrip_conn_init,
+ ntrip_conn_sent_probe,
+ ntrip_conn_sent_get,
+ ntrip_conn_established,
+ ntrip_conn_err
+ } conn_state; /* connection state for multi stage connect */
+ bool works; /* marks a working connection, so we try to reconnect once */
+ bool sourcetable_parse; /* have we read the sourcetable header? */
+ } ntrip;
+ /* State of a DGPSIP connection */
+ struct {
+ bool reported;
+ } dgpsip;
};
/* logging levels */
diff --git a/net_dgpsip.c b/net_dgpsip.c
index c747626a..87c7a188 100644
--- a/net_dgpsip.c
+++ b/net_dgpsip.c
@@ -25,7 +25,7 @@ int dgpsip_open(struct gps_device_t *device, const char *dgpsserver)
char *colon, *dgpsport = "rtcm-sc104";
int opts;
- device->driver.dgpsip.reported = false;
+ device->dgpsip.reported = false;
if ((colon = strchr(dgpsserver, ':')) != NULL) {
dgpsport = colon + 1;
*colon = '\0';
@@ -66,8 +66,8 @@ void dgpsip_report(struct gps_device_t *session)
* 10 is an arbitrary number, the point is to have gotten several good
* fixes before reporting usage to our DGPSIP server.
*/
- if (session->context->fixcnt > 10 && !session->driver.dgpsip.reported) {
- session->driver.dgpsip.reported = true;
+ if (session->context->fixcnt > 10 && !session->dgpsip.reported) {
+ session->dgpsip.reported = true;
if (session->gpsdata.gps_fd > -1) {
char buf[BUFSIZ];
(void)snprintf(buf, sizeof(buf), "R %0.8f %0.8f %0.2f\r\n",
diff --git a/net_ntrip.c b/net_ntrip.c
index ebcc01cf..5fa3a3dd 100644
--- a/net_ntrip.c
+++ b/net_ntrip.c
@@ -228,13 +228,13 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device)
gpsd_report(LOG_RAW, "Ntrip source table buffer %s\n", buf);
- sourcetable = device->driver.ntrip.sourcetable_parse;
+ sourcetable = device->ntrip.sourcetable_parse;
if (!sourcetable) {
/* parse SOURCETABLE */
if (strncmp(line, NTRIP_SOURCETABLE, strlen(NTRIP_SOURCETABLE)) ==
0) {
sourcetable = true;
- device->driver.ntrip.sourcetable_parse = true;
+ device->ntrip.sourcetable_parse = true;
llen = (ssize_t) strlen(NTRIP_SOURCETABLE);
line += llen;
len -= llen;
@@ -472,9 +472,11 @@ int ntrip_open(struct gps_device_t *device, char *caster)
char t[strlen(caster + 1)];
char *tmp = t;
- switch (device->driver.ntrip.conn_state) {
+ switch (device->ntrip.conn_state) {
case ntrip_conn_init:
device->servicetype = service_ntrip;
+ device->ntrip.works = false;
+ device->ntrip.sourcetable_parse = false;
ntrip_stream.set = false;
(void)strlcpy(tmp, caster, strlen(caster));
@@ -489,7 +491,7 @@ int ntrip_open(struct gps_device_t *device, char *caster)
gpsd_report(LOG_ERROR,
"can't extract user-ID and password from %s\n",
caster);
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
}
@@ -501,7 +503,7 @@ int ntrip_open(struct gps_device_t *device, char *caster)
/* todo: add autoconnect like in dgpsip.c */
gpsd_report(LOG_ERROR, "can't extract Ntrip stream from %s\n",
caster);
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
if ((colon = strchr(tmp, ':')) != NULL) {
@@ -522,16 +524,16 @@ int ntrip_open(struct gps_device_t *device, char *caster)
ret = ntrip_stream_req_probe();
if (ret == -1) {
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
device->gpsdata.gps_fd = ret;
- device->driver.ntrip.conn_state = ntrip_conn_sent_probe;
+ device->ntrip.conn_state = ntrip_conn_sent_probe;
return ret;
case ntrip_conn_sent_probe:
ret = ntrip_sourcetable_parse(device);
if (ret == -1) {
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
if (ret == 0 && ntrip_stream.set == false) {
@@ -539,25 +541,25 @@ int ntrip_open(struct gps_device_t *device, char *caster)
}
(void)close(device->gpsdata.gps_fd);
if (ntrip_auth_encode(&ntrip_stream, ntrip_stream.credentials, ntrip_stream.authStr, 128) != 0) {
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
ret = ntrip_stream_get_req();
if (ret == -1) {
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
device->gpsdata.gps_fd = ret;
- device->driver.ntrip.conn_state = ntrip_conn_sent_get;
+ device->ntrip.conn_state = ntrip_conn_sent_get;
break;
case ntrip_conn_sent_get:
ret = ntrip_stream_get_parse(device->gpsdata.gps_fd);
if (ret == -1) {
- device->driver.ntrip.conn_state = ntrip_conn_err;
+ device->ntrip.conn_state = ntrip_conn_err;
return -1;
}
- device->driver.ntrip.conn_state = ntrip_conn_established;
- device->driver.ntrip.works = true; // we know, this worked.
+ device->ntrip.conn_state = ntrip_conn_established;
+ device->ntrip.works = true; // we know, this worked.
break;
case ntrip_conn_established:
case ntrip_conn_err: