diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | evermore.c | 2 | ||||
-rw-r--r-- | gps.h | 4 | ||||
-rw-r--r-- | gpsd.spec.in | 8 | ||||
-rw-r--r-- | packet.c | 193 | ||||
-rw-r--r-- | packet_states.h | 94 | ||||
-rw-r--r-- | statetable.el | 19 |
7 files changed, 109 insertions, 215 deletions
diff --git a/Makefile.am b/Makefile.am index a70ffc9c..09b1af32 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,6 +86,7 @@ libgps_c_sources = \ ntpshm.c \ libgps.c \ packet.c \ + packet_states.h \ gpsutils.c \ geoid.c \ dgpsip.c \ @@ -96,6 +97,9 @@ libgps_c_sources = \ bits.h \ timebase.h +packet_names.h: packet_states.h + sed -e '/^ *\([A-Z][A-Z0-9_]*\),/s// "\1",/' <packet_states.h >packet_names.h + libgps_la_SOURCES = $(libgps_c_sources) libgpsmm.cpp libgps_la_LIBADD = $(LIBM) $(LIBC) $(LIBNSL) $(LIBSOCKET) $(LIBPTHREAD) @@ -3,6 +3,8 @@ * * About the only thing this gives us that NMEA won't is TDOP. * But we'll get atomic position reports from it, which is good. + * + * The vendor site is <http://www.emt.com.tw>. */ @@ -85,8 +85,10 @@ struct gps_fix_t { */ #define RTCM_WORDS_MAX 33 #define MAXCORRECTIONS 15 /* max correction count in type 1 or 9 */ -#define MAXHEALTH 1 #define MAXSTATIONS 3 /* maximum stations in almanac, type 5 */ +/* RTCM104 doesn't specfy this, so give it the largest reasonable value */ +#define MAXHEALTH MAXCORRECTIONS + typedef /*@unsignedintegraltype@*/ unsigned int rtcmword_t; diff --git a/gpsd.spec.in b/gpsd.spec.in index 56290a11..bb7aedac 100644 --- a/gpsd.spec.in +++ b/gpsd.spec.in @@ -135,11 +135,9 @@ cp gps.py gpsfake.py "$RPM_BUILD_ROOT"%{_libdir}/python${PYVERSION}/site-package %changelog * Wed Jul 6 2005 Eric S. Raymond <esr@snark.thyrsus.com> - @VERSION@-1 -- Added Evermore binary support, untested. Added Sony CXD2951 support, - also untested. All error estimates are now nailed to 95% confidence - interval. DBUS support is autodetected and no longer needs to be - configured. Added iTrax NMEA support, untested. Added rtcmdecode - and its documentation. Added dangerous alpha version of gpsflash. +- Added Sony CXD2951 support, also untested. All error estimates are + now nailed to 95% confidence interval. Added rtcmdecode and its + documentation. Added dangerous alpha version of gpsflash. * Wed Jul 6 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 2.28-1 - The 2.27 source tarball somehow got truncated on upload. @@ -62,100 +62,7 @@ distinguish them from baud barf. */ enum { - GROUND_STATE, /* we don't know what packet type to expect */ - -#ifdef NMEA_ENABLE - NMEA_DOLLAR, /* we've seen first character of NMEA leader */ - NMEA_PUB_LEAD, /* seen second character of NMEA G leader */ - NMEA_LEADER_END, /* seen end char of NMEA leader, in body */ - NMEA_CR, /* seen terminating \r of NMEA packet */ - NMEA_RECOGNIZED, /* saw trailing \n of NMEA packet */ - - SIRF_ACK_LEAD_1, /* seen A of possible SiRF Ack */ - SIRF_ACK_LEAD_2, /* seen c of possible SiRF Ack */ - - SEATALK_LEAD_1, /* SeaTalk/Garmin packet leader 'I' */ -#endif /* NMEA_ENABLE */ - - DLE_LEADER, /* we've seen the TSIP/EverMore leader (DLE) */ - -#ifdef TRIPMATE_ENABLE - ASTRAL_1, /* ASTRAL leader A */ - ASTRAL_2, /* ASTRAL leader S */ - ASTRAL_3, /* ASTRAL leader T */ - ASTRAL_4, /* ASTRAL leader R */ - ASTRAL_5, /* ASTRAL leader A */ -#endif /* TRIPMATE_ENABLE */ - -#ifdef EARTHMATE_ENABLE - EARTHA_1, /* EARTHA leader E */ - EARTHA_2, /* EARTHA leader A */ - EARTHA_3, /* EARTHA leader R */ - EARTHA_4, /* EARTHA leader T */ - EARTHA_5, /* EARTHA leader H */ -#endif /* EARTHMATE_ENABLE */ - -#ifdef SIRFII_ENABLE - SIRF_LEADER_1, /* we've seen first character of SiRF leader */ - SIRF_LEADER_2, /* seen second character of SiRF leader */ - SIRF_LENGTH_1, /* seen first byte of SiRF length */ - SIRF_PAYLOAD, /* we're in a SiRF payload part */ - SIRF_DELIVERED, /* saw last byte of SiRF payload/checksum */ - SIRF_TRAILER_1, /* saw first byte of SiRF trailer */ - SIRF_RECOGNIZED, /* saw second byte of SiRF trailer */ -#endif /* SIRFII_ENABLE */ - -#ifdef ZODIAC_ENABLE - ZODIAC_EXPECTED, /* expecting Zodiac packet */ - ZODIAC_LEADER_1, /* saw leading 0xff */ - ZODIAC_LEADER_2, /* saw leading 0x81 */ - ZODIAC_ID_1, /* saw first byte of ID */ - ZODIAC_ID_2, /* saw second byte of ID */ - ZODIAC_LENGTH_1, /* saw first byte of Zodiac packet length */ - ZODIAC_LENGTH_2, /* saw second byte of Zodiac packet length */ - ZODIAC_FLAGS_1, /* saw first byte of FLAGS */ - ZODIAC_FLAGS_2, /* saw second byte of FLAGS */ - ZODIAC_HSUM_1, /* saw first byte of Header sum */ - ZODIAC_PAYLOAD, /* we're in a Zodiac payload */ - ZODIAC_RECOGNIZED, /* found end of the Zodiac packet */ -#endif /* ZODIAC_ENABLE */ - -#ifdef EVERMORE_ENABLE - EVERMORE_LEADER_1, /* a DLE after having seen EverMore data */ - EVERMORE_LEADER_2, /* seen opening STX of EverMore packet */ - EVERMORE_PAYLOAD, /* in payload part of EverMore packet */ - EVERMORE_PAYLOAD_DLE,/* DLE in payload part of EverMore packet */ - EVERMORE_RECOGNIZED, /* found end of EverMore packet */ -#endif /* EVERMORE_ENABLE */ - -#ifdef ITALK_ENABLE - ITALK_LEADER_1, /* saw leading < of iTalk packet */ - ITALK_LEADER_2, /* saw leading * of iTalk packet */ - ITALK_LENGTH_1, /* saw MSB of packet length */ - ITALK_LENGTH_2, /* saw LSB of packet length */ - ITALK_DELIVERED, /* seen end of payload */ - ITALK_TRAILER_1, /* saw iTalk trailer byte */ - ITALK_RECOGNIZED, /* found end of the iTalk packet */ -#endif /* ITALK_ENABLE */ - -/* - * Packet formats without checksums start here. We list them last so - * that if a format with a conflicting structure *and* a checksum can - * be recognized, that will be preferred. - */ - -#ifdef TSIP_ENABLE - TSIP_LEADER, /* a DLE after having seen TSIP data */ - TSIP_PAYLOAD, /* we're in TSIP payload */ - TSIP_DLE, /* we've seen a DLE in TSIP payload */ - TSIP_RECOGNIZED, /* found end of the TSIP packet */ -#endif /* TSIP_ENABLE */ - -#ifdef RTCM104_ENABLE - RTCM_SYNC_STATE, /* we have sync lock */ - RTCM_SKIP_STATE, /* we have sync lock, but this character is bad */ - RTCM_RECOGNIZED, /* we have an RTCM packet */ -#endif /* RTCM104_ENABLE */ +#include "packet_states.h" }; static void nexstate(struct gps_device_t *session, unsigned char c) @@ -700,102 +607,8 @@ ssize_t packet_parse(struct gps_device_t *session, size_t newdata) /*@ +modobserver @*/ /* to regenerate this table, see statetable.el */ /*%start%*/char *state_table[] = { - "GROUND_STATE", /* we don't know what packet type to expect */ - -#ifdef NMEA_ENABLE - "NMEA_DOLLAR", /* we've seen first character of NMEA leader */ - "NMEA_PUB_LEAD", /* seen second character of NMEA G leader */ - "NMEA_LEADER_END", /* seen end char of NMEA leader, in body */ - "NMEA_CR", /* seen terminating \r of NMEA packet */ - "NMEA_RECOGNIZED", /* saw trailing \n of NMEA packet */ - - "SIRF_ACK_LEAD_1", /* seen A of possible SiRF Ack */ - "SIRF_ACK_LEAD_2", /* seen c of possible SiRF Ack */ - - "SEATALK_LEAD_1", /* SeaTalk/Garmin packet leader 'I' */ -#endif /* NMEA_ENABLE */ - - "DLE_LEADER", /* we've seen the TSIP/EverMore leader (DLE) */ - -#ifdef TRIPMATE_ENABLE - "ASTRAL_1", /* ASTRAL leader A */ - "ASTRAL_2", /* ASTRAL leader S */ - "ASTRAL_3", /* ASTRAL leader T */ - "ASTRAL_4", /* ASTRAL leader R */ - "ASTRAL_5", /* ASTRAL leader A */ -#endif /* TRIPMATE_ENABLE */ - -#ifdef EARTHMATE_ENABLE - "EARTHA_1", /* EARTHA leader E */ - "EARTHA_2", /* EARTHA leader A */ - "EARTHA_3", /* EARTHA leader R */ - "EARTHA_4", /* EARTHA leader T */ - "EARTHA_5", /* EARTHA leader H */ -#endif /* EARTHMATE_ENABLE */ - -#ifdef SIRFII_ENABLE - "SIRF_LEADER_1", /* we've seen first character of SiRF leader */ - "SIRF_LEADER_2", /* seen second character of SiRF leader */ - "SIRF_LENGTH_1", /* seen first byte of SiRF length */ - "SIRF_PAYLOAD", /* we're in a SiRF payload part */ - "SIRF_DELIVERED", /* saw last byte of SiRF payload/checksum */ - "SIRF_TRAILER_1", /* saw first byte of SiRF trailer */ - "SIRF_RECOGNIZED", /* saw second byte of SiRF trailer */ -#endif /* SIRFII_ENABLE */ - -#ifdef ZODIAC_ENABLE - "ZODIAC_EXPECTED", /* expecting Zodiac packet */ - "ZODIAC_LEADER_1", /* saw leading 0xff */ - "ZODIAC_LEADER_2", /* saw leading 0x81 */ - "ZODIAC_ID_1", /* saw first byte of ID */ - "ZODIAC_ID_2", /* saw second byte of ID */ - "ZODIAC_LENGTH_1", /* saw first byte of Zodiac packet length */ - "ZODIAC_LENGTH_2", /* saw second byte of Zodiac packet length */ - "ZODIAC_FLAGS_1", /* saw first byte of FLAGS */ - "ZODIAC_FLAGS_2", /* saw second byte of FLAGS */ - "ZODIAC_HSUM_1", /* saw first byte of Header sum */ - "ZODIAC_PAYLOAD", /* we're in a Zodiac payload */ - "ZODIAC_RECOGNIZED", /* found end of the Zodiac packet */ -#endif /* ZODIAC_ENABLE */ - -#ifdef EVERMORE_ENABLE - "EVERMORE_LEADER_1", /* a DLE after having seen EverMore data */ - "EVERMORE_LEADER_2", /* seen opening STX of EverMore packet */ - "EVERMORE_PAYLOAD", /* in payload part of EverMore packet */ - "EVERMORE_PAYLOAD_DLE",/* DLE in payload part of EverMore packet */ - "EVERMORE_RECOGNIZED", /* found end of EverMore packet */ -#endif /* EVERMORE_ENABLE */ - -#ifdef ITALK_ENABLE - "ITALK_LEADER_1", /* saw leading < of iTalk packet */ - "ITALK_LEADER_2", /* saw leading * of iTalk packet */ - "ITALK_LENGTH_1", /* saw MSB of packet length */ - "ITALK_LENGTH_2", /* saw LSB of packet length */ - "ITALK_DELIVERED", /* seen end of payload */ - "ITALK_TRAILER_1", /* saw iTalk trailer byte */ - "ITALK_RECOGNIZED", /* found end of the iTalk packet */ -#endif /* ITALK_ENABLE */ - -/* - * Packet formats without checksums start here. We list them last so - * that if a format with a conflicting structure *and* a checksum can - * be recognized, that will be preferred. - */ - -#ifdef TSIP_ENABLE - "TSIP_LEADER", /* a DLE after having seen TSIP data */ - "TSIP_PAYLOAD", /* we're in TSIP payload */ - "TSIP_DLE", /* we've seen a DLE in TSIP payload */ - "TSIP_RECOGNIZED", /* found end of the TSIP packet */ -#endif /* TSIP_ENABLE */ - -#ifdef RTCM104_ENABLE - "RTCM_SYNC_STATE", /* we have sync lock */ - "RTCM_SKIP_STATE", /* we have sync lock, but this character is bad */ - "RTCM_RECOGNIZED", /* we have an RTCM packet */ -#endif /* RTCM104_ENABLE */ -}; - /*%end%*/ +#include "packet_names.h" + }; nexstate(session, c); gpsd_report(7, "%08ld: character '%c' [%02X], new state: %s\n", session->counter, diff --git a/packet_states.h b/packet_states.h new file mode 100644 index 00000000..c04b8a40 --- /dev/null +++ b/packet_states.h @@ -0,0 +1,94 @@ + GROUND_STATE, /* we don't know what packet type to expect */ + +#ifdef NMEA_ENABLE + NMEA_DOLLAR, /* we've seen first character of NMEA leader */ + NMEA_PUB_LEAD, /* seen second character of NMEA G leader */ + NMEA_LEADER_END, /* seen end char of NMEA leader, in body */ + NMEA_CR, /* seen terminating \r of NMEA packet */ + NMEA_RECOGNIZED, /* saw trailing \n of NMEA packet */ + + SIRF_ACK_LEAD_1, /* seen A of possible SiRF Ack */ + SIRF_ACK_LEAD_2, /* seen c of possible SiRF Ack */ + + SEATALK_LEAD_1, /* SeaTalk/Garmin packet leader 'I' */ +#endif /* NMEA_ENABLE */ + + DLE_LEADER, /* we've seen the TSIP/EverMore leader (DLE) */ + +#ifdef TRIPMATE_ENABLE + ASTRAL_1, /* ASTRAL leader A */ + ASTRAL_2, /* ASTRAL leader S */ + ASTRAL_3, /* ASTRAL leader T */ + ASTRAL_4, /* ASTRAL leader R */ + ASTRAL_5, /* ASTRAL leader A */ +#endif /* TRIPMATE_ENABLE */ + +#ifdef EARTHMATE_ENABLE + EARTHA_1, /* EARTHA leader E */ + EARTHA_2, /* EARTHA leader A */ + EARTHA_3, /* EARTHA leader R */ + EARTHA_4, /* EARTHA leader T */ + EARTHA_5, /* EARTHA leader H */ +#endif /* EARTHMATE_ENABLE */ + +#ifdef SIRFII_ENABLE + SIRF_LEADER_1, /* we've seen first character of SiRF leader */ + SIRF_LEADER_2, /* seen second character of SiRF leader */ + SIRF_LENGTH_1, /* seen first byte of SiRF length */ + SIRF_PAYLOAD, /* we're in a SiRF payload part */ + SIRF_DELIVERED, /* saw last byte of SiRF payload/checksum */ + SIRF_TRAILER_1, /* saw first byte of SiRF trailer */ + SIRF_RECOGNIZED, /* saw second byte of SiRF trailer */ +#endif /* SIRFII_ENABLE */ + +#ifdef ZODIAC_ENABLE + ZODIAC_EXPECTED, /* expecting Zodiac packet */ + ZODIAC_LEADER_1, /* saw leading 0xff */ + ZODIAC_LEADER_2, /* saw leading 0x81 */ + ZODIAC_ID_1, /* saw first byte of ID */ + ZODIAC_ID_2, /* saw second byte of ID */ + ZODIAC_LENGTH_1, /* saw first byte of Zodiac packet length */ + ZODIAC_LENGTH_2, /* saw second byte of Zodiac packet length */ + ZODIAC_FLAGS_1, /* saw first byte of FLAGS */ + ZODIAC_FLAGS_2, /* saw second byte of FLAGS */ + ZODIAC_HSUM_1, /* saw first byte of Header sum */ + ZODIAC_PAYLOAD, /* we're in a Zodiac payload */ + ZODIAC_RECOGNIZED, /* found end of the Zodiac packet */ +#endif /* ZODIAC_ENABLE */ + +#ifdef EVERMORE_ENABLE + EVERMORE_LEADER_1, /* a DLE after having seen EverMore data */ + EVERMORE_LEADER_2, /* seen opening STX of EverMore packet */ + EVERMORE_PAYLOAD, /* in payload part of EverMore packet */ + EVERMORE_PAYLOAD_DLE,/* DLE in payload part of EverMore packet */ + EVERMORE_RECOGNIZED, /* found end of EverMore packet */ +#endif /* EVERMORE_ENABLE */ + +#ifdef ITALK_ENABLE + ITALK_LEADER_1, /* saw leading < of iTalk packet */ + ITALK_LEADER_2, /* saw leading * of iTalk packet */ + ITALK_LENGTH_1, /* saw MSB of packet length */ + ITALK_LENGTH_2, /* saw LSB of packet length */ + ITALK_DELIVERED, /* seen end of payload */ + ITALK_TRAILER_1, /* saw iTalk trailer byte */ + ITALK_RECOGNIZED, /* found end of the iTalk packet */ +#endif /* ITALK_ENABLE */ + +/* + * Packet formats without checksums start here. We list them last so + * that if a format with a conflicting structure *and* a checksum can + * be recognized, that will be preferred. + */ + +#ifdef TSIP_ENABLE + TSIP_LEADER, /* a DLE after having seen TSIP data */ + TSIP_PAYLOAD, /* we're in TSIP payload */ + TSIP_DLE, /* we've seen a DLE in TSIP payload */ + TSIP_RECOGNIZED, /* found end of the TSIP packet */ +#endif /* TSIP_ENABLE */ + +#ifdef RTCM104_ENABLE + RTCM_SYNC_STATE, /* we have sync lock */ + RTCM_SKIP_STATE, /* we have sync lock, but this character is bad */ + RTCM_RECOGNIZED, /* we have an RTCM packet */ +#endif /* RTCM104_ENABLE */ diff --git a/statetable.el b/statetable.el deleted file mode 100644 index 2f73cb0e..00000000 --- a/statetable.el +++ /dev/null @@ -1,19 +0,0 @@ -(defun statetable-regen () - "Turn the packet-getter's enum list into a string array." - (interactive) - (goto-char (point-min)) - (re-search-forward "enum \\({[^}]*};\\)") - (let ((enums (buffer-substring (match-beginning 1) (match-end 1)))) - (if (re-search-forward "/\\*%start%\\*/\\([^%]*\\)/\\*%end%\\*/" nil t) - (let ((start (save-excursion (goto-char (match-beginning 1)) (point-marker))) - (end (save-excursion (goto-char (match-end 1)) (point-marker)))) - (replace-match (concat - "char *state_table[] = " - enums - "\n\t") t t nil 1) - (goto-char start) - (while (re-search-forward "^ *\\([A-Z0-9_]+\\)," end t) - (replace-match - (concat "\"" (buffer-substring (match-beginning 1) (match-end 1)) "\"") - t t nil 1)))))) - |