diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2004-08-31 16:40:04 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2004-08-31 16:40:04 +0000 |
commit | 2681ebae3d3b50505a9026e4b760877460c62eee (patch) | |
tree | e9bd27670346214daece1ec8b8042e24a069193b | |
parent | d943d1aa8494ba21f17d9c7d7751f60ee93ff265 (diff) | |
download | gpsd-2681ebae3d3b50505a9026e4b760877460c62eee.tar.gz |
Attempt FV18 support.
-rw-r--r-- | HACKING | 3 | ||||
-rw-r--r-- | drivers.c | 28 | ||||
-rw-r--r-- | gpsd.h | 1 | ||||
-rw-r--r-- | gpsd.xml | 2 | ||||
-rw-r--r-- | libgpsd_core.c | 5 | ||||
-rw-r--r-- | serial.c | 15 |
6 files changed, 49 insertions, 5 deletions
@@ -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 @@ -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 * **************************************************************************/ @@ -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, ...); @@ -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; } } @@ -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) { |