summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpsd.c12
-rw-r--r--gpsd.h26
-rw-r--r--nmea_parse.c14
3 files changed, 20 insertions, 32 deletions
diff --git a/gpsd.c b/gpsd.c
index d32d0bac..e9a7fb27 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -354,17 +354,17 @@ static void raw_hook(char *sentence)
/* some listeners may be in watcher mode */
if (FD_ISSET(fd, &watcher_fds)) {
#define PUBLISH(fd, cmds) handle_request(fd, cmds, sizeof(cmds)-1)
- if (strncmp(GPRMC, sentence, sizeof(GPRMC)-1) == 0) {
+ if (PREFIX("$GPRMC", sentence)) {
PUBLISH(fd, "pdtvs");
- } else if (strncmp(GPGGA, sentence, sizeof(GPGGA)-1) == 0) {
+ } else if (PREFIX("$GPGGA", sentence)) {
PUBLISH(fd, "pdas");
- } else if (strncmp(GPGLL, sentence, sizeof(GPGLL)-1) == 0) {
+ } else if (PREFIX("$GPGLL", sentence)) {
PUBLISH(fd, "pd");
- } else if (strncmp(GPVTG, sentence, sizeof(GPVTG)-1) == 0) {
+ } else if (PREFIX("$GPVTG", sentence)) {
PUBLISH(fd, "tv");
- } else if (strncmp(GPGSA, sentence, sizeof(GPGSA)-1) == 0) {
+ } else if (PREFIX("$GPGSA", sentence)) {
PUBLISH(fd, "qm");
- } else if (strncmp(GPGSV, sentence, sizeof(GPGSV)-1) == 0) {
+ } else if (PREFIX("$GPGSV", sentence)) {
if (nmea_sane_satellites(&session->gNMEAdata))
PUBLISH(fd, "y");
}
diff --git a/gpsd.h b/gpsd.h
index 9ec34484..b41ce820 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -2,9 +2,7 @@
#include "gps.h"
-/*
- * Some internal capabilities depend on which drivers we're compiling.
- */
+/* Some internal capabilities depend on which drivers we're compiling. */
#if FV18_ENABLE || TRIPMATE_ENABLE || EARTHMATE_ENABLE || LOGFILE_ENABLE
#define NON_NMEA_ENABLE
#endif /* FV18_ENABLE || TRIPMATE_ENABLE || EARTHMATE_ENABLE || LOGFILE_ENABLE */
@@ -23,8 +21,7 @@ struct gps_type_t {
void (*handle_input)(struct gps_session_t *session);
int (*rtcm_writer)(struct gps_session_t *session, char *rtcmbuf, int rtcmbytes);
void (*wrapup)(struct gps_session_t *session);
- int baudrate, stopbits;
- int interval;
+ int baudrate, stopbits, interval;
};
#if defined (HAVE_SYS_TERMIOS_H)
@@ -45,35 +42,26 @@ struct gps_session_t {
int sentdgps; /* have we sent a DGPS correction? */
int fixcnt; /* count of good fixes seen */
struct termios ttyset, ttyset_old;
-#if TRIPMATE_ENABLE || defined(ZODIAC_ENABLE)
- /* public; set by -i option */
+#if TRIPMATE_ENABLE || defined(ZODIAC_ENABLE) /* public; set by -i option */
char *latitude, *longitude;
char latd, lond;
#endif /* TRIPMATE_ENABLE || defined(ZODIAC_ENABLE) */
-#ifdef ZODIAC_ENABLE
- /* private housekeeping stuff for the Zodiac driver */
+#ifdef ZODIAC_ENABLE /* private housekeeping stuff for the Zodiac driver */
unsigned short sn; /* packet sequence number */
double mag_var; /* Magnetic variation in degrees */
double separation; /* Geoidal separation */
int year, month, day;
int hours, minutes, seconds;
/*
- * Zodiac chipset channel status from PRWIZCH.
- * We stash it here is so that raw-mode translation of Zodiac binary
- * protocol will send it up to the client.
+ * Zodiac chipset channel status from PRWIZCH. Keep it so raw-mode
+ * translation of Zodiac binary protocol can send it up to the client.
*/
int Zs[MAXCHANNELS]; /* satellite PRNs */
int Zv[MAXCHANNELS]; /* signal values (0-7) */
#endif /* ZODIAC_ENABLE */
};
-#define GPGLL "$GPGLL"
-#define GPVTG "$GPVTG"
-#define GPGGA "$GPGGA"
-#define GPGSA "$GPGSA"
-#define GPGSV "$GPGSV"
-#define GPRMC "$GPRMC"
-#define PRWIZCH "$PRWIZCH"
+#define PREFIX(pref, sentence) !strncmp(pref, sentence, sizeof(pref)-1)
/* here are the available GPS drivers */
extern struct gps_type_t **gpsd_drivers;
diff --git a/nmea_parse.c b/nmea_parse.c
index 1471011f..5c2e6ba7 100644
--- a/nmea_parse.c
+++ b/nmea_parse.c
@@ -459,19 +459,19 @@ int nmea_parse(char *sentence, struct gps_data_t *outdata)
/* parse an NMEA sentence, unpack it into a session structure */
{
if (nmea_checksum(sentence+1)) {
- if (strncmp(GPRMC, sentence, sizeof(GPRMC)-1) == 0) {
+ if (PREFIX("$GPRMC", sentence)) {
processGPRMC(sentence, outdata);
- } else if (strncmp(GPGGA, sentence, sizeof(GPGGA)-1) == 0) {
+ } else if (PREFIX("$GPGGA", sentence)) {
processGPGGA(sentence, outdata);
- } else if (strncmp(GPGLL, sentence, sizeof(GPGLL)-1) == 0) {
+ } else if (PREFIX("$GPGLL", sentence)) {
processGPGLL(sentence, outdata);
- } else if (strncmp(GPVTG, sentence, sizeof(GPVTG)-1) == 0) {
+ } else if (PREFIX("$GPVTG", sentence)) {
processGPVTG(sentence, outdata);
- } else if (strncmp(GPGSA, sentence, sizeof(GPGSA)-1) == 0) {
+ } else if (PREFIX("$GPGSA", sentence)) {
processGPGSA(sentence, outdata);
- } else if (strncmp(GPGSV, sentence, sizeof(GPGSV)-1) == 0) {
+ } else if (PREFIX("$GPGSV", sentence)) {
processGPGSV(sentence, outdata);
- } else if (strncmp(PRWIZCH, sentence, sizeof(PRWIZCH)-1) == 0) {
+ } else if (PREFIX("$PRWIZCH", sentence)) {
/* do nothing */;
} else
return -1;