Skip to main content

NMEA Parser

A library used to decode NMEA data streams from GNSS receivers. Capable of parsing a text file containing NMEA data or reading from a serial port real time.

This library is currently in Beta and is subject to change any time.

Dependencies

PySerial is the only dependency. See requirements.txt.

Usage

See www.bek.sh/nmea-parser for a full manual.

Examples

Opening and Reading a Serial Port

It is highly sugested that you use all input streams within a context manager (with statement) as shown below.

from nmea import input_stream

stream = input_stream.GenericInputStream.open_stream('/dev/ttyACM0', 9600)

print(stream)

with stream:
    print(stream.get_line())

If you must use an input stream without a context manager, make sure that the ensure_closed() function is called prior to exit:

from nmea import input_stream

stream = input_stream.GenericInputStream.open_stream('/dev/ttyACM0', 9600)

print(stream)
print(stream.get_line())
stream.ensure_closed()      # You must not forget to manually close the stream.

Using a context manager ensures that the port is always closed should your program halt unexpectedly.

GenericInputStream.open_stream() also accepts all keyword arguments that are accepted by serial.Serial() in PySerial.

Opening and Reading a NMEA Dump file

Text files containing NMEA streams may also be used with this library. Just point the open_stream() function at the desired file:

from nmea import input_stream, data_frame

stream = input_stream.GenericInputStream.open_stream('sample-data/sample1.txt')

with stream:
    new_frame = data_frame.DataFrame.get_next_frame(stream)

    print("Current GPS time:", new_frame.gps_time)
    print("Current Latitude:", new_frame.latitude)
    print("Current Longitude:", new_frame.longitude)
    print("Current Speed:", new_frame.velocity)
    print("Current heading:", new_frame.track)

Getting Position Data and Logging to a Database

The DataFrame object contains properties that allow you to access your current position, movement, and information on all satellites used to calculate your fix. The logging module allows you to record these objects in an SQLite database.

from nmea import input_stream, data_frame, database_wrapper

stream = input_stream.GenericInputStream.open_stream('/dev/ttyACM0', 9600)

db = database_wrapper.SQLiteConnection.from_path('./example.sqlite')

print(stream)

with stream:
    while True:
        new_frame = data_frame.DataFrame.get_next_frame(stream)

        print("Current GPS time:", new_frame.gps_time)
        print("Current Latitude:", new_frame.latitude)
        print("Current Longitude:", new_frame.longitude)
        print("Current Speed:", new_frame.velocity)
        print("Current heading:", new_frame.track)
        print("Number of Satellites above:", new_frame.nsats)
        print("Individual Observations:")
        for obs in new_frame.sv_observations:
            print('\tPRN:', obs.prn)
            print('\t\tSignal to Noise:', obs.snr)
            print('\t\tAzimuth:', obs.azimuth)
            print('\t\tElevation:', obs.elevation)

        db.insert_dataframe(new_frame)

Metadata

Release files for nmea-parser 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nmea-parser 0.5.0
File Size Uploaded Provenance Actions
nmea-parser-0.5.0.tar.gz 12.8 kB Without provenance Details for nmea-parser-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nmea-parser 0.5.0
File Interpreter ABI Platform Actions
nmea_parser-0.5.0-py3-none-any.whl Python 3 none any Details for nmea_parser-0.5.0-py3-none-any.whl

Total release size: 31.6 kB

Release files / nmea-parser-0.5.0.tar.gz

Download URL nmea-parser-0.5.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0cd12782f05db3c2521a3f7b011d77ed8a6ede398193fad0620b4d26d2ad9c34
BLAKE2b-256 checksum
How to use checksums
dee4c526616c0c79a4e81749dbdc194a285c164ed5875e47d82959265ca76e8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / nmea_parser-0.5.0-py3-none-any.whl

Download URL nmea_parser-0.5.0-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bc0ec8b7d87668cb2378fff29d9f998227af0c28f3f8fd64af4595965052dd8
BLAKE2b-256 checksum
How to use checksums
3896d17f6f633364bc20b926429cb9ae1042f05c174ee2dbe36a740aa93d341d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Security for nmea-parser 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page