summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-23 13:12:10 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-23 13:12:10 +0000
commit6b070fe325b731a967f8ace8dc2b5d2786676014 (patch)
tree252cf17959eb80572d6088ed7d67f9ce6d647005
parent894add2589562cf783f444ca7e83943045ffae43 (diff)
downloadgpsd-6b070fe325b731a967f8ace8dc2b5d2786676014.tar.gz
Major rearrangement of device members in struct gpsdata_t...
...documented in the protocol-transition white paper. All regression tests pass.
-rw-r--r--driver_evermore.c6
-rw-r--r--driver_italk.c16
-rw-r--r--driver_navcom.c6
-rw-r--r--driver_oncore.c8
-rw-r--r--driver_sirf.c16
-rw-r--r--driver_superstar2.c8
-rw-r--r--driver_tsip.c14
-rw-r--r--driver_ubx.c6
-rw-r--r--drivers.c8
-rw-r--r--gps.h10
-rw-r--r--gpsctl.c48
-rw-r--r--gpsd.c62
-rw-r--r--gpsd_json.c18
-rw-r--r--gpsmon.c24
-rw-r--r--gpsutils.c2
-rw-r--r--libgps.c38
-rw-r--r--libgps_json.c9
-rw-r--r--libgpsd_core.c25
-rw-r--r--serial.c30
-rw-r--r--www/protocol-transition.txt26
-rw-r--r--xgps.c2
21 files changed, 199 insertions, 183 deletions
diff --git a/driver_evermore.c b/driver_evermore.c
index 60a8e11d..cb159e56 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -382,7 +382,7 @@ static bool evermore_speed(struct gps_device_t *session,
/*@ -type @*/
gpsd_report(LOG_PROG, "evermore_speed(%d%c%d)\n", speed, parity, stopbits);
/* parity and stopbit switching aren't available on this chip */
- if (parity!=(int)session->gpsdata.parity || stopbits!=(int)session->gpsdata.parity) {
+ if (parity!=(int)session->gpsdata.dev.parity || stopbits!=(int)session->gpsdata.dev.parity) {
return false;
} else {
unsigned char tmp8;
@@ -457,13 +457,13 @@ static void evermore_mode(struct gps_device_t *session, int mode)
if (mode == MODE_NMEA) {
/* NMEA */
(void) evermore_protocol(session, 1);
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
(void) evermore_nmea_config(session, 1); /* configure NMEA messages for gpsd */
} else {
/* binary */
(void) evermore_protocol(session, 0);
session->back_to_nmea = false;
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
}
}
diff --git a/driver_italk.c b/driver_italk.c
index 3f8de031..6bf17445 100644
--- a/driver_italk.c
+++ b/driver_italk.c
@@ -315,12 +315,12 @@ static gps_mask_t italk_parse_input(struct gps_device_t *session)
if (session->packet.type == ITALK_PACKET){
st = italk_parse(session, session->packet.outbuffer, session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY; /* binary */
+ session->gpsdata.dev.driver_mode = MODE_BINARY; /* binary */
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
- session->gpsdata.driver_mode = MODE_NMEA; /* NMEA */
+ session->gpsdata.dev.driver_mode = MODE_NMEA; /* NMEA */
return st;
#endif /* NMEA_ENABLE */
} else
@@ -377,9 +377,9 @@ static void italk_mode(struct gps_device_t *session, int mode)
{
if (mode == MODE_NMEA) {
(void)italk_set_mode(session,
- session->gpsdata.baudrate,
- (char)session->gpsdata.parity,
- (int)session->gpsdata.stopbits,
+ session->gpsdata.dev.baudrate,
+ (char)session->gpsdata.dev.parity,
+ (int)session->gpsdata.dev.stopbits,
false);
}
}
@@ -388,9 +388,9 @@ static void italk_configurator(struct gps_device_t *session, unsigned int seq)
{
if (seq == 0 && session->packet.type == NMEA_PACKET)
(void)italk_set_mode(session,
- session->gpsdata.baudrate,
- (char)session->gpsdata.parity,
- (int)session->gpsdata.stopbits,
+ session->gpsdata.dev.baudrate,
+ (char)session->gpsdata.dev.parity,
+ (int)session->gpsdata.dev.stopbits,
true);
}
#endif /* ALLOW_RECONFIGURE */
diff --git a/driver_navcom.c b/driver_navcom.c
index 02832fdf..5ab00a33 100644
--- a/driver_navcom.c
+++ b/driver_navcom.c
@@ -1146,12 +1146,12 @@ static gps_mask_t navcom_parse_input(struct gps_device_t *session)
if (session->packet.type == NAVCOM_PACKET){
st = navcom_parse(session, session->packet.outbuffer, session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY; /* binary */
+ session->gpsdata.dev.driver_mode = MODE_BINARY; /* binary */
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
- session->gpsdata.driver_mode = MODE_NMEA; /* NMEA */
+ session->gpsdata.dev.driver_mode = MODE_NMEA; /* NMEA */
return st;
#endif /* NMEA_ENABLE */
} else
@@ -1184,7 +1184,7 @@ static bool navcom_speed(struct gps_device_t *session,
unsigned int speed, char parity, int stopbits)
{
/* parity and stopbit switching aren't implemented */
- if (parity!=(char)session->gpsdata.parity || stopbits!=(int)session->gpsdata.parity) {
+ if (parity!=(char)session->gpsdata.dev.parity || stopbits!=(int)session->gpsdata.dev.parity) {
return false;
} else {
u_int8_t port_selection;
diff --git a/driver_oncore.c b/driver_oncore.c
index 4ee3cbc5..3bc6e6f1 100644
--- a/driver_oncore.c
+++ b/driver_oncore.c
@@ -402,12 +402,12 @@ static gps_mask_t oncore_parse_input(struct gps_device_t *session)
if (session->packet.type == ONCORE_PACKET){
st = oncore_dispatch(session, session->packet.outbuffer, session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
return st;
#endif /* NMEA_ENABLE */
} else
@@ -435,7 +435,7 @@ static void oncore_set_mode(struct gps_device_t *session, int mode)
if (mode == MODE_NMEA) {
/* send the mode switch control string */
/* oncore_to_nmea(session->gpsdata.gps_fd,session->gpsdata.baudrate);*/
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
/*
* Anticipatory switching works only when the packet getter is the
* generic one and it recognizes packets of the type this driver
@@ -444,7 +444,7 @@ static void oncore_set_mode(struct gps_device_t *session, int mode)
(void)gpsd_switch_driver(session, "Generic NMEA");
} else {
session->back_to_nmea = false;
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
}
}
diff --git a/driver_sirf.c b/driver_sirf.c
index 338b76ad..dd19ab20 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -207,7 +207,7 @@ static bool sirf_to_nmea(int ttyfd, speed_t speed)
static void sirfbin_mode(struct gps_device_t *session, int mode)
{
if (mode == MODE_NMEA) {
- (void)sirf_to_nmea(session->gpsdata.gps_fd,session->gpsdata.baudrate);
+ (void)sirf_to_nmea(session->gpsdata.gps_fd,session->gpsdata.dev.baudrate);
} else {
session->back_to_nmea = false;
}
@@ -219,9 +219,9 @@ static ssize_t sirf_get(struct gps_device_t *session)
ssize_t len = generic_get(session);
if (session->packet.type == SIRF_PACKET) {
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
} else if (session->packet.type == NMEA_PACKET) {
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
(void)gpsd_switch_driver(session, "Generic NMEA");
} else {
/* should never happen */
@@ -310,7 +310,7 @@ static gps_mask_t sirf_msg_swversion(struct gps_device_t *session, unsigned char
#ifdef NTPSHM_ENABLE
session->driver.sirf.time_seen = 0;
#endif /* NTPSHM_ENABLE */
- if (session->gpsdata.baudrate >= 38400){
+ if (session->gpsdata.dev.baudrate >= 38400){
gpsd_report(LOG_PROG, "Enabling subframe transmission...\n");
(void)sirf_write(session->gpsdata.gps_fd, enablesubframe);
}
@@ -348,7 +348,7 @@ static gps_mask_t sirf_msg_navdata(struct gps_device_t *session, unsigned char *
gpsd_interpret_subframe(session, words);
#ifdef ALLOW_RECONFIGURE
- if (session->gpsdata.baudrate < 38400){
+ if (session->gpsdata.dev.baudrate < 38400){
gpsd_report(LOG_PROG, "Disabling subframe transmission...\n");
(void)sirf_write(session->gpsdata.gps_fd, disablesubframe);
}
@@ -884,12 +884,12 @@ static gps_mask_t sirfbin_parse_input(struct gps_device_t *session)
if (session->packet.type == SIRF_PACKET){
st = sirf_parse(session, session->packet.outbuffer,
session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
return st;
#endif /* NMEA_ENABLE */
} else
@@ -904,7 +904,7 @@ static void sirfbin_configure(struct gps_device_t *session, unsigned int seq)
if (session->packet.type == NMEA_PACKET) {
gpsd_report(LOG_PROG, "Switching chip mode to SiRF binary.\n");
(void)nmea_send(session,
- "$PSRF100,0,%d,8,1,0", session->gpsdata.baudrate);
+ "$PSRF100,0,%d,8,1,0", session->gpsdata.dev.baudrate);
}
/* do this every time*/
{
diff --git a/driver_superstar2.c b/driver_superstar2.c
index d4a5a9b0..f95197f6 100644
--- a/driver_superstar2.c
+++ b/driver_superstar2.c
@@ -535,13 +535,13 @@ static gps_mask_t superstar2_parse_input(struct gps_device_t *session)
if (session->packet.type == SUPERSTAR2_PACKET){
st = superstar2_dispatch(session, session->packet.outbuffer,
session->packet.length);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
(void)gpsd_switch_driver(session, "Generic NMEA");
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
return st;
#endif /* NMEA_ENABLE */
} else
@@ -569,7 +569,7 @@ static bool superstar2_set_speed(struct gps_device_t *session,
speed_t speed, char parity, int stopbits)
{
/* parity and stopbit switching aren't available on this chip */
- if (parity!=(char)session->gpsdata.parity || (unsigned int)stopbits!=session->gpsdata.stopbits) {
+ if (parity!=(char)session->gpsdata.dev.parity || (unsigned int)stopbits!=session->gpsdata.dev.stopbits) {
return false;
} else {
/*@ +charint @*/
@@ -590,7 +590,7 @@ static void superstar2_set_mode(struct gps_device_t *session, int mode)
char mode_msg[] = {0x01, 0x48, 0xB7, 0x01, 0x00, 0x00, 0x00};
/* high bit 0 in the mode word means set NMEA mode */
- mode_msg[4] = (char)(session->gpsdata.baudrate / 300);
+ mode_msg[4] = (char)(session->gpsdata.dev.baudrate / 300);
(void)superstar2_write(session, mode_msg, 7);
/*@ -charint @*/
} else {
diff --git a/driver_tsip.c b/driver_tsip.c
index 6d301063..d20fadb7 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -59,9 +59,9 @@ static void tsip_probe_subtype(struct gps_device_t *session, unsigned int seq)
/* XXX Thunderbolts and Copernicus use 8N1... which isn't exactly a */
/* XXX good idea due to the fragile wire format. We must divine a */
/* XXX clever heuristic to decide if the parity change is required. */
- session->driver.tsip.parity = session->gpsdata.parity;
- session->driver.tsip.stopbits = session->gpsdata.stopbits;
- gpsd_set_speed(session, session->gpsdata.baudrate, 'O', 1);
+ session->driver.tsip.parity = session->gpsdata.dev.parity;
+ session->driver.tsip.stopbits = session->gpsdata.dev.stopbits;
+ gpsd_set_speed(session, session->gpsdata.dev.baudrate, 'O', 1);
break;
case 1:
@@ -85,7 +85,7 @@ static void tsip_wrapup(struct gps_device_t *session)
{
/* restore saved parity and stopbits when leaving TSIP mode */
gpsd_set_speed(session,
- session->gpsdata.baudrate,
+ session->gpsdata.dev.baudrate,
(unsigned char)session->driver.tsip.parity,
session->driver.tsip.stopbits);
}
@@ -763,13 +763,13 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session)
if (session->packet.type == TSIP_PACKET){
st = tsip_analyze(session);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#ifdef EVERMORE_ENABLE
} else if (session->packet.type == EVERMORE_PACKET) {
(void)gpsd_switch_driver(session, "EverMore binary");
st = evermore_parse(session, session->packet.outbuffer, session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#endif /* EVERMORE_ENABLE */
} else
@@ -824,7 +824,7 @@ static bool tsip_speed_switch(struct gps_device_t *session,
}
putbyte(buf,0,0xff); /* current port */
- putbyte(buf,1,(round(log((double)speed/300)/M_LN2))+2); /* input baudrate */
+ putbyte(buf,1,(round(log((double)speed/300)/M_LN2))+2); /* input dev.baudrate */
putbyte(buf,2,getub(buf,1)); /* output baudrate */
putbyte(buf,3,3); /* character width (8 bits) */
putbyte(buf,4,parity); /* parity (normally odd) */
diff --git a/driver_ubx.c b/driver_ubx.c
index 9f2ce882..d5f6aae3 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -469,12 +469,12 @@ static gps_mask_t parse_input(struct gps_device_t *session)
if (session->packet.type == UBX_PACKET){
st = ubx_parse(session, session->packet.outbuffer, session->packet.outbuflen);
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
return st;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
st = nmea_parse((char *)session->packet.outbuffer, session);
- session->gpsdata.driver_mode = MODE_NMEA;
+ session->gpsdata.dev.driver_mode = MODE_NMEA;
return st;
#endif /* NMEA_ENABLE */
} else
@@ -631,7 +631,7 @@ static void ubx_nmea_mode(struct gps_device_t *session, int mode)
for(i=0;i<22;i++)
buf[i] = original_port_settings[i]; /* copy the original port settings */
if(buf[0] == 0x01) /* set baudrate on serial port only */
- putlelong(buf, 8, session->gpsdata.baudrate);
+ putlelong(buf, 8, session->gpsdata.dev.baudrate);
if (mode == 0) {
buf[14] &= ~0x01; /* turn off UBX output on this port */
diff --git a/drivers.c b/drivers.c
index 4989c048..cc42624b 100644
--- a/drivers.c
+++ b/drivers.c
@@ -154,9 +154,9 @@ static void nmea_probe_subtype(struct gps_device_t *session, unsigned int seq)
*/
(void)nmea_send(session,
"$PSRF100,0,%d,%d,%d,0",
- session->gpsdata.baudrate,
- 9-session->gpsdata.stopbits,
- session->gpsdata.stopbits);
+ session->gpsdata.dev.baudrate,
+ 9-session->gpsdata.dev.stopbits,
+ session->gpsdata.dev.stopbits);
session->back_to_nmea = true;
break;
case 2:
@@ -251,7 +251,7 @@ static void garmin_mode_switch(struct gps_device_t *session, int mode)
(void)nmea_send(session, "$PGRMC1,1,2,1,,,,2,W,N");
(void)nmea_send(session, "$PGRMI,,,,,,,R");
(void)usleep(333); /* standard Garmin settling time */
- session->gpsdata.driver_mode = MODE_BINARY;
+ session->gpsdata.dev.driver_mode = MODE_BINARY;
}
}
diff --git a/gps.h b/gps.h
index 0d119a67..e277bbd9 100644
--- a/gps.h
+++ b/gps.h
@@ -831,6 +831,9 @@ struct device_t {
char driver[64];
char subtype[64];
double activated;
+ unsigned int baudrate, parity, stopbits; /* RS232 link parameters */
+ double cycle, mincycle; /* refresh cycle time in seconds */
+ unsigned int driver_mode; /* is driver in native mode or not? */
};
struct watch_t {
@@ -913,12 +916,7 @@ struct gps_data_t {
int azimuth[MAXCHANNELS]; /* azimuth */
double ss[MAXCHANNELS]; /* signal-to-noise ratio (dB) */
- /* where and what gpsd thinks the device is */
- char gps_device[PATH_MAX]; /* only valid if non-null. */
- char *gps_id; /* only valid if non-null. */
- unsigned int baudrate, parity, stopbits; /* RS232 link parameters */
- double cycle, mincycle; /* refresh cycle time in seconds */
- unsigned int driver_mode; /* is driver in native mode or not? */
+ struct device_t dev; /* device that shipped last update */
/* pack things that are never reported together to reduce structure size */
union {
diff --git a/gpsctl.c b/gpsctl.c
index 29f4c336..d089f92b 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -275,7 +275,7 @@ int main(int argc, char **argv)
// FIXME: Requires old protocol
(void)gps_query(gpsdata, "OFIB");
gpsd_report(LOG_SHOUT, "%s identified as %s at %d\n",
- gpsdata->gps_device,gpsdata->gps_id,gpsdata->baudrate);
+ gpsdata->dev.path,gpsdata->dev.subtype,gpsdata->dev.baudrate);
exit(0);
}
@@ -287,17 +287,17 @@ int main(int argc, char **argv)
exit(0);
}
- if (to_nmea) {
-#ifdef OLDSTYLE_ENABLE
- (void)gps_query(gpsdata, "N=0");
-#else
- (void)gps_query(gpsdata, "?CONFIGDEV={\"mode\":0}\r\n");
-#endif /* OLDSTYLE_ENABLE */
- if (gpsdata->driver_mode != MODE_NMEA) {
- gpsd_report(LOG_ERROR, "%s mode change to NMEA failed\n", gpsdata->gps_device);
+ if (to_nmea) {
+ #ifdef OLDSTYLE_ENABLE
+ (void)gps_query(gpsdata, "N=0");
+ #else
+ (void)gps_query(gpsdata, "?CONFIGDEV={\"mode\":0}\r\n");
+ #endif /* OLDSTYLE_ENABLE */
+ if (gpsdata->dev.driver_mode != MODE_NMEA) {
+ gpsd_report(LOG_ERROR, "%s mode change to NMEA failed\n", gpsdata->dev.path);
status = 1;
} else
- gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->gps_device);
+ gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->dev.path);
}
else if (to_binary) {
#ifdef OLDSTYLE_ENABLE
@@ -305,11 +305,11 @@ int main(int argc, char **argv)
#else
(void)gps_query(gpsdata, "?CONFIGDEV={\"mode\":1}\r\n");
#endif /* OLDSTYLE_ENABLE */
- if (gpsdata->driver_mode != MODE_BINARY) {
- gpsd_report(LOG_ERROR, "%s mode change to native mode failed\n", gpsdata->gps_device);
+ if (gpsdata->dev.driver_mode != MODE_BINARY) {
+ gpsd_report(LOG_ERROR, "%s mode change to native mode failed\n", gpsdata->dev.path);
status = 1;
} else
- gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->gps_device);
+ gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->dev.path);
}
if (speed != NULL) {
char parity = 'N';
@@ -352,14 +352,14 @@ int main(int argc, char **argv)
#endif /* OLDSTYLE_ENABLE */
speed, parity, stopbits);
}
- if (atoi(speed) != (int)gpsdata->baudrate) {
+ if (atoi(speed) != (int)gpsdata->dev.baudrate) {
gpsd_report(LOG_ERROR, "%s driver won't support %s%c%d\n",
- gpsdata->gps_device,
+ gpsdata->dev.path,
speed, parity, stopbits);
status = 1;
} else
gpsd_report(LOG_PROG, "%s change to %s%c%d succeeded\n",
- gpsdata->gps_device,
+ gpsdata->dev.path,
speed, parity, stopbits);
}
if (rate != NULL) {
@@ -390,7 +390,7 @@ int main(int argc, char **argv)
/*@ -mustfreeonly -immediatetrans @*/
session.context = &context;
gpsd_tty_init(&session);
- (void)strlcpy(session.gpsdata.gps_device, device, sizeof(session.gpsdata.gps_device));
+ (void)strlcpy(session.gpsdata.dev.path, device, sizeof(session.gpsdata.dev.path));
session.device_type = forcetype;
(void)gpsd_open(&session);
(void)gpsd_set_raw(&session);
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
}
}
gpsd_report(LOG_PROG, "%s looks like a %s at %d.\n",
- device, gpsd_id(&session), session.gpsdata.baudrate);
+ device, gpsd_id(&session), session.gpsdata.dev.baudrate);
if (forcetype!=NULL && strcmp("Generic NMEA", session.device_type->type_name) !=0 && strcmp(forcetype->type_name, session.device_type->type_name)!=0) {
gpsd_report(LOG_ERROR, "'%s' doesn't match non-generic type '%s' of selected device.", forcetype->type_name, session.device_type->type_name);
@@ -476,7 +476,7 @@ int main(int argc, char **argv)
}
}
gpsd_report(LOG_SHOUT, "%s identified as a %s at %d.\n",
- device, gpsd_id(&session), session.gpsdata.baudrate);
+ device, gpsd_id(&session), session.gpsdata.dev.baudrate);
}
/* if no control operation was specified, we're done */
@@ -537,13 +537,13 @@ int main(int argc, char **argv)
}
/*@ -nullpass @*/
gpsd_report(LOG_SHOUT, "after mode change, %s looks like a %s at %d.\n",
- device, gpsd_id(&session), session.gpsdata.baudrate);
+ device, gpsd_id(&session), session.gpsdata.dev.baudrate);
/*@ +nullpass @*/
}
}
if (speed) {
- char parity = echo ? 'N': session.gpsdata.parity;
- int stopbits = echo ? 1 : session.gpsdata.stopbits;
+ char parity = echo ? 'N': session.gpsdata.dev.parity;
+ int stopbits = echo ? 1 : session.gpsdata.dev.stopbits;
char *modespec;
modespec = strchr(speed, ':');
@@ -586,11 +586,11 @@ int main(int argc, char **argv)
(void)tcdrain(session.gpsdata.gps_fd);
(void)usleep(50000);
gpsd_report(LOG_PROG, "%s change to %s%c%d succeeded\n",
- session.gpsdata.gps_device,
+ session.gpsdata.dev.path,
speed, parity, stopbits);
} else {
gpsd_report(LOG_ERROR, "%s driver won't support %s%c%d.\n",
- session.gpsdata.gps_device,
+ session.gpsdata.dev.path,
speed, parity, stopbits);
status = 1;
}
diff --git a/gpsd.c b/gpsd.c
index b5ab68c4..3b67f67f 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -383,8 +383,8 @@ struct subscriber_t {
#endif
#define sub_index(s) (int)((s) - subscribers)
#define channel_index(s) (int)((s) - channels)
-#define allocated_device(devp) ((devp)->gpsdata.gps_device[0] != '\0')
-#define free_device(devp) (devp)->gpsdata.gps_device[0] = '\0'
+#define allocated_device(devp) ((devp)->gpsdata.dev.path[0] != '\0')
+#define free_device(devp) (devp)->gpsdata.dev.path[0] = '\0'
#define initialized_device(devp) ((devp)->context != NULL)
struct gps_device_t devices[MAXDEVICES];
@@ -587,7 +587,7 @@ static void deactivate_device(struct gps_device_t *device)
#ifdef GPSDNG_ENABLE
notify_watchers(device, WATCH_NEWSTYLE,
"{\"class\":\"DEVICE\",\"name\":\"%s\",\"activated\":0}\r\n",
- device->gpsdata.gps_device);
+ device->gpsdata.dev.path);
#endif /* GPSDNG_ENABLE */
if (device->gpsdata.gps_fd != -1) {
gpsd_deactivate(device);
@@ -609,7 +609,7 @@ static void raw_hook(struct gps_data_t *ud,
/* copy raw NMEA sentences from GPS to clients in raw mode */
if (sub != NULL && channel->device != NULL &&
- strcmp(ud->gps_device, channel->device->gpsdata.gps_device)==0)
+ strcmp(ud->dev.path, channel->device->gpsdata.dev.path)==0)
(void)throttled_write(sub, sentence, (ssize_t)len);
}
@@ -622,7 +622,7 @@ static void raw_hook(struct gps_data_t *ud,
struct gps_device_t *devp;
for (devp = devices; devp < devices + MAXDEVICES; devp++)
- if (allocated_device(devp) && strcmp(devp->gpsdata.gps_device, device_name)==0)
+ if (allocated_device(devp) && strcmp(devp->gpsdata.dev.path, device_name)==0)
return devp;
return NULL;
}
@@ -647,7 +647,7 @@ static /*@null@*/ struct gps_device_t *open_device(char *device_name)
/* normal case: set up GPS/RTCM/AIS service */
for (devp = devices; devp < devices + MAXDEVICES; devp++)
- if (!allocated_device(devp) || (strcmp(devp->gpsdata.gps_device, device_name)==0 && !initialized_device(devp))){
+ if (!allocated_device(devp) || (strcmp(devp->gpsdata.dev.path, device_name)==0 && !initialized_device(devp))){
goto found;
}
return NULL;
@@ -688,7 +688,7 @@ static bool allocation_filter(struct gps_device_t *device, gnss_type type)
* If we don't, open it and sniff packets until we do.
*/
if (allocated_device(device) && !initialized_device(device)) {
- if (open_device(device->gpsdata.gps_device) == NULL) {
+ if (open_device(device->gpsdata.dev.path) == NULL) {
free_device(device);
return false;
}
@@ -697,7 +697,7 @@ static bool allocation_filter(struct gps_device_t *device, gnss_type type)
gpsd_report(LOG_PROG,
"user requires %d=%s, device %d=%s emits packet type %d, observed mask is 0x%0x, checking against 0x%0x\n",
type, classmap[type].name,
- (int)(device - devices), device->gpsdata.gps_device,
+ (int)(device - devices), device->gpsdata.dev.path,
device->packet.type,
device->observed,
classmap[type].typemask);
@@ -799,7 +799,7 @@ static struct channel_t *assign_channel(struct subscriber_t *user,
sub_index(user),
(int)(channel->device - devices),
channel->device->gpsdata.gps_fd,
- channel->device->gpsdata.gps_device);
+ channel->device->gpsdata.dev.path);
else {
if (gpsd_activate(channel->device, true) < 0) {
@@ -821,8 +821,8 @@ static struct channel_t *assign_channel(struct subscriber_t *user,
/*@ -sefparams @*/
throttled_write(user, "GPSD,F=", 7);
throttled_write(user,
- channel->device->gpsdata.gps_device,
- strlen(channel->device->gpsdata.gps_device));
+ channel->device->gpsdata.dev.path,
+ strlen(channel->device->gpsdata.dev.path));
throttled_write(user, "\r\n", 2);
/*@ +sefparams @*/
}
@@ -842,7 +842,7 @@ static struct channel_t *assign_channel(struct subscriber_t *user,
#ifdef GPSDNG_ENABLE
if (newstyle(user) && was_unassigned)
(void)snprintf(buf, sizeof(buf), "{\"class\":\"DEVICE\",\"device\":\"%s\",\"activated\":%2.2f}\r\n",
- channel->device->gpsdata.gps_device,
+ channel->device->gpsdata.dev.path,
timestamp());
#endif /* GPSDNG_ENABLE */
/*@ -sefparams +matchanyintegral @*/
@@ -973,8 +973,8 @@ static void set_serial(struct gps_device_t *device,
speed_t speed, char *modestring)
/* set serial parameters for a device from a speed and modestring */
{
- unsigned int stopbits = device->gpsdata.stopbits;
- char parity = (char)device->gpsdata.parity;
+ unsigned int stopbits = device->gpsdata.dev.stopbits;
+ char parity = (char)device->gpsdata.dev.parity;
int wordsize = 8;
if (strchr("78", *modestring)!= NULL) {
@@ -1069,15 +1069,15 @@ static bool handle_oldstyle(struct subscriber_t *sub, char *buf,
}
#endif /* FIXED_PORT_SPEED */
if (channel->device) {
- if ( channel->device->gpsdata.parity == 0 ) {
+ if ( channel->device->gpsdata.dev.parity == 0 ) {
/* zero parity breaks the next snprintf */
- channel->device->gpsdata.parity = (unsigned)'N';
+ channel->device->gpsdata.dev.parity = (unsigned)'N';
}
(void)snprintf(phrase, sizeof(phrase), ",B=%d %u %c %u",
(int)gpsd_get_speed(&channel->device->ttyset),
- 9 - channel->device->gpsdata.stopbits,
- (int)channel->device->gpsdata.parity,
- channel->device->gpsdata.stopbits);
+ 9 - channel->device->gpsdata.dev.stopbits,
+ (int)channel->device->gpsdata.dev.parity,
+ channel->device->gpsdata.dev.stopbits);
} else {
(void)strlcpy(phrase, ",B=?", sizeof(phrase));
}
@@ -1091,14 +1091,14 @@ static bool handle_oldstyle(struct subscriber_t *sub, char *buf,
double cycle = strtod(++p, &p);
if (dev->rate_switcher != NULL && cycle >= dev->min_cycle)
if (dev->rate_switcher(channel->device, cycle))
- channel->device->gpsdata.cycle = cycle;
+ channel->device->gpsdata.dev.cycle = cycle;
}
if (dev->rate_switcher == NULL)
(void)snprintf(phrase, sizeof(phrase),
- ",C=%.2f", channel->device->gpsdata.cycle);
+ ",C=%.2f", channel->device->gpsdata.dev.cycle);
else
(void)snprintf(phrase, sizeof(phrase), ",C=%.2f %.2f",
- channel->device->gpsdata.cycle, channel->device->gpsdata.mincycle);
+ channel->device->gpsdata.dev.cycle, channel->device->gpsdata.dev.mincycle);
}
break;
#endif /* ALLOW_RECONFIGURE */
@@ -1160,7 +1160,7 @@ static bool handle_oldstyle(struct subscriber_t *sub, char *buf,
/*@ +branchstate @*/
if (channel != NULL && channel->device != NULL)
(void)snprintf(phrase, sizeof(phrase), ",F=%s",
- channel->device->gpsdata.gps_device);
+ channel->device->gpsdata.dev.path);
else
(void)strlcpy(phrase, ",F=?", sizeof(phrase));
break;
@@ -1211,8 +1211,8 @@ static bool handle_oldstyle(struct subscriber_t *sub, char *buf,
j++;
(void)snprintf(phrase, sizeof(phrase), ",K=%d ", j);
for (i = 0; i < MAXDEVICES; i++) {
- if (allocated_device(&devices[i]) && strlen(phrase)+strlen(devices[i].gpsdata.gps_device)+1 < sizeof(phrase)) {
- (void)strlcat(phrase, devices[i].gpsdata.gps_device, sizeof(phrase));
+ if (allocated_device(&devices[i]) && strlen(phrase)+strlen(devices[i].gpsdata.dev.path)+1 < sizeof(phrase)) {
+ (void)strlcat(phrase, devices[i].gpsdata.dev.path, sizeof(phrase));
(void)strlcat(phrase, " ", sizeof(phrase));
}
}
@@ -1247,7 +1247,7 @@ static bool handle_oldstyle(struct subscriber_t *sub, char *buf,
if (!channel || !channel->device)
(void)snprintf(phrase, sizeof(phrase), ",N=?");
else
- (void)snprintf(phrase, sizeof(phrase), ",N=%u", channel->device->gpsdata.driver_mode);
+ (void)snprintf(phrase, sizeof(phrase), ",N=%u", channel->device->gpsdata.dev.driver_mode);
break;
case 'O':
if ((channel=mandatory_assign_channel(sub, GPS, NULL))== NULL || !have_fix(channel))
@@ -1564,7 +1564,7 @@ static void json_devicelist_dump(char *reply, size_t replylen)
(void)strlcpy(reply,
"{\"class\"=\"DEVICES\",\"devices\":[", replylen);
for (devp = devices; devp < devices + MAXDEVICES; devp++)
- if (allocated_device(devp) && strlen(reply)+strlen(devp->gpsdata.gps_device)+3 < replylen-1) {
+ if (allocated_device(devp) && strlen(reply)+strlen(devp->gpsdata.dev.path)+3 < replylen-1) {
json_device_dump(devp,
reply+strlen(reply), replylen-strlen(reply));
(void)strlcat(reply, ",", replylen);
@@ -1678,7 +1678,7 @@ static void handle_newstyle_request(struct subscriber_t *sub,
for (chp = channels; chp < channels + NITEMS(channels); chp++)
if (chp->subscriber != sub)
continue;
- else if (devconf.device[0] != '\0' && chp->device && strcmp(chp->device->gpsdata.gps_device, devconf.device)!=0)
+ else if (devconf.device[0] != '\0' && chp->device && strcmp(chp->device->gpsdata.dev.path, devconf.device)!=0)
continue;
else {
channel = chp;
@@ -1689,7 +1689,7 @@ static void handle_newstyle_request(struct subscriber_t *sub,
"{\"class\":ERROR\",\"message\":\"Multiple subscribers, cannot change control bits.\"}\r\n");
else {
/* now that channel is selected, apply changes */
- if (devconf.native != channel->device->gpsdata.driver_mode)
+ if (devconf.native != channel->device->gpsdata.dev.driver_mode)
channel->device->device_type->mode_switcher(channel->device, devconf.native);
set_serial(channel->device,
(speed_t)devconf.bps, devconf.serialmode);
@@ -1701,7 +1701,7 @@ static void handle_newstyle_request(struct subscriber_t *sub,
for (chp = channels; chp < channels + NITEMS(channels); chp++)
if (chp->subscriber != sub)
continue;
- else if (devconf.device[0] != '\0' && chp->device && strcmp(chp->device->gpsdata.gps_device, devconf.device)!=0)
+ else if (devconf.device[0] != '\0' && chp->device && strcmp(chp->device->gpsdata.dev.path, devconf.device)!=0)
continue;
else {
json_configdev_dump(chp->device,
@@ -2151,7 +2151,7 @@ int main(int argc, char *argv[])
char id2[NMEA_MAX];
(void)snprintf(id2, sizeof(id2),
"{\"class\":\"DEVICE\",\"name\":\"%s\",\"subtype\":\"%s\"}",
- device->gpsdata.gps_device,
+ device->gpsdata.dev.path,
device->subtype);
(void)strlcat(id2, "\r\n", sizeof(id2));
notify_watchers(device, WATCH_NEWSTYLE, id2);
diff --git a/gpsd_json.c b/gpsd_json.c
index b95e8f52..0ed8d0cd 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -30,7 +30,7 @@ void json_tpv_dump(struct gps_data_t *gpsdata, struct gps_fix_t *fixp,
(void)snprintf(reply+strlen(reply),
replylen-strlen(reply),
"\"device\":\"%s\",",
- gpsdata->gps_device);
+ gpsdata->dev.path);
if (isnan(fixp->time)==0)
(void)snprintf(reply+strlen(reply),
replylen-strlen(reply),
@@ -115,7 +115,7 @@ void json_sky_dump(struct gps_data_t *datap, char *reply, size_t replylen)
(void)snprintf(reply+strlen(reply),
replylen-strlen(reply),
"\"device\":\"%s\",",
- datap->gps_device);
+ datap->dev.path);
if (isnan(datap->sentence_time)==0)
(void)snprintf(reply+strlen(reply),
replylen-strlen(reply),
@@ -161,7 +161,7 @@ void json_device_dump(struct gps_device_t *device,
{
struct classmap_t *cmp;
(void)strlcpy(reply, "{\"class\":\"DEVICE\",\"path\":\"", replylen);
- (void)strlcat(reply, device->gpsdata.gps_device, replylen);
+ (void)strlcat(reply, device->gpsdata.dev.path, replylen);
(void)strlcat(reply, "\",", replylen);
(void)snprintf(reply+strlen(reply), replylen-strlen(reply),
"\"activated\":%2.2f,", device->gpsdata.online);
@@ -249,13 +249,13 @@ void json_configdev_dump(struct gps_device_t *devp, char *reply, size_t replylen
{
(void)snprintf(reply, replylen,
"{\"class\":\"CONFIGDEV\",\"device\":\"%s\",\"native\":%d,\"bps\":%d,\"serialmode\":\"%u%c%u\",\"cycle\":%2.2f",
- devp->gpsdata.gps_device,
- devp->gpsdata.driver_mode,
+ devp->gpsdata.dev.path,
+ devp->gpsdata.dev.driver_mode,
(int)gpsd_get_speed(&devp->ttyset),
- 9 - devp->gpsdata.stopbits,
- (int)devp->gpsdata.parity,
- devp->gpsdata.stopbits,
- devp->gpsdata.cycle);
+ 9 - devp->gpsdata.dev.stopbits,
+ (int)devp->gpsdata.dev.parity,
+ devp->gpsdata.dev.stopbits,
+ devp->gpsdata.dev.cycle);
if (devp->device_type->rate_switcher != NULL)
(void)snprintf(reply+strlen(reply), replylen-strlen(reply),
",\"mincycle\":%2.2f",
diff --git a/gpsmon.c b/gpsmon.c
index 80dc3ae5..25293fdb 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -227,7 +227,7 @@ bool monitor_control_send(/*@in@*/unsigned char *buf, size_t len)
if (!serial) {
/*@ -sefparams @*/
assert(write(controlfd, "!", 1) != -1);
- assert(write(controlfd, session.gpsdata.gps_device, strlen(session.gpsdata.gps_device)) != -1);
+ assert(write(controlfd, session.gpsdata.dev.path, strlen(session.gpsdata.dev.path)) != -1);
assert(write(controlfd, "=", 1) != -1);
/*@ +sefparams @*/
/*
@@ -263,8 +263,8 @@ static bool monitor_raw_send(/*@in@*/unsigned char *buf, size_t len)
if (!serial) {
/*@ -sefparams @*/
assert(write(controlfd, "!", 1) != -1);
- assert(write(controlfd, session.gpsdata.gps_device,
- strlen(session.gpsdata.gps_device)) != -1);
+ assert(write(controlfd, session.gpsdata.dev.path,
+ strlen(session.gpsdata.dev.path)) != -1);
assert(write(controlfd, "=", 1) != -1);
/*@ +sefparams @*/
}
@@ -512,16 +512,16 @@ int main (int argc, char **argv)
else
command((char *)buf, sizeof(buf), "O\r\n"); /* force device allocation */
command((char *)buf, sizeof(buf), "F\r\n");
- (void)strlcpy(session.gpsdata.gps_device, (char *)buf+7, PATH_MAX);
+ (void)strlcpy(session.gpsdata.dev.path, (char *)buf+7, PATH_MAX);
command((char *)buf, sizeof(buf), "R=2\r\n");
/*@ +compdef @*/
serial = false;
} else {
- (void)strlcpy(session.gpsdata.gps_device, argv[optind], PATH_MAX);
+ (void)strlcpy(session.gpsdata.dev.path, argv[optind], PATH_MAX);
if (gpsd_activate(&session, false) == -1) {
gpsd_report(LOG_ERROR,
"activation of device %s failed, errno=%d\n",
- session.gpsdata.gps_device, errno);
+ session.gpsdata.dev.path, errno);
exit(2);
}
@@ -577,14 +577,14 @@ int main (int argc, char **argv)
(void)wattrset(statwin, A_BOLD);
if (serial)
display(statwin, 0, 0, "%s %4d %c %d",
- session.gpsdata.gps_device,
+ session.gpsdata.dev.path,
gpsd_get_speed(&session.ttyset),
- session.gpsdata.parity,
- session.gpsdata.stopbits);
+ session.gpsdata.dev.parity,
+ session.gpsdata.dev.stopbits);
else
/*@ -nullpass @*/
display(statwin, 0, 0, "%s:%s:%s",
- source.server, source.port, session.gpsdata.gps_device);
+ source.server, source.port, session.gpsdata.dev.path);
/*@ +nullpass @*/
(void)wattrset(statwin, A_NORMAL);
(void)wmove(cmdwin, 0,0);
@@ -762,8 +762,8 @@ int main (int argc, char **argv)
monitor_complain("No device defined yet");
else if (serial) {
speed_t speed;
- char parity = (char)session.gpsdata.parity;
- unsigned int stopbits = session.gpsdata.stopbits;
+ char parity = (char)session.gpsdata.dev.parity;
+ unsigned int stopbits = session.gpsdata.dev.stopbits;
char *modespec;
modespec = strchr(arg, ':');
diff --git a/gpsutils.c b/gpsutils.c
index 24cb29af..8e75e3f6 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -547,7 +547,7 @@ gps_mask_t dop(struct gps_data_t *gpsdata)
} else {
gpsd_report(LOG_INF,
"LOS matrix is singular, can't calculate DOPs - source '%s'\n",
- gpsdata->gps_device);
+ gpsdata->dev.path);
return 0;
}
diff --git a/libgps.c b/libgps.c
index f74f6dfc..0418bfc9 100644
--- a/libgps.c
+++ b/libgps.c
@@ -52,11 +52,6 @@ int gps_close(struct gps_data_t *gpsdata)
/* close a gpsd connection */
{
int retval = close(gpsdata->gps_fd);
- if (gpsdata->gps_id) {
- (void)free(gpsdata->gps_id);
- gpsdata->gps_id = NULL;
- }
- gpsdata->gps_device[0] = '\0';
/*@i@*/(void)free(gpsdata);
return retval;
}
@@ -137,19 +132,19 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata)
break;
case 'B':
if (sp[2] == '?') {
- gpsdata->baudrate = gpsdata->stopbits = 0;
+ gpsdata->dev.baudrate = gpsdata->dev.stopbits = 0;
} else
(void)sscanf(sp, "B=%u %*d %*s %u",
- &gpsdata->baudrate, &gpsdata->stopbits);
+ &gpsdata->dev.baudrate, &gpsdata->dev.stopbits);
break;
case 'C':
if (sp[2] == '?')
- gpsdata->mincycle = gpsdata->cycle = 0;
+ gpsdata->dev.mincycle = gpsdata->dev.cycle = 0;
else {
if (sscanf(sp, "C=%lf %lf",
- &gpsdata->cycle,
- &gpsdata->mincycle) < 2)
- gpsdata->mincycle = gpsdata->cycle;
+ &gpsdata->dev.cycle,
+ &gpsdata->dev.mincycle) < 2)
+ gpsdata->dev.mincycle = gpsdata->dev.cycle;
}
break;
case 'D':
@@ -175,13 +170,12 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata)
#undef DEFAULT
}
break;
- case 'F':
- /*@ -mustfreeonly */
+ case 'F': /*@ -mustfreeonly */
if (sp[2] == '?')
- gpsdata->gps_device[0] = '\0';
+ gpsdata->dev.path[0] = '\0';
else {
/*@ -mayaliasunique @*/
- strncpy(gpsdata->gps_device, sp+2, PATH_MAX);
+ strncpy(gpsdata->dev.path, sp+2, PATH_MAX);
/*@ +mayaliasunique @*/
gpsdata->set |= DEVICE_SET;
}
@@ -189,12 +183,10 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata)
break;
case 'I':
/*@ -mustfreeonly */
- if (gpsdata->gps_id)
- free(gpsdata->gps_id);
if (sp[2] == '?')
- gpsdata->gps_id = NULL;
+ gpsdata->dev.subtype[0] = '\0';
else {
- gpsdata->gps_id = strdup(sp+2);
+ (void)strlcpy(gpsdata->dev.subtype, sp+2, sizeof(gpsdata->dev.subtype));
gpsdata->set |= DEVICEID_SET;
}
/*@ +mustfreeonly */
@@ -229,9 +221,9 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata)
break;
case 'N':
if (sp[2] == '?')
- gpsdata->driver_mode = MODE_NMEA;
+ gpsdata->dev.driver_mode = MODE_NMEA;
else
- gpsdata->driver_mode = (unsigned)atoi(sp+2);
+ gpsdata->dev.driver_mode = (unsigned)atoi(sp+2);
break;
case 'O':
if (sp[2] == '?') {
@@ -616,9 +608,9 @@ static void data_dump(struct gps_data_t *collect, time_t now)
}
}
if (collect->set & DEVICE_SET)
- printf("Device is %s\n", collect->gps_device);
+ printf("Device is %s\n", collect->dev.path);
if (collect->set & DEVICEID_SET)
- printf("GPSD ID is %s\n", collect->gps_id);
+ printf("GPSD ID is %s\n", collect->dev.subtype);
if (collect->set & DEVICELIST_SET) {
int i;
printf("%d devices:\n", collect->devices.ndevices);
diff --git a/libgps_json.c b/libgps_json.c
index b6960ce0..ec5b76ed 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -25,8 +25,8 @@ static int json_tpv_read(const char *buf,
int status;
const struct json_attr_t json_attrs_1[] = {
{"class", check, .dflt.check = "TPV"},
- {"device", string, .addr.string.ptr = gpsdata->gps_device,
- .addr.string.len = sizeof(gpsdata->gps_device)},
+ {"device", string, .addr.string.ptr = gpsdata->dev.path,
+ .addr.string.len = sizeof(gpsdata->dev.path)},
{"tag", string, .addr.string.ptr = gpsdata->tag,
.addr.string.len = sizeof(gpsdata->tag)},
{"time", real, .addr.real = &gpsdata->fix.time,
@@ -111,7 +111,7 @@ static int json_sky_read(const char *buf,
};
const struct json_attr_t json_attrs_2[] = {
{"class", check, .dflt.check = "SKY"},
- {"device", string, .addr.string.ptr = gpsdata->gps_device,
+ {"device", string, .addr.string.ptr = gpsdata->dev.path,
.addr.string.len = PATH_MAX},
{"tag", string, .addr.string.ptr = gpsdata->tag,
.addr.string.len = MAXTAGLEN},
@@ -146,7 +146,8 @@ static int json_device_read(const char *buf,
{
const struct json_attr_t json_attrs_device[] = {
{"class", check, .dflt.check = "DEVICE"},
- {"path", string, .addr.string.ptr = dev->path,
+
+ {"path", string, .addr.string.ptr = dev->path,
.addr.string.len = sizeof(dev->path)},
{"activated", real, .addr.real = &dev->activated},
{"flags", integer, .addr.integer = &dev->flags},
diff --git a/libgpsd_core.c b/libgpsd_core.c
index eb3788bf..7050a6ae 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -47,7 +47,7 @@ int gpsd_switch_driver(struct gps_device_t *session, char* type_name)
gpsd_report(LOG_PROG, "selecting %s driver...\n", (*dp)->type_name);
gpsd_assert_sync(session);
/*@i@*/session->device_type = *dp;
- session->gpsdata.mincycle = session->device_type->min_cycle;
+ session->gpsdata.dev.mincycle = session->device_type->min_cycle;
if (!session->context->readonly && session->device_type->probe_subtype != NULL)
session->device_type->probe_subtype(session, session->packet.counter = 0);
#ifdef ALLOW_RECONFIGURE
@@ -70,7 +70,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, char
{
/*@ -mayaliasunique @*/
if (device != NULL)
- (void)strlcpy(session->gpsdata.gps_device, device, PATH_MAX);
+ (void)strlcpy(session->gpsdata.dev.path, device, sizeof(session->gpsdata.dev.path));
/*@ -mustfreeonly @*/
session->device_type = NULL; /* start by hunting packets */
session->observed = 0;
@@ -89,7 +89,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, char
session->gpsdata.gdop = NAN;
session->gpsdata.epe = NAN;
session->mag_var = NAN;
- session->gpsdata.cycle = session->gpsdata.mincycle = 1;
+ session->gpsdata.dev.cycle = session->gpsdata.dev.mincycle = 1;
/* tty-level initialization */
gpsd_tty_init(session);
@@ -127,7 +127,7 @@ void gpsd_deactivate(struct gps_device_t *session)
}
#endif /* ALLOW_RECONFIGURE */
gpsd_report(LOG_INF, "closing GPS=%s (%d)\n",
- session->gpsdata.gps_device, session->gpsdata.gps_fd);
+ session->gpsdata.dev.path, session->gpsdata.gps_fd);
(void)gpsd_close(session);
}
@@ -164,7 +164,7 @@ static /*@null@*/void *gpsd_ppsmonitor(void *arg)
} else {
gpsd_report(LOG_RAW, "pps-detect (%s) on %s changed to %d\n",
((pps_device==TIOCM_CAR) ? "DCD" : "CTS"),
- session->gpsdata.gps_device, state);
+ session->gpsdata.dev.path, state);
laststate = state;
unchanged = 0;
}
@@ -703,7 +703,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
session->gpsdata.d_xmit_time = timestamp();
gpsd_report(LOG_RAW,
"packet sniff on %s finds type %d\n",
- session->gpsdata.gps_device,
+ session->gpsdata.dev.path,
session->packet.type);
if (session->packet.type > COMMENT_PACKET) {
session->observed |= PACKET_TYPEMASK(session->packet.type);
@@ -721,15 +721,14 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
gpsd_report(LOG_RAW+2, "GPS sent %zd new characters\n", newlen);
if (newlen == -1) { /* read error */
gpsd_report(LOG_INF, "GPS on %s is offline (%lf sec since data)\n",
- session->gpsdata.gps_device,
+ session->gpsdata.dev.path,
timestamp() - session->gpsdata.online);
session->gpsdata.online = 0;
return 0;
} else if (newlen == 0) { /* no new data */
- if (session->device_type != NULL && timestamp()>session->gpsdata.online+session->gpsdata.
-cycle+1){
+ if (session->device_type != NULL && timestamp()>session->gpsdata.online+session->gpsdata.dev.cycle+1){
gpsd_report(LOG_INF, "GPS on %s is offline (%lf sec since data)\n",
- session->gpsdata.gps_device,
+ session->gpsdata.dev.path,
timestamp() - session->gpsdata.online);
session->gpsdata.online = 0;
return 0;
@@ -737,14 +736,14 @@ cycle+1){
return ONLINE_SET;
} else if (session->packet.outbuflen == 0) { /* got new data, but no packet */
gpsd_report(LOG_RAW+3, "New data on %s, not yet a packet\n",
- session->gpsdata.gps_device);
+ session->gpsdata.dev.path);
return ONLINE_SET;
} else {
gps_mask_t received, dopmask = 0;
session->gpsdata.online = timestamp();
gpsd_report(LOG_RAW+3, "Accepted packet on %s.\n",
- session->gpsdata.gps_device);
+ session->gpsdata.dev.path);
/*@ -nullstate @*/
if (session->gpsdata.raw_hook)
session->gpsdata.raw_hook(&session->gpsdata,
@@ -821,7 +820,7 @@ cycle+1){
#endif /* BINARY_ENABLE */
if (buf2[0] != '\0') {
gpsd_report(LOG_IO, "<= GPS (binary) %s: %s",
- session->gpsdata.gps_device, buf2);
+ session->gpsdata.dev.path, buf2);
if (session->gpsdata.raw_hook)
session->gpsdata.raw_hook(&session->gpsdata,
buf2, strlen(buf2), 1);
diff --git a/serial.c b/serial.c
index 96fa95bc..b99198ed 100644
--- a/serial.c
+++ b/serial.c
@@ -104,7 +104,7 @@ void gpsd_set_speed(struct gps_device_t *session,
else
rate = B115200;
- if (rate!=cfgetispeed(&session->ttyset) || (unsigned int)parity!=session->gpsdata.parity || stopbits!=session->gpsdata.stopbits) {
+ if (rate!=cfgetispeed(&session->ttyset) || (unsigned int)parity!=session->gpsdata.dev.parity || stopbits!=session->gpsdata.dev.stopbits) {
/*
* Don't mess with this conditional! Speed zero is supposed to mean
@@ -191,9 +191,9 @@ void gpsd_set_speed(struct gps_device_t *session,
gpsd_report(LOG_INF, "speed %d, %d%c%d\n",
gpsd_get_speed(&session->ttyset), 9-stopbits, parity, stopbits);
- session->gpsdata.baudrate = (unsigned int)speed;
- session->gpsdata.parity = (unsigned int)parity;
- session->gpsdata.stopbits = stopbits;
+ session->gpsdata.dev.baudrate = (unsigned int)speed;
+ session->gpsdata.dev.parity = (unsigned int)parity;
+ session->gpsdata.dev.stopbits = stopbits;
if (!session->context->readonly) {
/*
@@ -224,24 +224,24 @@ int gpsd_open(struct gps_device_t *session)
if (session->context->netgnss_service == netgnss_remotegpsd){
session->gpsdata.gps_fd = session->context->dsock;
session->saved_baud = 57600;
- session->gpsdata.baudrate = 57600;
- session->gpsdata.parity = 'N';
- session->gpsdata.stopbits = 1;
+ session->gpsdata.dev.baudrate = 57600;
+ session->gpsdata.dev.parity = 'N';
+ session->gpsdata.dev.stopbits = 1;
session->context->readonly = 1;
return session->gpsdata.gps_fd;
}
/*@ -boolops -type @*/
- if (session->context->readonly || ((stat(session->gpsdata.gps_device, &sb) != -1) && ((sb.st_mode & S_IFCHR) != S_IFCHR))){
+ if (session->context->readonly || ((stat(session->gpsdata.dev.path, &sb) != -1) && ((sb.st_mode & S_IFCHR) != S_IFCHR))){
mode = (mode_t)O_RDONLY;
- gpsd_report(LOG_INF, "opening read-only GPS data source at '%s'\n", session->gpsdata.gps_device);
+ gpsd_report(LOG_INF, "opening read-only GPS data source at '%s'\n", session->gpsdata.dev.path);
} else {
- gpsd_report(LOG_INF, "opening GPS data source at '%s'\n", session->gpsdata.gps_device);
+ gpsd_report(LOG_INF, "opening GPS data source at '%s'\n", session->gpsdata.dev.path);
}
/*@ +boolops +type @*/
- if ((session->gpsdata.gps_fd = open(session->gpsdata.gps_device, (int)(mode|O_NONBLOCK|O_NOCTTY))) == -1) {
+ if ((session->gpsdata.gps_fd = open(session->gpsdata.dev.path, (int)(mode|O_NONBLOCK|O_NOCTTY))) == -1) {
gpsd_report(LOG_ERROR, "device open failed: %s - retrying read-only\n", strerror(errno));
- if ((session->gpsdata.gps_fd = open(session->gpsdata.gps_device, O_RDONLY|O_NONBLOCK|O_NOCTTY)) == -1) {
+ if ((session->gpsdata.gps_fd = open(session->gpsdata.dev.path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) == -1) {
gpsd_report(LOG_ERROR, "read-only device open failed: %s\n", strerror(errno));
return -1;
}
@@ -329,13 +329,13 @@ bool gpsd_next_hunt_setting(struct gps_device_t *session)
session->packet.retry_counter = 0;
if (session->baudindex++ >= (unsigned int)(sizeof(rates)/sizeof(rates[0]))-1) {
session->baudindex = 0;
- if (session->gpsdata.stopbits++ >= 2)
+ if (session->gpsdata.dev.stopbits++ >= 2)
return false; /* hunt is over, no sync */
}
gpsd_set_speed(session,
rates[session->baudindex],
- (unsigned char)session->gpsdata.parity,
- session->gpsdata.stopbits);
+ (unsigned char)session->gpsdata.dev.parity,
+ session->gpsdata.dev.stopbits);
}
return true; /* keep hunting */
diff --git a/www/protocol-transition.txt b/www/protocol-transition.txt
index 4e910bfb..05bc7f32 100644
--- a/www/protocol-transition.txt
+++ b/www/protocol-transition.txt
@@ -256,3 +256,29 @@ protocol. Do not rely on it.
The old 'Z' and '$' commands, used by the developers for profiling,
have no equivalents. We'll implement them if we need them.
+
+== How the gps_data_t structure has changed ==
+
+The client libary's reporting structure, struct gpsdata_t, has a new
+substructure (struct device_t) named "dev" that groups together
+information about the device that shipped the last update to the
+client. The members of this structure replace several top-level
+struct gpsdata members in older versions.
+
+Most notably, the gps_device member has been replaced by dev.path.
+It is valid after every response with a device tag (DEVICE, TPV, SKY,
+AIS, RTCM2, RTCM3, CONFIGDEV).
+
+The top-level gps_id member is replaced by dev.subtype. This data
+should be considered valid only when DEVICEID_SET is on in the
+top-level set member.
+
+The dev members baudrate, parity, stopbits, cycle, mincycle, and
+driver_mode replace older top-level members. They should be
+considered valid only when DEVICE_SET is on in the top-level set
+member (note: this flag is not reliably set yet, work in progress).
+
+The top-level members ndevices and devicelist (used only on the client
+side) have been replaced by an array of struct device_t structures.
+Storage for pathnames is no longer dynamically allocated, but rather
+lives in a union with several other substructures.
diff --git a/xgps.c b/xgps.c
index 98ff109b..9c5a3f59 100644
--- a/xgps.c
+++ b/xgps.c
@@ -969,7 +969,7 @@ update_panel(struct gps_data_t *gpsdata, char *message,
XmTextFieldSetString(text_9, "n/a");
if (gpsdata->set & DEVICEID_SET) {
(void)strlcpy(s, "xgps: ", sizeof(s));
- (void)strlcpy(s+6, gpsdata->gps_id, sizeof(s)-6);
+ (void)strlcpy(s+6, gpsdata->dev.subtype, sizeof(s)-6);
set_title(s);
}
if (gpsdata->online == 0) {