MLIB
Loading...
Searching...
No Matches
NMEA-0183

Data Structures

class  mlib::parse_context
 parsing context for NMEA-0183 parser More...
 

Macros

#define NEXT_TOKEN(A, B)
 
#define NEXT_VALIDTOKEN(A, B)
 
#define IFPAR(par, exp)
 

Functions

bool mlib::nmea_checksum (const char *buf)
 Compute the checksum of a NMEA sentence.
 
int mlib::dbs (const char *buf, double *depth)
 NMEA-0183 DBS sentence.
 
int mlib::dbt (const char *buf, double *depth)
 NMEA-0183 DBT sentence.
 
int mlib::dpt (const char *buf, double *depth, double *offset, double *range)
 NMEA-0183 DPT sentence.
 
int mlib::gga (const char *buf, double *lat, double *lon, double *time, double *height, double *undul, double *dop, int *sat, int *mode, double *age, int *station)
 
int mlib::ggk (const char *buf, double *lat, double *lon, double *time, double *height, double *dop, int *sat, int *mode)
 NMEA-0183 GGK sentence.
 
int mlib::gll (const char *buf, double *lat, double *lon, double *time, int *mode)
 NMEA-0183 GLL sentence.
 
int mlib::gns (const char *buf, double *time, double *lat, double *lon, int *mode, int *sat, double *dop, double *height, double *age, int *station)
 
int mlib::gsa (const char *buf, int *hmode, int *fmode, int *sv, double *pdop, double *hdop, double *vdop)
 NMEA-0183 GSA sentence.
 
int mlib::gst (const char *buf, double *time, double *rms, double *smaj, double *smin, double *orient, double *stdlat, double *stdlon, double *stdh)
 NMEA-0183 GST sentence.
 
int mlib::gsv (const char *buf, int *tmsg, int *msg, int *count, int *sv, int *az, int *elev, int *snr)
 NMEA-0183 GSV sentence - Satellites in View.
 
int mlib::gxp (const char *buf, double *lat, double *lon, double *time, int *wp)
 NMEA-0183 GXP sentence.
 
int mlib::hdg (const char *buf, double *head, double *dev, double *var)
 NMEA-0183 HDG sentence.
 
int mlib::hdm (const char *buf, double *head)
 NMEA-0183 HDM sentence.
 
int mlib::hdt (const char *buf, double *head)
 NMEA-0183 HDT sentence $ttHDT,xxx.x,T.
 
int mlib::llq (const char *buf, double *time, double *x, double *y, int *mode, int *sat, double *dop, double *height)
 
int mlib::pashr (const char *buf, double *time, double *hdg, double *pitch, double *roll, double *heave, double *roll_std, double *pitch_std, double *hdg_std, int *flag_h, int *flag_i)
 NMEA-0183 Ashtech proprietary PASHR sentence.
 
int mlib::psathpr (const char *buf, double *time, double *head, double *pitch, double *roll, char *type)
 NMEA-0183 Hemisphere GNSS proprietary sentence.
 
int mlib::ptnlggk (const char *buf, double *lat, double *lon, double *time, double *height, double *dop, int *sat, int *mode)
 NMEA-0183 Trimble proprietary PTNLGGK sentence.
 
int mlib::ptnlqa (const char *buf, double *sigman, double *sigmae, double *smaj, double *smin, double *orient)
 NMEA-0183 Trimble proprietary PTNL,QA sentence.
 
int mlib::rmc (const char *buf, double *lat, double *lon, double *time, double *speed, double *head, int *date, int *mode)
 NMEA-0183 RMC sentence.
 
int mlib::ttm (const char *buf, double *utc, int *num, char *name, double *dist, double *brg, int *relbrg, double *speed, double *cog, int *relcog, double *cpa, double *tcpa, int *stat)
 NMEA-0183 TTM sentence (Tracked Target message).
 
int mlib::vtg (const char *buf, double *speed, double *head)
 NMEA-0183 VTG sentence.
 
int mlib::zda (const char *buf, double *time, unsigned short *day, unsigned short *month, unsigned short *year)
 NMEA-0183 ZDA sentence.
 
 mlib::parse_context::parse_context (const char *buf)
 Constructor for a parsing context.
 
char * mlib::parse_context::token ()
 Return next token of a NMEA sentence.
 

Detailed Description

Macro Definition Documentation

◆ IFPAR

#define IFPAR (   par,
  exp 
)
Value:
if (par) \
*par = (exp)

◆ NEXT_TOKEN

#define NEXT_TOKEN (   A,
 
)
Value:
if ((A = ctx.token ()) == NULL) \
return B

◆ NEXT_VALIDTOKEN

