{"id":7592,"library":"pynmeagps","title":"pynmeagps","description":"pynmeagps is an original Python 3 parser aimed primarily at the subset of the NMEA 0183 © v4 protocol relevant to GNSS/GPS receivers. It provides functionalities for both parsing incoming NMEA messages from various streams (e.g., serial, socket, file) and generating outbound NMEA messages. The library is actively maintained, currently at version 1.1.2, with regular updates and bug fixes.","status":"active","version":"1.1.2","language":"en","source_language":"en","source_url":"https://github.com/semuconsulting/pynmeagps","tags":["NMEA","GPS","GNSS","parser","generator","protocol","serial-communication"],"install":[{"cmd":"pip install pynmeagps","lang":"bash","label":"Pip"},{"cmd":"conda install -c conda-forge pynmeagps","lang":"bash","label":"Conda"}],"dependencies":[],"imports":[{"note":"Used for reading and parsing NMEA messages from a stream or static strings.","symbol":"NMEAReader","correct":"from pynmeagps import NMEAReader"},{"note":"Represents a parsed NMEA message object and can be used for generating messages.","symbol":"NMEAMessage","correct":"from pynmeagps import NMEAMessage"},{"note":"Dictionary of recognised NMEA talker IDs. Also NMEA_MSGIDS, NMEA_MSGIDS_PROP for message IDs.","symbol":"NMEA_TALKERS","correct":"from pynmeagps.nmeatypes_core import NMEA_TALKERS"},{"note":"Constants for validation flags and error handling modes.","symbol":"VALCKSUM","correct":"from pynmeagps import VALCKSUM, VALMSGID, ERR_LOG"}],"quickstart":{"code":"from pynmeagps import NMEAReader, NMEAMessage, VALCKSUM, VALMSGID\n\n# Example 1: Parsing an NMEA message string\nnmea_string = b'$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47\\r\\n'\n\ntry:\n    # Using NMEAReader.parse() for individual messages\n    parsed_message = NMEAReader.parse(nmea_string, validate=VALCKSUM | VALMSGID)\n    print(f\"Parsed GGA message: {parsed_message}\")\n    print(f\"  Talker: {parsed_message.talker}\")\n    print(f\"  Message ID: {parsed_message.msgID}\")\n    print(f\"  Latitude: {parsed_message.lat}° {parsed_message.lat_dir}\")\n    print(f\"  Longitude: {parsed_message.lon}° {parsed_message.lon_dir}\")\nexcept Exception as e:\n    print(f\"Error parsing message: {e}\")\n\n# Example 2: Creating an NMEA message (e.g., GLL)\n# For a real application, ensure correct talker, msgID, and payload values\n# This example uses nominal values for illustration\nfrom datetime import datetime, time\n\ntry:\n    msg = NMEAMessage(\n        talker='GP', \n        msgID='GLL', \n        msgmode=0, \n        lat=48.12345, \n        lat_dir='N', \n        lon=11.67890, \n        lon_dir='E', \n        time=time(10, 30, 0),\n        status='A',\n        posMode='A'\n    )\n    # The to_nmea() method returns the checksummed NMEA message as bytes\n    generated_nmea = msg.to_nmea()\n    print(f\"Generated GLL message: {generated_nmea.decode('ascii').strip()}\")\nexcept Exception as e:\n    print(f\"Error generating message: {e}\")","lang":"python","description":"This quickstart demonstrates how to parse an NMEA message from a string using `NMEAReader.parse()` and how to construct a new NMEA message using the `NMEAMessage` class. It includes basic error handling and illustrates accessing parsed attributes and generating checksummed NMEA output. Note that NMEA messages should generally be byte strings (e.g., `b'$GPGGA...'`)."},"warnings":[{"fix":"Use the standard Python iterator pattern directly on the `NMEAReader` object. E.g., `for raw, parsed in NMEAReader(stream): ...`","message":"The `NMEAReader.iterate()` method was removed in Release 1.0.26.","severity":"breaking","affected_versions":">=1.0.26"},{"fix":"Install the `pygnssutils` package (`pip install pygnssutils`) and use its `gnssdump` utility.","message":"The command-line utility `nmeadump` has been removed and replaced by `gnssdump`.","severity":"deprecated","affected_versions":">=1.0.14"},{"fix":"Ensure your project uses Python 3.10 or later (currently requires Python >=3.10).","message":"Python 3.8 support was officially dropped as of Release 1.0.43.","severity":"gotcha","affected_versions":">=1.0.43"},{"fix":"From release 1.0.41 onwards, unknown messages can be parsed to a nominal structure by *not* setting the `VALMSGID` flag. For user-defined proprietary messages, pass a `userdefined` dictionary to `NMEAReader` or `NMEAReader.parse()`.","message":"Parsing unknown or proprietary NMEA message types might raise `NMEAParseError` if strict validation (`VALMSGID`) is enabled.","severity":"gotcha","affected_versions":"<1.0.41"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Either disable `VALMSGID` validation (e.g., `validate=VALCKSUM`) to parse it to a nominal structure, or provide a `userdefined` payload definition dictionary if it's a proprietary message.","cause":"Attempting to parse an NMEA message with an unknown or unsupported message ID while `VALMSGID` validation is active.","error":"NMEAParseError: Unknown msgID GNACN, msgmode GET"},{"fix":"Replace calls to `NMEAReader.iterate()` with direct iteration over the `NMEAReader` object itself (e.g., `for raw, parsed in nmr: ...`).","cause":"Using the `iterate()` method on an `NMEAReader` instance, which was removed.","error":"AttributeError: 'NMEAReader' object has no attribute 'iterate'"},{"fix":"Version 1.1.2 includes a workaround for this specific Unicore firmware error. Update to `pynmeagps` version 1.1.2 or later.","cause":"A known firmware error in certain Unicore UM9* devices generates malformed NMEA GLL sentences with incorrect negative latitude values.","error":"Incorrect latitude values (e.g., negative) in parsed GLL sentences from Unicore UM9* firmware."}]}