summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2004-08-31 16:40:04 +0000
committerEric S. Raymond <esr@thyrsus.com>2004-08-31 16:40:04 +0000
commit2681ebae3d3b50505a9026e4b760877460c62eee (patch)
treee9bd27670346214daece1ec8b8042e24a069193b
parentd943d1aa8494ba21f17d9c7d7751f60ee93ff265 (diff)
downloadgpsd-2681ebae3d3b50505a9026e4b760877460c62eee.tar.gz
Attempt FV18 support.
-rw-r--r--HACKING3
-rw-r--r--drivers.c28
-rw-r--r--gpsd.h1
-rw-r--r--gpsd.xml2
-rw-r--r--libgpsd_core.c5
-rw-r--r--serial.c15
6 files changed, 49 insertions, 5 deletions
diff --git a/HACKING b/HACKING
index 32ccb533..ecb8e96c 100644
--- a/HACKING
+++ b/HACKING
@@ -24,6 +24,9 @@ watches for. When that string is recognized at the start of a
line, the interpreter switches to its driver. The new driver
initializer method is called immediately.
+(The initializer method is called unconditionally each time the device
+is opened, if there is no trigger string.)
+
The trickiest part of the code is the handling of input sources in gpsd.c
itself. It had to tolerate clients connecting and disconnecting at random
times, and the GPS being unplugged and replugged, without leaking file
diff --git a/drivers.c b/drivers.c
index e4e4633c..9d6480a7 100644
--- a/drivers.c
+++ b/drivers.c
@@ -114,6 +114,34 @@ struct gps_type_t nmea =
/**************************************************************************
*
+ * FV18 -- doesn't send GPGSAs, uses 7N2
+ *
+ **************************************************************************/
+
+void fv18_initializer(struct gps_session_t *session)
+{
+ /* FV18 sends 1 start bit, 8 bits, 1 stop bit, looking like 7N2 */
+ gpsd_set_7N2();
+ /* tell it to send GSAs so we'll know if 3D is accurate */
+ write(session->fdout, "$PFEC,GPint,GSA01,DTM00,ZDA00,RMC01,GLL01*39", 18);
+}
+
+struct gps_type_t fv18 =
+{
+ 'f', /* select explicitly with -T f */
+ "FV18", /* full name of type */
+ NULL, /* no recognition string */
+ fv18_initializer, /* to be sent unconditionally */
+ nmea_handle_input, /* read text sentence */
+ nmea_write_rtcm, /* write RTCM data straight */
+ NULL, /* no wrapup */
+ 4800, /* default speed to connect at */
+ 1, /* updates every second */
+};
+
+
+/**************************************************************************
+ *
* TripMate -- extended NMEA, gets faster fix when primed with lat/long/time
*
**************************************************************************/
diff --git a/gpsd.h b/gpsd.h
index e90e0937..72f1a921 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -88,6 +88,7 @@ extern int gpsd_activate(struct gps_session_t *session);
extern void gpsd_deactivate(struct gps_session_t *session);
extern int gpsd_poll(struct gps_session_t *session);
extern void gpsd_wrap(struct gps_session_t *session);
+extern int gpsd_set_7N2(void);
/* caller must supply this */
void gpscli_report(int d, const char *fmt, ...);
diff --git a/gpsd.xml b/gpsd.xml
index cc13258a..ce4e17fd 100644
--- a/gpsd.xml
+++ b/gpsd.xml
@@ -73,7 +73,7 @@ station.</para>
<listitem>
<para>Set GPS type, usually not necessary because most GPSes now speak
the standard NMEA 0183 protocol: possible values are n=NMEA generic,
-t=TripMate, e=EarthMate, l=logfile.</para>
+t=TripMate, e=EarthMate, f=FV18, l=logfile.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 4414b6f2..f64a2675 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -48,7 +48,6 @@ struct gps_session_t *gpsd_init(char devicetype, char *dgpsserver)
session->device_type = devtype;
session->baudrate = devtype->baudrate;
}
-
session->dsock = -1;
if (dgpsserver) {
@@ -125,6 +124,10 @@ int gpsd_activate(struct gps_session_t *session)
session->fdin = input;
session->fdout = input;
gpscli_report(1, "gpsd_activate: opened GPS (%d)\n", input);
+
+ /* if there is an initializer and no trigger string, invoke it */
+ if (session->device_type->initializer && !session->device_type->trigger)
+ session->device_type->initializer(session);
return input;
}
}
diff --git a/serial.c b/serial.c
index 2b21c1a3..10c6796e 100644
--- a/serial.c
+++ b/serial.c
@@ -51,13 +51,13 @@ int gpsd_open(char *device_name, int device_speed)
ttyfd = open(device_name, O_RDWR | O_NONBLOCK);
if (ttyfd < 0)
- return (-1);
+ return -1;
if (isatty(ttyfd)) {
gpscli_report(1, "setting speed %d, 8 bits, no parity\n", device_speed);
/* Save original terminal parameters */
if (tcgetattr(ttyfd,&ttyset_old) != 0)
- return (-1);
+ return -1;
memcpy(&ttyset, &ttyset_old, sizeof(ttyset));
@@ -70,11 +70,20 @@ int gpsd_open(char *device_name, int device_speed)
ttyset.c_iflag = ttyset.c_oflag = ttyset.c_lflag = (tcflag_t) 0;
ttyset.c_oflag = (ONLCR);
if (tcsetattr(ttyfd, TCSANOW, &ttyset) != 0)
- return (-1);
+ return -1;
}
return ttyfd;
}
+int gpsd_set_7N2(void)
+{
+ ttyset.c_cflag &=~ CSIZE & CS8;
+ ttyset.c_cflag |= CSIZE & CS7;
+ if (tcsetattr(ttyfd, TCSANOW, &ttyset) != 0)
+ return -1;
+ return 0;
+}
+
void gpsd_close()
{
if (ttyfd != -1) {