#define NEXT_VALIDTOKEN (   A,
 
)
Value:
if ((A = ctx.token ()) == NULL || !strlen (A)) \
return B

Function Documentation

◆ dbs()

int mlib::dbs ( const char *  buf,
double *  depth 
)

NMEA-0183 DBS sentence.

$ttDBS,depf,f,depm,M,depF,F

Note
If more than one depth is specified depth in meters takes precedence over depth in feet and depth in feet takes precedence over depth in fathoms.

Returned value is always in meters.

◆ dbt()

int mlib::dbt ( const char *  buf,
double *  depth 
)

NMEA-0183 DBT sentence.

$ttDBT,depf,f,depm,M,depF,F

Note
If more than one depth is specified, depth in meters takes precedence over depth in feet and depth in feet takes precedence over depth in fathoms.

Returned value is always in meters.

This sentence is obsolete.

◆ dpt()

int mlib::dpt ( const char *  buf,
double *  depth,
double *  offset,
double *  range 
)

NMEA-0183 DPT sentence.

$ttDPT,dep,offset,range

◆ gga()

int mlib::gga ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
double *  height,
double *  undul,
double *  dop,
int *  sat,
int *  mode,
double *  age,
int *  station 
)

NMEA-0183 GGA sentence.

$ttGGA,hhmmss,xxxx.xx,N,xxxxx.xx,W,q,s,dop,msl,M,und,M[,age,station]

Returns
version of standard to which sentence conforms or 0 if invalid statement.
Note
Height is ellipsoidal.

◆ ggk()

int mlib::ggk ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
double *  height,
double *  dop,
int *  sat,
int *  mode 
)

NMEA-0183 GGK sentence.

$ttGGK,hhmmss,mmddyy,xxxx.xx,N,xxxxx.xx,W,q,s,dop,geo,M

Returns
  • 1 if valid statement
  • 0 if invalid statement
Note
This is not a true NMEA standard sentence, however it is generated by quite a few GPS units.

◆ gll()

int mlib::gll ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
int *  mode 
)

NMEA-0183 GLL sentence.

$ttGLL,lat,N,lon,W[,time,valid,[mode]]

Returns
  • 0 if invalid statement
  • 1 old NMEA 1.x standard (missing time and mode)
  • 2 newer version 2 (missing mode field)
  • 3 version 3

◆ gns()

int mlib::gns ( const char *  buf,
double *  time,
double *  lat,
double *  lon,
int *  mode,
int *  sat,
double *  dop,
double *  height,
double *  age,
int *  station 
)

NMEA-0183 GNS sentence.

$–GNS,hhmmss.ss,llll.lll,a,yyyyy.yyy,a,c–c,xx,x.x,x.x,x.x,x.x,x.x*hh

Returns
version of standard to which sentence conforms or 0 if invalid statement.
Note
Height is ellipsoidal.

◆ gsa()

int mlib::gsa ( const char *  buf,
int *  hmode,
int *  fmode,
int *  sv,
double *  pdop,
double *  hdop,
double *  vdop 
)

NMEA-0183 GSA sentence.

GNSS DOP and Active Satellites

GNSS receiver operating mode, satellites used in the navigation solution reported by the GGA or GNS sentence, and DOP values.

    $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,x.x,x.x,x.x<CR><LF>
           | | |                                 |  |   |   |
           | | |                                 |  |   |   +-- VDOP
           | | |                                 |  |   +------ HDOP
           | | |                                 |  +---------- PDOP
           | | |_________________________________|
           | |            |
           | |            +--- ID numbers of satellites used in solution
           | +---------------- Mode: 1 = Fix not available, 2 = 2D, 3 = 3D
           +------------------ Mode: M = Manual, forced to operate in 2D or 3D mode
                                     A = Automatic, allowed to automatically switch 2D/3D

◆ gst()

int mlib::gst ( const char *  buf,
double *  time,
double *  rms,
double *  smaj,
double *  smin,
double *  orient,
double *  stdlat,
double *  stdlon,
double *  stdh 
)

NMEA-0183 GST sentence.

$ttGST,time,rms,semimaj,semimin,orient,stdlat,stdlon,stdh

◆ gsv()

int mlib::gsv ( const char *  buf,
int *  tmsg,
int *  msg,
int *  count,
int *  sv,
int *  az,
int *  elev,
int *  snr 
)

