Python bindings for nmealib (NMEA 0183 and NMEA 2000 parsing)
Project description
nmealib
Modern C++20 library for parsing NMEA 0183 sentences and NMEA 2000 CAN messages, with typed models, validation, and extensible message handling.
Why nmealib
- Unified parsing for NMEA 0183 and NMEA 2000
- Python and C++ libraries with consistent APIs
- Typed message classes for safer integrations
- Built-in validation (including NMEA 0183 checksum handling)
- Extensible architecture for new sentence/PGN support
- CLI tool for quick parsing and debugging
- Unit-tested codebase
Quick Start
CLI
Download the latest release from GitHub Releases, then parse a sentence:
./nmealib-cli '$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47'
Parse from a file/pipe:
cat nmea_sentences.txt | ./nmealib-cli
C++ Library
Add the library to your CMake project (see Installation Guide), then include and use it:
#include <nmealib.h>
int main() {
std::string sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";
try {
auto msg = nmealib::NMEA0183::GGA::parse(sentence);
std::cout << "Parsed GGA message: " << msg.toString() << std::endl;
std::cout << "Latitude: " << msg.getLatitude() << std::endl;
// Access other fields as needed
} catch (const nmealib::ParseException& e) {
std::cerr << "Failed to parse sentence: " << e.what() << std::endl;
}
return 0;
}
See using-nmealib for a full example project demonstrating library usage.
Python Library (PyPI)
Install from PyPI:
python -m pip install nmealib
Quick usage example:
import nmealib
raw_0183 = "$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W,A,V*6A\r\n"
raw_2000 = "09F11260:342C71FF7FFF7FFD"
try:
msg_0183 = nmealib.nmea0183.Nmea0183Factory.create(raw_0183)
print(type(msg_0183).__name__) # RMC
print(msg_0183.get_latitude(), msg_0183.get_longitude())
msg_2000 = nmealib.nmea2000.Nmea2000Factory.create(raw_2000)
print(type(msg_2000).__name__) # PGN127250
except nmealib.NmeaException as exc:
print(f"Parse error: {exc}")
Use in PlatformIO
The library is published on the PlatformIO registry:
https://registry.platformio.org/libraries/fliuzzi02/nmealib
Add the dependency in your platformio.ini:
lib_deps =
fliuzzi02/nmealib
Or install it with the PlatformIO CLI:
pio pkg install --library "fliuzzi02/nmealib"
An embedded reference example is available in examples/platformio-esp32.
Documentation
Companion usage repository: using-nmealib
Project Structure
nmealib/
├── .github/ # CI workflow files
├── app/ # CLI entrypoint
├── docs/ # Documentation
├── examples/ # Usage examples (including PlatformIO)
├── include/
│ ├── nmealib.h # Main umbrella header
│ └── nmealib/
│ ├── nmeaException.h # Custom exception class
│ ├── message.h # Base Message class and utilities
│ ├── nmea0183.h # Base NMEA 0183 class and utilities
│ ├── nmea2000.h # Base NMEA 2000 class and utilities
│ ├── detail/ # Internal shared parsing/error helpers
│ ├── nmea0183/ # NMEA 0183 message type headers
│ └── nmea2000/ # NMEA 2000 message type headers
├── scripts/ # CI/dev utility scripts
├── src/ # Library implementation and parsing logic
├── tests/ # Unit tests
├── CMakeLists.txt # Root CMake project configuration
├── CMakePresets.json # Preset build/test configurations
├── README.md # This file
└── library.json # PlatformIO package manifest
Supported Protocols
All messages/PGNs listed in the Protocol Support are currently implemented and supported.
Messages/PGNs not listed are currently considered not implemented.
License
Licensed under MIT. See LICENSE.
Support
- Open an issue in this repository for bugs/feature requests.
- For usage questions, include sample input data and expected output.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nmealib-0.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nmealib-0.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b16914e3d100f8253cfde8f76224286da8ba7a913e39f73d7587e514358f69
|
|
| MD5 |
8b44ecb58c53ce94bf16d60b9cce5b34
|
|
| BLAKE2b-256 |
620110a1be010603bec6457810c8ef5d94bc537abad7dab06501ec2eb1cfe517
|