summaryrefslogtreecommitdiff
path: root/isgps.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-07-25 14:02:00 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-07-25 14:02:00 +0000
commit03bc6c126a755dc0c38dc6214feecf212ab77096 (patch)
treec5cddbf725698f40664619438024f703c6a27922 /isgps.c
parent37fb3a68b15b45e86e90db6abef1333f1ada0775 (diff)
downloadgpsd-03bc6c126a755dc0c38dc6214feecf212ab77096.tar.gz
Fix some documentation.
Diffstat (limited to 'isgps.c')
-rw-r--r--isgps.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/isgps.c b/isgps.c
index 097c0d21..95e0c643 100644
--- a/isgps.c
+++ b/isgps.c
@@ -1,30 +1,21 @@
/*****************************************************************************
-This is a decoder for RTCM-104, an obscure and complicated serial
-protocol used for broadcasting pseudorange corrections from
-differential-GPS reference stations. The applicable
-standard is
-
-RTCM RECOMMENDED STANDARDS FOR DIFFERENTIAL NAVSTAR GPS SERVICE,
-RTCM PAPER 194-93/SC 104-STD
-
-Ordering instructions are accessible from <http://www.rtcm.org/>
-under "Publications".
-
-Also applicable is ITU-R M.823: "Technical characteristics of
-differential transmissions for global navigation satellite systems
-from maritime radio beacons in the frequency band 283.5 - 315 kHz in
-region 1 and 285 - 325 kHz in regions 2 & 3."
+This is a decoder for the unnamed protocol described in IS-GPS-200,
+the Navstar GPS Interface Specification, and used as a transport layer
+for both GPS satellite downlink transmissions and the RTCM104 format
+for briodcasting differential-GPS corrections.
The code was originally by Wolfgang Rupprecht. ESR severely hacked
it, with Wolfgang's help, in order to separate message analysis from
-message dumping (he also added support for big-endian machines and
-repacking). You are not expected to understand any of it.
+message dumping and separate this lower layer from the upper layer
+handing RTCM decoding. You are not expected to understand any of it.
-However, in case you think you need to, this decoder is divided into
-two layers. The lower one just handles synchronizing with the
-incoming bitstream and parity checking, Here are Wolfgang's original
-rather cryptic notes on the lower level:
+This lower layer just handles synchronizing with the incoming
+bitstream and parity checking; all it does is assemble message
+packets. It needs an upper layer to analyze the packets into
+bitfields and the assemble the bitfields into usable data.
+
+Here are Wolfgang's original rather cryptic notes on this code:
--------------------------------------------------------------------------
1) trim and bitflip the input.
@@ -61,24 +52,6 @@ are used to extract pieces of it (which, if you're on a big-endian machine
may need to be swapped end-for-end). Those pieces are copied and (where
necessary) reassembled into a struct rtcm_t.
-Wolfgang's decoder was loosely based on one written by John Sanger in
-1999 (in particular the dump function emits Sanger's dump format).
-Here are John Sanger's original notes:
-
---------------------------------------------------------------------------
-The RTCM decoder prints a legible representation of the input data.
-The RTCM SC-104 specification is copyrighted, so I cannot
-quote it - in fact, I have never read it! Most of the information
-used to develop the decoder came from publication ITU-R M.823.
-This is a specification of the data transmitted from LF DGPS
-beacons in the 300kHz band. M.823 contains most of those parts of
-RTCM SC-104 directly relevant to the air interface (there
-are one or two annoying and vital omissions!). Information
-about the serial interface format was gleaned from studying
-the output of a beacon receiver test program made available on
-Starlink's website.
---------------------------------------------------------------------------
-
*****************************************************************************/
#include <unistd.h>
@@ -332,3 +305,18 @@ enum isgpsstat_t isgps_decode(struct gps_device_t *session,
}
/*@ +usereleased +compdef @*/
+#if WORDS_BIGENDIAN
+unsigned bitreverse(unsigned x, unsigned w)
+{
+ unsigned char mask = 1 << (w - 1), result = 0;
+
+ while (value) /* skip most significant bits that are zero */
+ {
+ if (value & 1) /* replace mod (machine dependency) */
+ result |= mask;
+ mask >>= 1;
+ value >>= 1;
+ }
+ return result;
+}
+#endif