summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver_proto.c1
-rw-r--r--drivers.c8
-rw-r--r--evermore.c1
-rw-r--r--garmin.c2
-rw-r--r--gpsd.h1
-rw-r--r--italk.c1
-rw-r--r--serial.c4
-rw-r--r--sirf.c1
-rw-r--r--truenorth.c108
-rw-r--r--tsip.c1
10 files changed, 38 insertions, 90 deletions
diff --git a/driver_proto.c b/driver_proto.c
index 3e5c89e3..e89a2e99 100644
--- a/driver_proto.c
+++ b/driver_proto.c
@@ -118,6 +118,7 @@ struct gps_type_t proto_binary =
.trigger = NULL, /* recognize the type */
.channels = 12, /* used for dumping binary packets */
.probe = NULL, /* no probe */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.initializer = proto_initializer,/* initialize the device */
.get_packet = packet_get, /* use generic packet getter */
.parse_packet = proto_parse_input,/* parse message packets */
diff --git a/drivers.c b/drivers.c
index 0f66dd9c..573a4222 100644
--- a/drivers.c
+++ b/drivers.c
@@ -128,6 +128,7 @@ static struct gps_type_t nmea = {
.typename = "Generic NMEA", /* full name of type */
.trigger = NULL, /* it's the default */
.channels = 12, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = nmea_initializer, /* probe for special types */
.get_packet = packet_get, /* use generic packet getter */
@@ -176,6 +177,7 @@ static struct gps_type_t garmin = {
.typename = "Garmin Serial", /* full name of type */
.trigger = "$PGRMC", /* Garmin private */
.channels = 12, /* not used by this driver */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = garmin_nmea_initializer,/* probe for special types */
.get_packet = packet_get, /* use generic packet getter */
@@ -200,6 +202,7 @@ static struct gps_type_t fv18 = {
.typename = "San Jose Navigation FV18", /* full name of type */
.trigger = FV18_PROBE, /* FV18s should echo the probe */
.channels = 12, /* not used by this driver */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* mo probe */
.initializer = NULL, /* to be sent unconditionally */
.get_packet = packet_get, /* how to get a packet */
@@ -266,6 +269,7 @@ static struct gps_type_t sirf_nmea = {
.trigger = NULL, /* let the binary driver have it */
#endif /* SIRF_ENABLE */
.channels = 12, /* not used by the NMEA parser */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = sirf_initializer, /* turn off debugging messages */
.get_packet = packet_get, /* how to get a packet */
@@ -308,6 +312,7 @@ static struct gps_type_t tripmate = {
.typename = "Delorme TripMate", /* full name of type */
.trigger ="ASTRAL", /* tells us to switch */
.channels = 12, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup before hunt */
.probe = NULL, /* no probe */
.initializer = tripmate_initializer, /* send unconfitionally */
.get_packet = packet_get, /* how to get a packet */
@@ -357,6 +362,7 @@ static struct gps_type_t earthmate = {
.typename = "Delorme EarthMate (pre-2003, Zodiac chipset)",
.trigger = "EARTHA", /* Earthmate trigger string */
.channels = 12, /* not used by NMEA parser */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = earthmate_initializer, /* switch us to Zodiac mode */
.get_packet = packet_get, /* how to get a packet */
@@ -481,6 +487,7 @@ static struct gps_type_t itrax = {
.typename = "iTrax", /* full name of type */
.trigger = "$PFST,OK", /* tells us to switch to Itrax */
.channels = 12, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = itrax_initializer, /* initialize */
.get_packet = packet_get, /* how to get a packet */
@@ -517,6 +524,7 @@ static struct gps_type_t rtcm104 = {
.typename = "RTCM104", /* full name of type */
.trigger = NULL, /* no recognition string */
.channels = 0, /* not used */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = NULL, /* no initializer */
.get_packet = packet_get, /* how to get a packet */
diff --git a/evermore.c b/evermore.c
index 69b41874..b285da50 100644
--- a/evermore.c
+++ b/evermore.c
@@ -653,6 +653,7 @@ struct gps_type_t evermore_binary =
.typename = "EverMore binary", /* full name of type */
.trigger = "\x10\x02\x04\x38\x8d\xc5\x10\x03", /* recognize the type */
.channels = EVERMORE_CHANNELS, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = evermore_initializer, /* initialize the device */
.get_packet = packet_get, /* use generic one */
diff --git a/garmin.c b/garmin.c
index 26598c6f..ef6f2913 100644
--- a/garmin.c
+++ b/garmin.c
@@ -1071,6 +1071,7 @@ struct gps_type_t garmin_usb_binary =
.typename = "Garmin USB binary", /* full name of type */
.trigger = NULL, /* no trigger, it has a probe */
.channels = GARMIN_CHANNELS, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = garmin_probe, /* how to detect at startup time */
.initializer = garmin_init, /* initialize the device */
.get_packet = garmin_get_packet,/* how to grab a packet */
@@ -1089,6 +1090,7 @@ struct gps_type_t garmin_ser_binary =
.typename = "Garmin Serial binary", /* full name of type */
.trigger = NULL, /* no trigger, it has a probe */
.channels = GARMIN_CHANNELS, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* how to detect at startup time */
.initializer = NULL, /* initialize the device */
.get_packet = packet_get, /* how to grab a packet */
diff --git a/gpsd.h b/gpsd.h
index d5d72d92..0136d1e2 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -75,6 +75,7 @@ struct gps_type_t {
/*@observer@*//*@null@*/char *trigger;
int channels;
/*@null@*/bool (*probe)(struct gps_device_t *session);
+ /*@null@*/bool (*wakeup)(struct gps_device_t *session);
/*@null@*/void (*initializer)(struct gps_device_t *session);
/*@null@*/ssize_t (*get_packet)(struct gps_device_t *session);
/*@null@*/gps_mask_t (*parse_packet)(struct gps_device_t *session);
diff --git a/italk.c b/italk.c
index 6a30f72b..daf08ea5 100644
--- a/italk.c
+++ b/italk.c
@@ -116,6 +116,7 @@ struct gps_type_t italk_binary =
.typename = "iTalk binary", /* full name of type */
.trigger = NULL, /* recognize the type */
.channels = 12, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = italk_initializer,/* initialize the device */
.get_packet = packet_get, /* use generic packet grabber */
diff --git a/serial.c b/serial.c
index fae63d0c..c041d23f 100644
--- a/serial.c
+++ b/serial.c
@@ -223,6 +223,8 @@ 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;
}
@@ -269,6 +271,8 @@ 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 */
diff --git a/sirf.c b/sirf.c
index cca822fd..be92dd99 100644
--- a/sirf.c
+++ b/sirf.c
@@ -762,6 +762,7 @@ struct gps_type_t sirf_binary =
.typename = "SiRF binary", /* full name of type */
.trigger = "$Ack Input105.", /* expected response to SiRF PSRF105 */
.channels = SIRF_CHANNELS, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = sirfbin_initializer,/* initialize the device */
.get_packet = packet_get, /* use the generic packet getter */
diff --git a/truenorth.c b/truenorth.c
index c207542f..853073c5 100644
--- a/truenorth.c
+++ b/truenorth.c
@@ -29,10 +29,6 @@
#ifdef TNT_ENABLE
-enum {
-#include "packet_states.h"
-};
-
static void tnt_add_checksum(char *sentence)
{
unsigned char sum = '\0';
@@ -73,101 +69,33 @@ static int tnt_send(int fd, const char *fmt, ... )
}
}
-#define TNT_SNIFF_RETRIES 100
/*
- * The True North compass won't start talking
- * unless you ask it to. So to identify it we
- * need to query for it's ID string.
+ * The True North compass won't start talking unless you ask it to. To
+ * wake it up, we query for its ID string just after each speed change
+ * in the autobaud hunt. Then we send codes to start the flow of data.
*/
-static int tnt_packet_sniff(struct gps_device_t *session)
-{
- unsigned int n, count = 0;
-
- gpsd_report(5, "tnt_packet_sniff begins\n");
- for (n = 0; n < TNT_SNIFF_RETRIES; n++)
- {
- count = 0;
- (void)tnt_send(session->gpsdata.gps_fd, "@X?");
- if (ioctl(session->gpsdata.gps_fd, FIONREAD, &count) < 0)
- return BAD_PACKET;
- if (count == 0) {
- //int delay = 10000000000.0 / session->gpsdata.baudrate;
- //gpsd_report(5, "usleep(%d)\n", delay);
- //usleep(delay);
- gpsd_report(5, "sleep(1)\n");
- (void)sleep(1);
- } else if (packet_get(session) >= 0) {
- if((session->packet_type == NMEA_PACKET)&&(session->packet_state == NMEA_RECOGNIZED))
- {
- gpsd_report(5, "tnt_packet_sniff returns %d\n",session->packet_type);
- return session->packet_type;
- }
- }
- }
-
- gpsd_report(5, "tnt_packet_sniff found no packet\n");
- return BAD_PACKET;
-}
-
-
-static void tnt_initializer(struct gps_device_t *session)
-{
- // Send codes to start the flow of data
- //tnt_send(session->gpsdata.gps_fd, "@BA?"); // Query current rate
- //tnt_send(session->gpsdata.gps_fd, "@BA=8"); // Start HTM packet at 1Hz
- /*
- * Sending this twice seems to make it more reliable!!
- * I think it gets the input on the unit synced up.
- */
- (void)tnt_send(session->gpsdata.gps_fd, "@BA=15"); // Start HTM packet at 1200 per minute
- (void)tnt_send(session->gpsdata.gps_fd, "@BA=15"); // Start HTM packet at 1200 per minute
-}
-
-static bool tnt_probe(struct gps_device_t *session)
+static int tnt_wakeup(struct gps_device_t *session)
{
- unsigned int *ip;
-#ifdef FIXED_PORT_SPEED
- /* just the one fixed port speed... */
- static unsigned int rates[] = {FIXED_PORT_SPEED};
-#else /* FIXED_PORT_SPEED not defined */
- /* The supported baud rates */
- static unsigned int rates[] = {38400, 19200, 2400, 4800, 9600 };
-#endif /* FIXED_PORT_SPEED defined */
-
- gpsd_report(1, "Probing TrueNorth Compass\n");
-
- /*
- * Only block until we get at least one character, whatever the
- * third arg of read(2) says.
- */
- /*@ ignore @*/
- memset(session->ttyset.c_cc,0,sizeof(session->ttyset.c_cc));
- session->ttyset.c_cc[VMIN] = 1;
- /*@ end @*/
-
- session->ttyset.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
- session->ttyset.c_cflag |= CREAD | CLOCAL;
- session->ttyset.c_iflag = session->ttyset.c_oflag = session->ttyset.c_lflag = (tcflag_t) 0;
-
- session->baudindex = 0;
- for (ip = rates; ip < rates + sizeof(rates)/sizeof(rates[0]); ip++)
- if (ip == rates || *ip != rates[0])
- {
- gpsd_report(1, "hunting at speed %d\n", *ip);
- gpsd_set_speed(session, *ip, 'N',1);
- if (tnt_packet_sniff(session) != BAD_PACKET)
- return true;
- }
- return false;
+ (void)tnt_send(session->gpsdata.gps_fd, "@X?");
+ //tnt_send(session->gpsdata.gps_fd, "@BA?"); // Query current rate
+ //tnt_send(session->gpsdata.gps_fd, "@BA=8"); // Start HTM packet at 1Hz
+ /*
+ * Sending this twice seems to make it more reliable!!
+ * I think it gets the input on the unit synced up.
+ * The intent is to start HTM packet reporting at 1200 per minute.
+ */
+ (void)tnt_send(session->gpsdata.gps_fd, "@BA=15");
+ (void)tnt_send(session->gpsdata.gps_fd, "@BA=15");
}
struct gps_type_t trueNorth = {
.typename = "True North", /* full name of type */
.trigger = " TNT1500",
.channels = 0, /* not an actual GPS at all */
- .probe = tnt_probe, /* probe by sending ID query */
- .initializer = tnt_initializer, /* probe for True North Digital Compass */
- .get_packet = packet_get, /* how to get a packet */
+ .wakeup = tnt_wakeup, /* wakeup by sending ID query */
+ .probe = NULL, /* no probe */
+ .initializer = NULL, /* no initializer */
+ .get_packet = packet_get, /* how to get a packet */
.parse_packet = nmea_parse_input, /* how to interpret a packet */
.rtcm_writer = NULL, /* Don't send */
.speed_switcher = NULL, /* no speed switcher */
diff --git a/tsip.c b/tsip.c
index eec606bd..9351698f 100644
--- a/tsip.c
+++ b/tsip.c
@@ -699,6 +699,7 @@ struct gps_type_t tsip_binary =
.typename = "Trimble TSIP", /* full name of type */
.trigger = NULL, /* no trigger */
.channels = TSIP_CHANNELS, /* consumer-grade GPS */
+ .wakeup = NULL, /* no wakeup to be done before hunt */
.probe = NULL, /* no probe */
.initializer = tsip_initializer, /* initialization */
.get_packet = packet_get, /* use the generic packet getter */