summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-14 16:58:46 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-14 16:58:46 -0500
commitc47d84f2bed4cd35189376b5cadf8fc057f4c5ee (patch)
treee14fb1842cba3c4b9c3146d556aebff1f2fba879 /gpsmon.c
parentf4717ee30534c80ab45bcb0c66cb788da72fd9d5 (diff)
downloadgpsd-c47d84f2bed4cd35189376b5cadf8fc057f4c5ee.tar.gz
In gpsmon, more simplification. All regression test pass, PPS is live.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gpsmon.c b/gpsmon.c
index 202c98fa..977f133e 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -121,7 +121,6 @@ static const struct monitor_object_t *monitor_objects[] = {
};
static const struct monitor_object_t **active;
-static const struct gps_type_t *active_type;
static const struct gps_type_t *fallback;
/*@ +nullassign @*/
@@ -462,7 +461,7 @@ static void select_packet_monitor(struct gps_device_t *device)
* within gpsd_multipoll() before this hook is called.
*/
if (device->packet.type != last_type) {
- active_type = device->device_type;
+ const struct gps_type_t *active_type = device->device_type;
if (device->packet.type == NMEA_PACKET
&& ((device->device_type->flags & DRIVER_STICKY) != 0))
active_type = &driver_nmea0183;
@@ -621,7 +620,7 @@ bool monitor_control_send( /*@in@*/ unsigned char *buf, size_t len)
ssize_t st;
context.readonly = false;
- st = active_type->control_send(&session, (char *)buf, len);
+ st = session.device_type->control_send(&session, (char *)buf, len);
context.readonly = true;
return (st != -1);
}
@@ -717,13 +716,13 @@ static bool do_command(const char *line)
switch (line[0]) {
#ifdef RECONFIGURE_ENABLE
case 'c': /* change cycle time */
- if (active_type == NULL)
+ if (session.device_type == NULL)
complain("No device defined yet");
else if (!serial)
complain("Only available in low-level mode.");
else {
double rate = strtod(arg, NULL);
- const struct gps_type_t *switcher = active_type;
+ const struct gps_type_t *switcher = session.device_type;
if (fallback != NULL && fallback->rate_switcher != NULL)
switcher = fallback;
@@ -744,7 +743,7 @@ static bool do_command(const char *line)
#endif /* RECONFIGURE_ENABLE */
break;
case 'i': /* start probing for subtype */
- if (active_type == NULL)
+ if (session.device_type == NULL)
complain("No GPS type detected.");
else if (!serial)
complain("Only available in low-level mode.");
@@ -786,12 +785,12 @@ static bool do_command(const char *line)
/* *INDENT-ON* */
} else
v = (unsigned)atoi(line + 1);
- if (active_type == NULL)
+ if (session.device_type == NULL)
complain("No device defined yet");
else if (!serial)
complain("Only available in low-level mode.");
else {
- const struct gps_type_t *switcher = active_type;
+ const struct gps_type_t *switcher = session.device_type;
if (fallback != NULL && fallback->mode_switcher != NULL)
switcher = fallback;
@@ -815,7 +814,7 @@ static bool do_command(const char *line)
#ifdef RECONFIGURE_ENABLE
case 's': /* change speed */
- if (active_type == NULL)
+ if (session.device_type == NULL)
complain("No device defined yet");
else if (!serial)
complain("Only available in low-level mode.");
@@ -825,7 +824,7 @@ static bool do_command(const char *line)
unsigned int stopbits =
(unsigned int)session.gpsdata.dev.stopbits;
char *modespec;
- const struct gps_type_t *switcher = active_type;
+ const struct gps_type_t *switcher = session.device_type;
if (fallback != NULL && fallback->speed_switcher != NULL)
switcher = fallback;
@@ -918,7 +917,7 @@ static bool do_command(const char *line)
#ifdef CONTROLSEND_ENABLE
case 'x': /* send control packet */
- if (active_type == NULL)
+ if (session.device_type == NULL)
complain("No device defined yet");
else if (!serial)
complain("Only available in low-level mode.");
@@ -927,9 +926,9 @@ static bool do_command(const char *line)
int st = gpsd_hexpack(arg, (char *)buf, strlen(arg));
if (st < 0)
complain("Invalid hex string (error %d)", st);
- else if (active_type->control_send == NULL)
+ else if (session.device_type->control_send == NULL)
complain("Device type %s has no control-send method.",
- active_type->type_name);
+ session.device_type->type_name);
else if (!monitor_control_send(buf, (size_t) st))
complain("Control send failed.");
/*@ +compdef @*/