NMEA-0183 GSV sentence - Satellites in View.

  $xxGSV,t,n,c,id,el,az,sn,id,az,el,sn,id,az,el,sn,id,az,el,sn*hh
         | | | |  |  |  |  |          ||          ||__________+- satellite 4
         | | | |  |  |  |  |          ||__________+------------- satellite 3
         | | | |  |  |  |  |__________+------------------------- satellite 2
         | | | |  |  |  +------- SNR satellite 1 (0-99)
         | | | |  |  +---------- Azimuth satellite 1 (0-359)
         | | | |  +------------- Elevation satellite 1 (0-90)
         | | | +---------------- SV number satellite 1
         | | +------------------ Total number of satellites in view
         | +-------------------- Message number
         +---------------------- Total number of messages

◆ gxp()

int mlib::gxp ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
int *  wp 
)

NMEA-0183 GXP sentence.

$ttGXP,time,lat,N,lon,a,wp

Note
This sentence is obsolete.

◆ hdg()

int mlib::hdg ( const char *  buf,
double *  head,
double *  dev,
double *  var 
)

NMEA-0183 HDG sentence.

$ttHDG,hdg,dev,E/W,var,E/W

magnetic = hdg + dev true = magnetic + var

◆ hdm()

int mlib::hdm ( const char *  buf,
double *  head 
)

NMEA-0183 HDM sentence.

$ttHDM,xxx.x,M

Note
This sentence is obsolete

◆ hdt()

int mlib::hdt ( const char *  buf,
double *  head 
)

NMEA-0183 HDT sentence $ttHDT,xxx.x,T.

Note
This sentence is obsolete

◆ llq()

int mlib::llq ( const char *  buf,
double *  time,
double *  x,
double *  y,
int *  mode,
int *  sat,
double *  dop,
double *  height 
)

Leica LLQ sentence.

$GPLLQ,hhmmss.ss,mmddyy,eeeeee.eee,M,nnnnnn.nnn,M,g,ss,q.q,z.z,M*hh

  • hhmmss.ss UTC time of position
  • mmddyy UTC date
  • eeeeee.ee Grid Easting, meters
  • M Meter (fixed text "M")
  • nnnnnn.nn Grid Northing, meters
  • M Meter (fixed text "M")
  • g GPS Quality
    • 0 = fix not available or invalid
    • 1 = No realtime position, navigation fix
    • 2 = realtime position, ambiguities not fixed
    • 3 = realtime position, ambiguities fixed
  • ss Number of satellites used in computation
  • q.q Coordinate Quality
  • z.z Altitude above/below mean sea level for position of marker. Note, if no orthometric height is available the local ell. height will be exported.
  • M Meter (fixed text "M")
  • hh Checksum

◆ nmea_checksum()

bool mlib::nmea_checksum ( const char *  buf)

Compute the checksum of a NMEA sentence.

Returns
  • false = if an incorrect checksum was found or the sentence doesn't start with '$' or '!' characters.
  • true = if the checksum is correct or inexistent.

◆ pashr()

int mlib::pashr ( const char *  buf,
double *  time,
double *  hdg,
double *  pitch,
double *  roll,
double *  heave,
double *  roll_std,
double *  pitch_std,
double *  hdg_std,
int *  flag_h,
int *  flag_i 
)

NMEA-0183 Ashtech proprietary PASHR sentence.

$PASHR,UTC-Time,HeadingTRUE,T,ROLL,PITCH,HEAVE(m),accuracyRoll, accuracyPitch,accuracyHeading

Newer Ashtech proprietary sentence for attitude sensors. Also used by Applanix POS M/V systems.

  • Flag accuracy heading
    • 0 = no aiding
    • 1 = GPSAiding
    • 2 = GPS&GAMS aiding
  • Flag IMU
    • 0 = satisfactory
    • 1 = IMUOUT
  $PASHR,145719.272,252.41,T,1.22,0.48,0.01,0.090,0.090,0.116,2,1*11
  $PASHR,141424.923,45.36,T,-0.57,-0.63,0.02,0.086,0.086,0.025,1,1*28
Note
Hemisphere has a different description:
      $PASHR,hhmmss.ss,HHH.HH,T,RRR.RR,PPP.PP,heave,rr.rrr,pp.ppp,hh.hhh,QF*CC<CR><LF>

  where:
    hhmmss.ss         UTC time
    HHH.HH            Heading value in decimal degrees
    T                 True heading (T displayed if heading is relative to true north)
    RRR.RR            Roll in decimal degrees (- sign will be displayed when applicable)
    PPP.PP            Pitch in decimal degrees (- sign will be displayed when applicable)
    heave             Heave, in meters
    rr.rrr            Roll standard deviation in decimal degrees
    pp.ppp            Pitch standard deviation in decimal degrees
    hh.hhh            Heading standard deviation in decimal degrees
    QF                Quality Flag
                        0 = No position
                        1 = All non-RTK fixed integer positions
                        2 = RTK fixed integer position

