Expand description
§marlin-nmea-0183
Sans-I/O typed decoders for NMEA 0183 sentences. Built on
marlin-nmea-envelope.
The envelope crate produces RawSentence values — verified framing,
checksum-checked, fields split as byte slices. This crate turns those
into typed Rust structs:
bytes → marlin_nmea_envelope → RawSentence → marlin_nmea_0183 → Nmea0183Message§Supported sentence types
$__GGA—GgaData— position + fix quality + satellites$__HDT—HdtData— true heading$__VTG—VtgData— course & speed over ground$PSXN—PsxnData— Kongsberg-family proprietary motion; slot meanings are install-configurable viaPsxnLayout/DecodeOptions$PRDID—PrdidData— proprietary attitude with multiple vendor dialects; default refuses to guess (emitsPrdidData::Raw). Select a dialect viaDecodeOptions::with_prdid_dialect.
The talker ID is preserved as metadata on each typed struct rather
than dispatched on; $GPGGA, $INGGA, $GNGGA all decode to
GgaData with different talker values.
§Quickstart
use marlin_nmea_envelope::{OneShot, SentenceSource};
use marlin_nmea_0183::{decode, Nmea0183Message};
// Classic NMEA 0183 GGA example (checksum 0x47 = XOR of body bytes).
let mut parser = OneShot::new();
parser.feed(b"$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47");
let raw = parser.next_sentence().unwrap().unwrap();
match decode(&raw).unwrap() {
Nmea0183Message::Gga(gga) => {
assert_eq!(gga.talker, Some(*b"GP"));
assert_eq!(gga.satellites_used, Some(8));
}
_ => panic!("expected GGA"),
}§Extension
Each sentence type has a public per-sentence decoder
(decode_gga, decode_hdt, …). Downstream crates that need
proprietary sentences this crate doesn’t decode can build their own
enum and delegate to these decoders. See the crate
README
for a full example.
§Policy
Unknown sentence types are returned as
Nmea0183Message::Unknown with the raw sentence preserved. They
are not silently dropped and not returned as errors — the
caller decides what to do with them.
Structs§
- Decode
Options - Runtime configuration for ambiguous sentence decodings.
- GgaData
- Decoded fields of a
$__GGAsentence. - GllData
- Decoded fields of a
$__GLLsentence. - HdtData
- Decoded fields of a
$__HDTsentence. - Nmea0183
Parser - Typed-message parser built on top of any envelope-level
SentenceSourcethat producesRawSentencevalues. - Prdid
Pitch Roll Heading - PRDID decoded with field order
pitch, roll, heading— the canonical Teledyne RDI ADCP ordering. - Prdid
Roll Pitch Heading - PRDID decoded with field order
roll, pitch, heading— an alternative ordering seen on some integration guides. Not compatible with the Teledyne RDI ordering; swapping them produces wrong data silently. - Psxn
Data - Decoded fields of a
$PSXNsentence. - Psxn
Layout - Configuration for how PSXN
dataNslots map to motion quantities. - RawSentence
- A single NMEA 0183 sentence, borrowed from the parser’s internal buffer.
- RmcData
- Decoded fields of an
$__RMCsentence. - UtcDate
- UTC calendar date as carried by RMC’s
ddmmyyfield. - UtcTime
- UTC time-of-day with millisecond resolution.
- VtgData
- Decoded fields of a
$__VTGsentence.
Enums§
- Data
Status - Two-state validity flag from the RMC and GLL
Statusfield. - Decode
Error - Errors that can occur while decoding a typed NMEA sentence.
- GgaFix
Quality - GPS fix quality indicator — first field after time/lat/lon/hemi.
- Nmea0183
Error - Errors surfacing from
Nmea0183Parser::next_message(and from theParserenum’s delegating method). - Nmea0183
Message - A typed NMEA 0183 message.
- Parser
- Runtime selector between one-shot and streaming typed parsers.
- Prdid
Data - Typed payload of a
$PRDIDsentence. - Prdid
Dialect - Runtime selector for which PRDID field ordering to decode with.
- Psxn
Layout Parse Error - Error from parsing a legacy PSXN layout string like
"rphx1". - Psxn
Slot - Meaning of one of the six
dataNslots in a PSXN sentence. - RmcNav
Status - NMEA 4.10+ navigational-status byte — 13th field of RMC.
- VtgMode
- NMEA 2.3+ mode indicator — 9th field of VTG.
Functions§
- decode
- Decode a
RawSentenceinto a typedNmea0183Messageusing the defaultDecodeOptions. - decode_
gga - Decode a GGA sentence into typed fields.
- decode_
gll - Decode a GLL sentence into typed fields.
- decode_
hdt - Decode an HDT sentence.
- decode_
prdid - Decode a PRDID sentence using the given dialect.
- decode_
prdid_ pitch_ roll_ heading - Decode a PRDID sentence as
pitch, roll, heading(Teledyne RDI canonical ordering). - decode_
prdid_ roll_ pitch_ heading - Decode a PRDID sentence as
roll, pitch, heading(alternative ordering). - decode_
psxn - Decode a
$PSXNsentence using the provided layout. - decode_
rmc - Decode an RMC sentence into typed fields.
- decode_
vtg - Decode a VTG sentence into typed fields.
- decode_
with - Decode a
RawSentenceinto a typedNmea0183Messageusing the suppliedDecodeOptions.