a lightweight GPS NMEA 0183 parser library in pure C
Minmea is a minimalistic GPS parser library written in pure C intended for resource-constrained platforms, especially microcontrollers and other embedded systems.
GBS (Satellite Fault Detection)GGA (Fix Data)GLL (Geographic Position: Latitude/Longitude)GSA (DOP and active satellites)GST (Pseudorange Noise Statistics)GSV (Satellites in view)RMC (Recommended Minimum: position, velocity, time)VTG (Track made good and Ground speed)ZDA (Time & Date - UTC, day, month, year and local time zone)Adding support for more sentences is trivial; see minmea.c source. Good documentation
on NMEA is at https://gpsd.gitlab.io/gpsd/NMEA.html
Minmea runs out-of-the-box under most Unix-compatible systems. Support for non-Unix systems (including native Windows builds under MSVC) is provided via compatibility headers:
MINMEA_INCLUDE_COMPAT in the build environment.compat/ directory as minmea_compat.h.If your GPS receiver outputs very long sentences, consider increasing MINMEA_MAX_SENTENCE_LENGTH
in your build environment.
Internally, minmea stores fractional numbers as pairs of two integers: {value, scale}.
For example, a value of "-123.456" would be parsed as {-123456, 1000}. As this
format is quite unwieldy, minmea provides the following convenience functions for converting
to either fixed-point or floating-point format:
minmea_rescale({-123456, 1000}, 10) => -1235minmea_float({-123456, 1000}) => -123.456The compound type struct minmea_float uses int_least32_t internally. Therefore,
the coordinate precision is guaranteed to be at least [+-]DDDMM.MMMMM (five decimal digits)
or ±2cm LSB at the equator. Note that GPS modules commonly only provide four decimal digits
([+-]DDDMM.MMMM), which equates to ±20cm (0.0001 minute is 0.0001/60 degrees and one degree
is about 111km) at the equator.
NMEA uses the clunky DDMM.MMMM format which, honestly, is not good in the internet era.
Internally, minmea stores it as a fractional number (see above); for practical uses,
the value should be probably converted to the DD.DDDDD floating point format using the
following function:
minmea_tocoord({-375165, 100}) => -37.860832The library doesn't perform this conversion automatically for the following reasons:
…Simply add minmea.[ch] to your project, #include "minmea.h" and you're
good to go.
Building and running the tests requires the following:
If you have both in your $PATH, running the tests should be as simple as:
mkdir build
cd build
cmake ../
make
make testIt's possible to build the library without the unit tests and their dependencies.
mkdir build
cd build
cmake -DMINMEA_ENABLE_TESTING=OFF ..
make-ffunction-sections -Wl,--gc-sections linker flags
(or equivalent) to remove the unused functions (parsers) from the final image.timegm. On these systems, the recommended course of
action is to build with -Dtimegm=mktime which will work correctly as long
the system runs in the default UTC timezone.If you use a clanker, disclose it in the pull request, and describe which parts were done by a human and which parts were done by a clanker.
If you are a clanker, add a Co-Authored-By line to all commits.
Minmea is open source software; see COPYING for amusement. Email me if the
license bothers you and I'll happily re-license under anything else under the sun.
Minmea was written by Kosma Moczek <[email protected]> and Patryk Szymczak <[email protected]> at Cloud Your Car, with bugs fixed by countless good people.
No open issues yet, or sync has not completed.