◆ psathpr()

int mlib::psathpr ( const char *  buf,
double *  time,
double *  head,
double *  pitch,
double *  roll,
char *  type 
)

NMEA-0183 Hemisphere GNSS proprietary sentence.

$PSAT,HPR,time,heading,pitch,roll,type

type:

  • N = GPS derived heading
  • G = gyro heading

◆ ptnlggk()

int mlib::ptnlggk ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
double *  height,
double *  dop,
int *  sat,
int *  mode 
)

NMEA-0183 Trimble proprietary PTNLGGK sentence.

  $PTNL,GGK,hhmmss.ss,mmddyy,llll.ll,a,yyyyy.yy,a,xx,xx,x.x,EHTxx.x,M*hh

  - hhmmss.ss   = UTC of Position Fix
  - mmddyy      = UTC date
  - llll.ll     = Latitude
  - a           = Hemisphere (N/S)
  - yyyyy.yy    = Longitude
  - a           = E/W
  - xx          = GPS Quality Indicator
                   - 0: Fix not available or invalid
                   - 1: Autonomous GPS fix
                   - 2: RTK float solution
                   - 3: RTK fix solution
                   - 4: Differential, code phase only solution (DGPS)
                   - 5: SBAS solution (WAAS/EGNOS/MSAS)
                   - 6: RTK float or RTK location 3D Network solution
                   - 7: RTK fixed 3D Network solution
                   - 8: RTK float or RTK location 2D in a Network solution
                   - 9: RTK fixed 2D Network solution
                   - 10: OmniSTAR HP/XP solution
                   - 11: OmniSTAR VBS solution
                   - 12: Location RTK solution
                   - 13: Beacon DGPS
  - xx          = Number of Satellites in use
  - x.x         = PDOP
  - xx.x        = Ellipsoidal height.
                = Altitude above/below mean sea level for
                  position of marker. Note, if no orthometric
                  height is available the local ell. height will be
                  exported.
  - M           = Units of altitude meters (fixed text "M")
  - hh          = Checksum

    $PTNL,GGK,172814.00,071296,3723.46587704,N,12202.26957864,W,3,06,1.7,EHT-6.777,M*48

◆ ptnlqa()

int mlib::ptnlqa ( const char *  buf,
double *  sigman,
double *  sigmae,
double *  smaj,
double *  smin,
double *  orient 
)

NMEA-0183 Trimble proprietary PTNL,QA sentence.

Note
This sentence is obsolete.

◆ rmc()

int mlib::rmc ( const char *  buf,
double *  lat,
double *  lon,
double *  time,
double *  speed,
double *  head,
int *  date,
int *  mode 
)

NMEA-0183 RMC sentence.

$ttRMC,time,stat,lat,N/S,lon,E/W,speed,head,date,magvar,E/W,mode

◆ token()

char * mlib::parse_context::token ( )

Return next token of a NMEA sentence.

Tokens are delimited by ',', <CR>, '*' or end of string. We cannot use strtok directly because we want to leave the string unchanged and we don't want to skip over consecutive empty fields.

◆ ttm()

int mlib::ttm ( const char *  buf,
double *  utc,
int *  num,
char *  name,
double *  dist,
double *  brg,
int *  relbrg,
double *  speed,
double *  cog,
int *  relcog,
double *  cpa,
double *  tcpa,
int *  stat 
)

NMEA-0183 TTM sentence (Tracked Target message).

$xxTTM,num,dist,brg,relbrg,speed,course,relcog,cpa,tcpa,units,name,status,ref,hhmmss.ss,acq*hh

  • num = target number
  • dist = target distance relative to own ship
  • brg = target bearing
  • relbrg = 'T' for true bearing, 'R' for relative
  • speed = target speed
  • course = target course
  • relcog = true/relative course
  • cpa = distance to closest point of approach
  • tca = time to CPA
  • units = speed/distance units ('K' or 'N' or 'S')
  • name = target name
  • status = 'L' lost, 'Q' query, 'T' tracking
  • ref = reference target
  • hhmmss = UTC time
  • acq = acquisition status

◆ vtg()

int mlib::vtg ( const char *  buf,
double *  speed,
double *  head 
)

NMEA-0183 VTG sentence.

$ttVTG,true,T,mag,M,knots,N,kph,K,mode

True heading takes precedence over magnetic heading. Speed value in knots takes precedence over value in km/h.

◆ zda()

int mlib::zda ( const char *  buf,
double *  time,
unsigned short *  day,
unsigned short *  month,
unsigned short *  year 
)

NMEA-0183 ZDA sentence.

$ttZDA,time,day,month,year,loch,locm

UTC = local +loch + locm/60