13 Jul 2005
gpsdecode 1 The GPSD Project GPSD Documentation
gpsdecode decode RTCM or AIVDM streams into a readable format
`gpsdecode` -c -d -e -j -u -D debuglevel -V

## DESCRIPTION

This tool is a decoder/encoder for various binary packet formats associated with GPS and differential-correction services. It produces a text dump on standard output from binary on standard input, or binary packets on standard output from text on standard input, and aims to be 100% information-preserving in both directions. As well as data, the decoder also prints decoder status messages to standard error as necessary.

Two of the supported formats are RTCM 2 and 3, a pair of obscure and complicated serial protocol used for broadcasting pseudorange corrections from differential-GPS reference stations. You can use this mode of the tool with nc 1 to examine RTCM feeds from DGPSIP servers or Ntrip broadcasters. The decoder dump formats for RTCM2 are described in rtcm 5; these lines go to standard output.

Another supported format is AIVDM. This is the sentence format used by the marine Automatic Identification System. This can be decoded, but not yet encoded.

## OPTIONS

The `-d` option tells the program to decode packets presented on standard input to a text dump on standard output. This is the default behavior.

RTCM2 will be dumped in one of the formats of rtcm-104 5 on standard output.

The `-e` option option tells the program to encode a text dump in one of the formats of rtcm-104 5 to standard output. This option is a placeholder: support for RTCM2 encoding from the Sager format has been removed

The `-u` suppresses scaling of AIS data to float quantities and text expansion of numeric codes. A dump with this option is lossless.

The `-j` sets the dump format to JSON, with each each field preceded by a quoted label and colon and the entire dump line wrapped in curly braces.

The `-c` sets the AIS dump format to separate fields with an ASCII pipe symbol. Fields are dumped in the order they occur in the AIS packet. Numerics are not scaled. Strings are unpacked from six-bit to full ASCII

The `-V` option directs the program to emit its version number, then exit.

The `-D` option sets a debug verbosity level. It is mainly of interest to developers.

## AIS DUMP FORMATS

Without the `-j` option, dump lines are values of AIS payload fields, pipe-separated, in the order that they occur in the payload. Spans of fields expressing a date are emitted as an ISO8601 timestamp (look for colons and the trailing Z indicating Zulu/UTC time), and the 19-bit group of TDMA status fields found at the end of message types 1-4 are are dumped as a single unsigned integer (in hex preceded by "0x"). Unused regional-authority fields are also dumped (in hex preceded by "0x"). Variable-length binary fields are dumped as an integer bit length, followed by a colon, followed by a hex dump.

By default, certain scaling and conversion operations are performed for the output. Latitudes and longitudes are scaled to decimal degrees rather than the native AIS unit of 1/10000th of a minute of arc. Ship (but not air) speeds are scaled to knots rather than tenth-of-knot units. Navigation status and positioning-system type are dumped as text strings rather than IAS numeric codes. Rate of turn may appear as "nan" if is unavailable, or as one of the strings "fastright" or "fastleft" if it is out of the IAS encoding range; otherwise it is quadratically mapped back to the turn sensor number in degrees per minute. Vessel draughts are converted to decimal meters rather than native AIS decimeters.

With the `-j` option, the AIS dump format changes to JSON. Data fields are handled as described above in scaled and unscaled modes, but are values attached to JSON attributes as described in AIVDM/AIVDO protocol decoding.

## APPLICABLE STANDARDS

The applicable standard for V2 is RTCM Recommended Standards for Differential NAVSTAR GPS Service RTCM Paper 194-93/SC 104-STD.

Note that gpsdecode presently recognizes only the 2.1 level of RTCM; the protocol was revised up to a version 2.3 including additional messages relating to GLONASS and real-time kinematics before being deprecated in favor of V3. It is now semi-obsolete.

The applicable standard for V3 is RTCM Standard 10403.1 for Differential GNSS Services - Version 3 RTCM Paper 177-2006-SC104-STD.

Ordering instructions for the RTCM standards are accessible from the website of the Radio Technical Commission for Maritime Services under "Publications".

The applicable standard for AIVDM is ITU-R M.1371: ITU Recommendation on the Technical Characteristics for a Universal Shipborne Automatic Identification System (AIS) using Time Division Multiple Access in the Maritime Mobile Band, A more accessible description can be found at AIVDM/AIVDO protocol decoding on the references page of the GPSD project website.

## BUGS AND LIMITATIONS

AIDVM decoding of types 16-17, 22-23, and 25-26 is unverified.

RTCM3 decoding is buggy and incomplete.

RTCM2 represents floating-point quantities as an integer multiple of a fixed scale factor. Editing an RTCM2 dump can produce numbers that are not an integer multiple of the scale factor for their field. If you do this, the value actually packed into binary RTCM2 will be rounded down to the nearest scale unit, and dumping will show slightly different numbers than those you entered. This bug could be fixed by supporting the `-u` option to suppress scaling.

The RTCM2 decoder logic is sufficiently convoluted to confuse some compiler optimizers, notably in GCC 3.x at -O2, into generating bad code.

Older version of this utility used comma as a field separator with the `-c` option. This was a mistake, as ship name and other string fields can contain commas.

## SEE ALSO

gpsd 8, gps 1, libgps 3, libgpsd 3, gpsprof 1, gpsfake 1, rtcm-104 5.

## AUTHOR

Eric S. Raymond esr@thyrsus.com. This is a somewhat hacked version of an RTCM decoder originally written by Wolfgang Rupprecht. There is a project page for gpsd here.