jNMEA â NMEA-0183 Navigation, Timing, and Attitude Telegram Parser
Overview & Purpose
The jNMEA module (code/subr/jNMEA.c and code/subr/jNMEA.h) parses standard NMEA-0183 ASCII comma-delimited navigation, timing, velocity, and attitude sentences into strongly typed C structures. Originally written by John Hughes Clarke in September 1997 and extended by Brian Danforth (2005) and JHC (2008â2010), it handles talker prefixes from standalone GPS ($GP), multi-constellation GNSS ($GN), integrated navigation systems ($IN), and Trimble proprietary attitude strings ($PTNL), automatically converting DDMM.MMMM latitude/longitude strings into signed double-precision decimal degrees and extracting millisecond-precision UTC timestamps.
Key Data Structures (jNMEA.h)
1. Position Fix Telegrams (GGA, GGK, RMC, GLL)
NMEA_GPGGA_telegram($GPGGA,$INGGA,$GNGGA):- Time:
short hour, min, secs, millisecs; - Position:
int lat_deg; double lat_min; short lat_sign; int lon_deg; double lon_min; short lon_sign;and precomputed signed decimal degreesdouble lat, lon;. - Quality & Geodesy:
int GPS_quality(0invalid,1SPS,2DGPS,3PPS,4RTK Fixed,5RTK Float),int num_sats,float HDOP,float antenna_altitude,char antenna_units,float geoid_height,char geoid_units,float correction_age,char Terminator[10].
- Time:
NMEA_GPGGK_telegram($GPGGK,$INGGK):- Adds calendar date (
short day, month, year) and RTK/PPK quality flags alongsidelat,lon, and ellipsoidalantenna_altitude.
- Adds calendar date (
NMEA_GPRMC_telegram($GPRMC,$INRMC):- Recommended Minimum Navigation Information: UTC time (
hour, min, secs, millisecs),char status('A'valid,'V'warning),lat,lon, speed over groundfloat speed(knots), course over groundfloat course(degrees), date (day, month, year), andfloat magneticVariation(magVarSign).
- Recommended Minimum Navigation Information: UTC time (
NMEA_GPGLL_telegram($GPGLL,$INGLL):- Geographic Latitude/Longitude and UTC fix time (
hour, min, secs, millisecs,lat,lon).
- Geographic Latitude/Longitude and UTC fix time (
2. Timing, Velocity & Attitude Telegrams (ZDA, VTG, VHW, PTNL)
NMEA_GPZDA_telegram($GPZDA,$INZDA,$GNZDA):- UTC timestamp (
hour, min, secs, millisecs) and full calendar date (day, month, year).
- UTC timestamp (
NMEA_GPVTG_telegram($GPVTG,$INVTG,$GNVTG):- Track made good and ground speed:
float true_heading,float magnetic_heading,float SOG_1(knots),float SOG_2(km/h).
- Track made good and ground speed:
NMEA_LGVHW_telegram:- Water speed and heading (
ships_gyro,magnetic_compass,speed_knots).
- Water speed and heading (
TRIM_PTNL_telegram($PTNL,AVR,...):- Trimble dual-antenna GNSS attitude telegram containing UTC time (
hour, min, secs, millisecs),float yaw(degrees),float tilt(pitch/roll in degrees), andfloat baselineseparation (meters).
- Trimble dual-antenna GNSS attitude telegram containing UTC time (
Public Functions & Signatures
void jnmea_read_INGGA(char *telegram, int tot_char, int verbose_flag, NMEA_GPGGA_telegram *gpgga_str);
void jnmea_read_INGGK(char *telegram, int tot_char, int verbose_flag, NMEA_GPGGK_telegram *gpggk_str);
void jnmea_read_INRMC(char *telegram, int tot_char, int verbose_flag, NMEA_GPRMC_telegram *gprmc_str);
void jnmea_read_GPGLL(char *telegram, int tot_char, int verbose_flag, NMEA_GPGLL_telegram *gpgll_str);
void jnmea_read_INZDA(char *telegram, int tot_char, int verbose_flag, NMEA_GPZDA_telegram *gpzda_str);
void jnmea_read_GPVTG(char *telegram, int tot_char, int verbose_flag, NMEA_GPVTG_telegram *gpvtg_str);
void jnmea_read_PTNL (char *telegram, int tot_char, int verbose_flag, TRIM_PTNL_telegram *ptnl_str);
- Parsing Mechanics:
- Each parser scans
telegramup totot_charbytes for the matching 5-character NMEA mnemonic (e.g.,GPGGA,INGGA, orGNGGA), replaces commas,with spaces in a local scratch buffer while carefully preserving empty comma-delimited fields (,,), and extracts fields sequentially viasscanf(). - Latitude (
DDMM.MMMM) and Longitude (DDDMM.MMMM) are split into integer degrees and floating-point minutes, signed according to the hemisphere character ('N'/'S','E'/'W'), and stored inlatandlonas(deg + min / 60.0) * sign.
- Each parser scans
How It Fits Into the OMG Architecture
jNMEA is the standard ASCII navigation decoder across all OMG ingestion and real-time tools:
- Standalone Navigation Converters (
NMEAtoNav): Converts raw logged NMEA serial streams directly into binary OMG.navfiles. - Sonar Format Converters (
read_kmall,readEA600,humm2omg,oceanReader,upAGCDIG,plotSVP): Decodes embedded NMEA strings encapsulated inside Kongsberg.kmall, Simrad EA400/EA600.raw, and Humminbird sonar packets. - Real-Time Acquisition (
RT,RTLite): Parses live UDP/serial NMEA broadcasts (RT_unravel.c,RTlite_unravel.c) to geolocate incoming multibeam pings.