diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-10-26 16:16:21 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-10-26 16:16:21 +0000 |
commit | 75aa67955267e9d3f602f7b57e1405984f81445a (patch) | |
tree | 2755c1bdca38f6d97f973d5dd8e4684a4b08d4c6 /truenorth.c | |
parent | d74df4d29521580f858e81f62a805798ca009d95 (diff) | |
download | gpsd-75aa67955267e9d3f602f7b57e1405984f81445a.tar.gz |
Eliminate duplicative code in the Truenorth driver.
Make the wakeup capability a function returning void.
Diffstat (limited to 'truenorth.c')
-rw-r--r-- | truenorth.c | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/truenorth.c b/truenorth.c index 853073c5..f6658348 100644 --- a/truenorth.c +++ b/truenorth.c @@ -9,10 +9,9 @@ * measurements it provides a compass heading using NMEA * formatted output strings. I threw this into gpsd since it * already has convienient NMEA parsing support. Also because - * I use the compass to suplement the heading provided by + * I use the compass to supplement the heading provided by * another gps unit. A gps heading is unreliable at slow * speed or no speed. - * */ #include <stdlib.h> @@ -28,53 +27,12 @@ #include "gpsd.h" #ifdef TNT_ENABLE - -static void tnt_add_checksum(char *sentence) -{ - unsigned char sum = '\0'; - char c, *p = sentence; - - if (*p == '@') { - p++; - } else { - gpsd_report(1, "Bad TNT sentence: '%s'\n", sentence); - } - while ( ((c = *p) != '*') && (c != '\0')) { - sum ^= c; - p++; - } - *p++ = '*'; - /*@i@*/snprintf(p, 4, "%02X\r\n", sum); -} - -static int tnt_send(int fd, const char *fmt, ... ) -{ - int status; - char buf[BUFSIZ]; - va_list ap; - - va_start(ap, fmt) ; - (void)vsnprintf(buf, sizeof(buf)-5, fmt, ap); - va_end(ap); - strlcat(buf, "*", BUFSIZ); - tnt_add_checksum(buf); - status = (int)write(fd, buf, strlen(buf)); - tcdrain(fd); - if (status == (int)strlen(buf)) { - gpsd_report(2, "=> GPS: %s\n", buf); - return status; - } else { - gpsd_report(2, "=> GPS: %s FAILED\n", buf); - return -1; - } -} - /* * 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_wakeup(struct gps_device_t *session) +static void tnt_wakeup(struct gps_device_t *session) { (void)tnt_send(session->gpsdata.gps_fd, "@X?"); //tnt_send(session->gpsdata.gps_fd, "@BA?"); // Query current rate @@ -84,8 +42,8 @@ static int tnt_wakeup(struct gps_device_t *session) * 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"); + (void)nmea_send(session->gpsdata.gps_fd, "@BA=15"); + (void)nmea_send(session->gpsdata.gps_fd, "@BA=15"); } struct gps_type_t trueNorth = { |