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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7ed05b9c7af000e48f89c0ef0bb018b4fed153538b89500697476818b1d05ab
|
|
| MD5 |
36a3cb3500989ec82782eeb58cdf5a38
|
|
| BLAKE2b-256 |
ed5ce6c98ddf7cb44265343cf9dda97c4304cc7c1699587bb627c470a571a7dc
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee4d42b9210b053c850569954911bf97b324e2118189e6dbbe24a8f9825fd38
|
|
| MD5 |
d0cfe06e4c2ff4a38105bfbee787077b
|
|
| BLAKE2b-256 |
ee8182caae03a17abaaced920106e3d8e432056929b430bf7d2a5618c3e3c296
|