summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2004-08-20 16:24:52 +0000
committerEric S. Raymond <esr@thyrsus.com>2004-08-20 16:24:52 +0000
commit9986dac88e321bd840659a7c4c9eb129cfef0798 (patch)
tree2c6d6a855fcc8e6b5416e691ac133b772dfbcf5d
parentc3f7e6fc4e91b9ff0fc6ed9ba3967e8eec04164c (diff)
downloadgpsd-9986dac88e321bd840659a7c4c9eb129cfef0798.tar.gz
Second half of file name change, and some function name changes.
-rw-r--r--drivers.c4
-rw-r--r--earthmate.c26
-rw-r--r--gpsd.h6
-rw-r--r--nmea.h6
-rw-r--r--nmea_parse.c31
5 files changed, 42 insertions, 31 deletions
diff --git a/drivers.c b/drivers.c
index 8e93a4d5..ed9a98ab 100644
--- a/drivers.c
+++ b/drivers.c
@@ -52,7 +52,7 @@ void gps_NMEA_handle_message(struct gpsd_t *session, char *sentence)
gpscli_report(2, "<= GPS: %s\n", sentence);
if (*sentence == '$')
{
- if (gps_process_NMEA_message(sentence + 1, &session->gNMEAdata) < 0)
+ if (nmea_parse(sentence + 1, &session->gNMEAdata) < 0)
gpscli_report(2, "unknown sentence: \"%s\"\n", sentence);
}
else
@@ -145,7 +145,7 @@ void tripmate_initializer(struct gpsd_t *session)
session->initpos.longitude, session->initpos.lond,
tm->tm_hour, tm->tm_min, tm->tm_sec,
tm->tm_mday, tm->tm_mon + 1, tm->tm_year);
- gps_add_checksum(buf + 1); /* add c-sum + cr/lf */
+ nmea_add_checksum(buf + 1); /* add c-sum + cr/lf */
if (session->fdout != -1) {
write(session->fdout, buf, strlen(buf));
gpscli_report(1, "=> GPS: %s", buf);
diff --git a/earthmate.c b/earthmate.c
index 60b5920f..c856e7aa 100644
--- a/earthmate.c
+++ b/earthmate.c
@@ -41,7 +41,7 @@ struct header {
static void analyze(struct gpsd_t *session, struct header *, unsigned short *);
-static unsigned short em_gps_checksum(unsigned short *w, int n)
+static unsigned short em_nmea_checksum(unsigned short *w, int n)
{
unsigned short csum = 0;
@@ -52,8 +52,8 @@ static unsigned short em_gps_checksum(unsigned short *w, int n)
}
/* em_spew - Takes a message type, an array of data words, and a length
- for the array, and prepends a 5 word header (including gps_checksum).
- The data words are expected to be gps_checksummed */
+ for the array, and prepends a 5 word header (including nmea_checksum).
+ The data words are expected to be nmea_checksummed */
#if defined (WORDS_BIGENDIAN)
@@ -89,7 +89,7 @@ static void em_spew(struct gpsd_t *session, int type, unsigned short *dat, int d
h.sync = 0x81ff;
h.id = type;
h.ndata = dlen - 1;
- h.csum = em_gps_checksum((unsigned short *) &h, 4);
+ h.csum = em_nmea_checksum((unsigned short *) &h, 4);
if (session->fdout != -1) {
end_write(session->fdout, &h, sizeof(h));
@@ -143,7 +143,7 @@ static void em_init(struct gpsd_t *session)
*(long *) (data + 13) = putlong(session->initpos.longitude, (session->initpos.lond == 'W') ? 1 : 0);
data[15] = data[16] = 0;
data[17] = data[18] = data[19] = data[20] = 0;
- data[21] = em_gps_checksum(data, 21);
+ data[21] = em_nmea_checksum(data, 21);
em_spew(session, 1200, data, 22);
}
@@ -162,7 +162,7 @@ static void send_rtcm(struct gpsd_t *session,
data[0] = sn; /* sequence number */
memcpy(&data[1], rtcmbuf, rtcmbytes);
- data[n] = em_gps_checksum(data, n);
+ data[n] = em_nmea_checksum(data, n);
em_spew(session, 1351, data, n+1);
}
@@ -377,7 +377,7 @@ static void analyze(struct gpsd_t *session,
char *bufp2;
int i = 0, j = 0, nmea = 0;
- if (p[h->ndata] == em_gps_checksum(p, h->ndata)) {
+ if (p[h->ndata] == em_nmea_checksum(p, h->ndata)) {
if (session->debug > 5)
gpscli_report(1, "id %d\n", h->id);
switch (h->id) {
@@ -394,7 +394,7 @@ static void analyze(struct gpsd_t *session,
((session->gNMEAdata.longitude > 0) ? 'E' : 'W'),
session->gNMEAdata.mode, session->gNMEAdata.satellites_used, session->gNMEAdata.hdop,
session->gNMEAdata.altitude, 'M', session->gNMEAdata.separation, 'M', "", "");
- gps_add_checksum(bufp + 1);
+ nmea_add_checksum(bufp + 1);
bufp = bufp + strlen(bufp);
}
sprintf(bufp,
@@ -407,7 +407,7 @@ static void analyze(struct gpsd_t *session,
session->gNMEAdata.track, session->gNMEAdata.day, session->gNMEAdata.month,
(session->gNMEAdata.year % 100), session->gNMEAdata.mag_var,
(session->gNMEAdata.mag_var > 0) ? 'E' : 'W');
- gps_add_checksum(bufp + 1);
+ nmea_add_checksum(bufp + 1);
nmea = 1000;
break;
case 1002:
@@ -429,7 +429,7 @@ static void analyze(struct gpsd_t *session,
bufp = bufp + strlen(bufp);
sprintf(bufp, "%.2f,%.2f,%.2f*", session->gNMEAdata.pdop, session->gNMEAdata.hdop,
session->gNMEAdata.vdop);
- gps_add_checksum(bufp2 + 1);
+ nmea_add_checksum(bufp2 + 1);
bufp2 = bufp = bufp + strlen(bufp);
#ifdef PROCESS_PRWIZCH
sprintf(bufp, "$PRWIZCH");
@@ -440,7 +440,7 @@ static void analyze(struct gpsd_t *session,
}
sprintf(bufp, "*");
bufp = bufp + strlen(bufp);
- gps_add_checksum(bufp2 + 1);
+ nmea_add_checksum(bufp2 + 1);
nmea = 1002;
#endif /* PROCESS_PRWIZCH */
break;
@@ -461,7 +461,7 @@ static void analyze(struct gpsd_t *session,
bufp += strlen(bufp);
if (i % 4 == 3) {
sprintf(bufp, "*");
- gps_add_checksum(bufp2 + 1);
+ nmea_add_checksum(bufp2 + 1);
bufp += strlen(bufp);
bufp2 = bufp;
}
@@ -546,7 +546,7 @@ static void em_eat(struct gpsd_t *session, unsigned char c)
case EM_HUNT_CS:
if (!(byte = putword(&(h.csum), c, byte))) {
- if (h.csum == em_gps_checksum((unsigned short *) &h, 4)) {
+ if (h.csum == em_nmea_checksum((unsigned short *) &h, 4)) {
state = EM_HUNT_DATA;
data = (unsigned short *) malloc((h.ndata + 1) * 2);
words = 0;
diff --git a/gpsd.h b/gpsd.h
index 200f808a..705407b3 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -64,10 +64,10 @@ extern struct gps_type_t earthmate_b;
extern struct gps_type_t logfile;
/* GPS library internal prototypes */
-extern int gps_process_NMEA_message(char *sentence, struct gps_data *outdata);
+extern int nmea_parse(char *sentence, struct gps_data *outdata);
extern void gps_NMEA_handle_message(struct gpsd_t *session, char *sentence);
-extern void gps_add_checksum(char *sentence);
-extern short gps_checksum(char *sentence);
+extern void nmea_add_checksum(char *sentence);
+extern short nmea_checksum(char *sentence);
extern int gps_open(char *device_name, int device_speed);
extern void gps_close();
extern int netlib_passiveTCP(char *service, int qlen);
diff --git a/nmea.h b/nmea.h
index 5e19fac2..6780afa2 100644
--- a/nmea.h
+++ b/nmea.h
@@ -10,7 +10,7 @@
#define PMGNST "PMGNST"
/* prototypes */
-extern int gps_process_NMEA_message(char *sentence, struct gps_data *outdata);
+extern int nmea_parse(char *sentence, struct gps_data *outdata);
extern void gps_NMEA_handle_message(char *sentence);
-extern void gps_add_checksum(char *sentence);
-extern short gps_checksum(char *sentence);
+extern void nmea_add_checksum(char *sentence);
+extern short nmea_checksum(char *sentence);
diff --git a/nmea_parse.c b/nmea_parse.c
index dc596a52..7343a284 100644
--- a/nmea_parse.c
+++ b/nmea_parse.c
@@ -7,7 +7,11 @@
#include "gps.h"
#include "gpsd.h"
-/* ----------------------------------------------------------------------- */
+/**************************************************************************
+ *
+ * Parser helpers begin here
+ *
+ **************************************************************************/
/* field() returns a string containing the nth comma delimited
field from sentence string
@@ -39,7 +43,6 @@ static void do_lat_lon(char *sentence, int begin, struct gps_data *out)
char str[20], *p;
int updated = 0;
-
if (*(p = field(sentence, begin + 0)) != '\0') {
strncpy(str, p, 20);
sscanf(p, "%lf", &lat);
@@ -103,7 +106,11 @@ static int update_field_f(char *sentence, int fld, double *dest)
return changed;
}
-/* ----------------------------------------------------------------------- */
+/**************************************************************************
+ *
+ * NMEA sentence handling begin here
+ *
+ **************************************************************************/
/*
The time field in the GPRMC sentence is in the format hhmmss;
@@ -128,7 +135,7 @@ static void processGPRMC(char *sentence, struct gps_data *out)
054.7 Course Made Good, True
191194 Date of fix 19 November 1994
020.3,E Magnetic variation 20.3 deg East
- *68 mandatory gps_checksum
+ *68 mandatory nmea_checksum
*/
char utc[20], ddmmyy[10], hhmmss[10];
@@ -447,7 +454,7 @@ static void processPMGNST(char *sentence, struct gps_data *out)
05.0 time left on the gps battery in hours
+03327 numbers change (freq. compensation?)
00 PRN number receiving current focus
- *40 gps_checksum
+ *40 nmea_checksum
*/
int tmp1, newstatus, newmode;
@@ -500,9 +507,13 @@ static void processPRWIZCH(char *sentence, struct gps_data *out)
}
#endif /* PROCESS_PRWIZCH */
-/* ----------------------------------------------------------------------- */
+/**************************************************************************
+ *
+ * Entry points begin here
+ *
+ **************************************************************************/
-short gps_checksum(char *sentence)
+short nmea_checksum(char *sentence)
{
unsigned char sum = '\0';
char c, *p = sentence, csum[3];
@@ -514,7 +525,7 @@ short gps_checksum(char *sentence)
return (strncmp(csum, p, 2) == 0);
}
-void gps_add_checksum(char *sentence)
+void nmea_add_checksum(char *sentence)
{
unsigned char sum = '\0';
char c, *p = sentence;
@@ -525,9 +536,9 @@ void gps_add_checksum(char *sentence)
sprintf(p, "%02X\r\n", sum);
}
-int gps_process_NMEA_message(char *sentence, struct gps_data *outdata)
+int nmea_parse(char *sentence, struct gps_data *outdata)
{
- if (gps_checksum(sentence)) {
+ if (nmea_checksum(sentence)) {
if (strncmp(GPRMC, sentence, 5) == 0) {
processGPRMC(sentence, outdata);
} else if (strncmp(GPGGA, sentence, 5) == 0) {