Skip to main content

Module nmea

Module nmea 

Source
Expand description

NMEA 0183 logs: the sentences a GPS receiver writes, one per line.

NmeaReader takes the log as bytes in whatever pieces they arrive and hands rows back a batch at a time, keeping only the line in progress and the fix being merged. Nothing about it needs the whole file, so a log being written can be read on as it grows (push the new bytes, take what is ready); only NmeaReader::finish says there will be no more.

Every length comes from the reader, not the file: a line is at most MAX_LINE bytes (the standard’s is 82), so a hostile file costs one line of memory.

Structs§

NmeaReader
An NMEA log read into one Table, a piece at a time.
Stats
What a read counted, for the notes.

Enums§

Table
The tables an NMEA log opens as: the fixes merged from its sentences, each sentence type alone, or every sentence as it stands.

Constants§

BATCH_ROWS
Rows held before they are handed over as a batch.
MAX_LINE
The longest line read as a sentence. The standard allows 82 characters; vendors’ own sentences run longer. A longer line is not NMEA and is skipped.

Functions§

looks_like
Whether the first bytes of a file are an NMEA log: its first line that is not blank is a sentence at the start of the line, either with a checksum that matches or of a type receivers write. A CSV header such as $USD,$EUR has the shape of a sentence and is neither. A capture from a serial port starts wherever the port was in its output, so a first line that is the tail of a sentence (...,M,,*47) is passed over.