summaryrefslogtreecommitdiff
path: root/gpsd.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-11-30 07:29:25 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-11-30 07:29:25 +0000
commit2f6775a8769ed7a2250bb90a68c5fa2617123604 (patch)
treeb0a90a20de3049daf781390419172d628bb83fc0 /gpsd.h
parent1c2b3463912566fa8a5841385a56ed1d966138db (diff)
downloadgpsd-2f6775a8769ed7a2250bb90a68c5fa2617123604.tar.gz
Split the packet-sniffer internals out of the session structure.
This is a big, super-intrusive patch but changes no logic at all -- it's all about ripping out some of the gps_device_t structure members into a new gps_packet_t structure. Even the driver API doesn't change at all, this is all libgpsd(3) internals being rearranged. The motivation here is that we want to kill off the ad-hoc Python implementation of a packet-sniffer in gpsfake. To do that we need to be able to write a "pure" packet sniffer that uses the same C code as the daemon's but without being welded to the rest of the libgpsd(3) code. This is the first step towards that.
Diffstat (limited to 'gpsd.h')
-rw-r--r--gpsd.h90
1 files changed, 49 insertions, 41 deletions
diff --git a/gpsd.h b/gpsd.h
index 60f1d3d1..2b6b8f1e 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -124,18 +124,9 @@ struct gps_type_t {
*/
#define INPUT_BUFFER_LENGTH 1024
-struct gps_device_t {
-/* session object, encapsulates all global state */
- struct gps_data_t gpsdata;
- /*@relnull@*/struct gps_type_t *device_type;
- struct gps_context_t *context;
-#ifdef ALLOW_RECONFIGURE
- bool enable_reconfigure; /* OK to hack GPS settings? */
-#endif /* ALLOW_RECONFIGURE */
- double rtcmtime; /* timestamp of last RTCM104 correction to GPS */
- struct termios ttyset, ttyset_old;
+struct gps_packet_t {
/* packet-getter internals */
- int packet_type;
+ int type;
#define BAD_PACKET -1
#define NMEA_PACKET 0
#define SIRF_PACKET 1
@@ -145,10 +136,8 @@ struct gps_device_t {
#define ITALK_PACKET 5
#define RTCM_PACKET 6
#define GARMIN_PACKET 7
- unsigned int baudindex;
- int saved_baud;
- unsigned int packet_state;
- size_t packet_length;
+ unsigned int state;
+ size_t length;
unsigned char inbuffer[MAX_PACKET_LENGTH*2+1];
size_t inbuflen;
unsigned /*@observer@*/char *inbufptr;
@@ -157,7 +146,35 @@ struct gps_device_t {
size_t outbuflen;
unsigned long char_counter; /* count characters processed */
unsigned long retry_counter; /* count sniff retries */
- unsigned packet_counter; /* packets since last driver switch */
+ unsigned counter; /* packets since last driver switch */
+ /*
+ * This is not conditionalized on RTCM104_ENABLE because we need to
+ * be able to build rtcmdecode even when RTCM support is not
+ * configured in the daemon.
+ */
+ struct {
+ /* ISGPS200 decoding */
+ bool locked;
+ int curr_offset;
+ isgps30bits_t curr_word;
+ isgps30bits_t buf[RTCM_WORDS_MAX];
+ unsigned int bufindex;
+ } isgps;
+};
+
+struct gps_device_t {
+/* session object, encapsulates all global state */
+ struct gps_data_t gpsdata;
+ /*@relnull@*/struct gps_type_t *device_type;
+ struct gps_context_t *context;
+#ifdef ALLOW_RECONFIGURE
+ bool enable_reconfigure; /* OK to hack GPS settings? */
+#endif /* ALLOW_RECONFIGURE */
+ double rtcmtime; /* timestamp of last RTCM104 correction to GPS */
+ struct termios ttyset, ttyset_old;
+ unsigned int baudindex;
+ int saved_baud;
+ struct gps_packet_t packet;
char subtype[64]; /* firmware version or subtype ID */
double poll_times[FD_SETSIZE]; /* last daemon poll time */
#ifdef NTPSHM_ENABLE
@@ -240,19 +257,6 @@ struct gps_device_t {
unsigned int Zv[ZODIAC_CHANNELS]; /* signal values (0-7) */
} zodiac;
#endif /* ZODIAC_ENABLE */
- /*
- * This is not conditionalized on RTCM104_ENABLE because we need to
- * be able to build rtcmdecode even when RTCM support is not
- * configured in the daemon. It doesn't take up extra space.
- */
- struct {
- /* ISGPS200 decoding */
- bool locked;
- int curr_offset;
- isgps30bits_t curr_word;
- isgps30bits_t buf[RTCM_WORDS_MAX];
- unsigned int bufindex;
- } isgps;
#endif /* BINARY_ENABLE */
} driver;
};
@@ -277,16 +281,18 @@ extern gps_mask_t nmea_parse(char *, struct gps_device_t *);
extern int nmea_send(int, const char *, ... );
extern void nmea_add_checksum(char *);
+ssize_t generic_get(struct gps_device_t *);
ssize_t pass_rtcm(struct gps_device_t *, char *, size_t);
extern gps_mask_t sirf_parse(struct gps_device_t *, unsigned char *, size_t);
extern gps_mask_t evermore_parse(struct gps_device_t *, unsigned char *, size_t);
extern gps_mask_t garmin_ser_parse(struct gps_device_t *);
-extern void packet_reset(struct gps_device_t *);
-extern void packet_pushback(struct gps_device_t *);
-extern ssize_t packet_parse(struct gps_device_t *, size_t);
-extern ssize_t packet_get(struct gps_device_t *);
-extern int packet_sniff(struct gps_device_t *);
+
+extern void packet_reset(struct gps_packet_t *);
+extern void packet_pushback(struct gps_packet_t *);
+extern ssize_t packet_parse(struct gps_packet_t *, struct rtcm_t *, size_t);
+extern ssize_t packet_get(int, struct rtcm_t *, struct gps_packet_t *);
+extern int packet_sniff(struct gps_packet_t *);
extern bool dgnss_url(char *);
extern int dgnss_open(struct gps_context_t *, char *);
@@ -331,19 +337,21 @@ extern bool ntpshm_free(struct gps_context_t *, int);
extern int ntpshm_put(struct gps_device_t *, double);
extern int ntpshm_pps(struct gps_device_t *,struct timeval *);
-extern void isgps_init(/*@out@*/struct gps_device_t *);
-enum isgpsstat_t isgps_decode(struct gps_device_t *,
+extern void isgps_init(/*@out@*/struct gps_packet_t *);
+enum isgpsstat_t isgps_decode(struct gps_packet_t *,
bool (*preamble_match)(isgps30bits_t *),
- bool (*length_check)(struct gps_device_t *),
+ bool (*length_check)(struct gps_packet_t *),
size_t,
unsigned int);
extern unsigned int isgps_parity(isgps30bits_t);
-extern enum isgpsstat_t rtcm_decode(struct gps_device_t *, unsigned int);
-extern void rtcm_dump(struct gps_device_t *, /*@out@*/char[], size_t);
+extern enum isgpsstat_t rtcm_decode(struct gps_packet_t *,
+ struct rtcm_t *,
+ unsigned int);
+extern void rtcm_dump(struct rtcm_t *, /*@out@*/char[], size_t);
extern int rtcm_undump(/*@out@*/struct rtcm_t *, char *);
-extern void rtcm_unpack(struct gps_device_t *);
-extern bool rtcm_repack(struct gps_device_t *);
+extern void rtcm_unpack(/*@out@*/struct rtcm_t *, char *);
+extern bool rtcm_repack(struct rtcm_t *, char *);
extern void ecef_to_wgs84fix(struct gps_data_t *,
double, double, double,