Skip to main content

A package to parse general form of NMEA sentences. It is not specific to just certain devices only.

Project description

pyNMEAParser

A package to parse general form of NMEA sentences. It is not specific to just certain devices only. After successfully parsing an NMEA data, it will return a list of fields in the NMEA sentence.

API

NMEAParser()

Description: The constructor for NMEAParser class.

Returns: NMEAParser object.

# Create NMEAParser object
parser = NMEAParser()

add_handler(id:str, fn:Callable)

Description: Attach a handler function to be called when id matches the key.

Parameters:

id: A string representing the key.

fn: The handler function of which will be called if id matches the key. The function needs to accept a list as a parameter.

def my_handler(fields):
    print(fields)


parser.add_handler('GPGGA', my_handler)

process(sentence:str)

Description: Process the string passed to the function. This string will be concatenated with the previously incomplete processed string.

Parameters:

sentence: NMEA string format. This can be an arbitrary data, but needs to adhere to NMEA standard.

# Process an NMEA string
parser.process('$GPZDA,024008.97,24,11,2022,00,00*62')
parser.process('$MY_OWN,SOME,DATA,HERE*2F') # Can be arbitrary as long as adhering to NMEA standard.

get_buffer()

Description: Process the string passed to the function. This string will be concatenated with the previously incomplete processed string.

Returns: The string currently in the buffer.

print('Unprocessed string:', parser.get_buffer()) # Display the string that is still not processed.

Usage

Examples

Simple parse

from pynmeaparser import NMEAParser

def my_handler(fields):
    print(fields)

parser = NMEAParser() # Create parser object
parser.add_handler('GPZDA', handler) # Add handler. The handler function will be called if the first field contains the key.
parser.process('$GPZDA,024008.97,24,11,2022,00,00*62') # Process NMEA string here.
# Output: ['GPZDA', '024008.97', '24', '11', '2022', '00', '00']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynmeaparser-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynmeaparser-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pynmeaparser-1.0.0.tar.gz.

File metadata

  • Download URL: pynmeaparser-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pynmeaparser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f7ed05b9c7af000e48f89c0ef0bb018b4fed153538b89500697476818b1d05ab
MD5 36a3cb3500989ec82782eeb58cdf5a38
BLAKE2b-256 ed5ce6c98ddf7cb44265343cf9dda97c4304cc7c1699587bb627c470a571a7dc

See more details on using hashes here.

File details

Details for the file pynmeaparser-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pynmeaparser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pynmeaparser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dee4d42b9210b053c850569954911bf97b324e2118189e6dbbe24a8f9825fd38
MD5 d0cfe06e4c2ff4a38105bfbee787077b
BLAKE2b-256 ee8182caae03a17abaaced920106e3d8e432056929b430bf7d2a5618c3e3c296

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page