Skip to content

Commit

Permalink
Merge pull request #66 from semuconsulting/RC-1.0.42
Browse files Browse the repository at this point in the history
RC 1.0.42
  • Loading branch information
semuadmin authored Sep 17, 2024
2 parents 3814785 + 7301df9 commit 6041dfa
Show file tree
Hide file tree
Showing 16 changed files with 2,146 additions and 1,081 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"editor.formatOnSave": true,
"modulename": "${workspaceFolderBasename}",
"distname": "${workspaceFolderBasename}",
"moduleversion": "1.0.41",
"moduleversion": "1.0.42",
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Companion libraries are available which handle UBX © and RTCM3 © messa
![Contributors](https://img.shields.io/github/contributors/semuconsulting/pynmeagps.svg)
![Open Issues](https://img.shields.io/github/issues-raw/semuconsulting/pynmeagps)

The library implements a comprehensive set of outbound (GET) and inbound (SET/POLL) GNSS NMEA messages relating to GNSS/GPS devices, but is readily [extensible](#extensibility). Refer to [`NMEA_MSGIDS`](https://github.com/semuconsulting/pynmeagps/blob/master/src/pynmeagps/nmeatypes_core.py#L172) and [`NMEA_MSGIDS_PROP`](https://github.com/semuconsulting/pynmeagps/blob/master/src/pynmeagps/nmeatypes_core.py#L224) for the complete dictionary of standard and proprietary messages currently supported. While the [NMEA 0183 protocol itself is proprietary](https://www.nmea.org/nmea-0183.html), the definitions here have been collated from public domain sources.
The library implements a comprehensive set of outbound (GET) and inbound (SET/POLL) GNSS NMEA messages relating to GNSS/GPS and Maritime devices, but is readily [extensible](#extensibility). Refer to [`NMEA_MSGIDS`](https://github.com/semuconsulting/pynmeagps/blob/master/src/pynmeagps/nmeatypes_core.py#L172) and [`NMEA_MSGIDS_PROP`](https://github.com/semuconsulting/pynmeagps/blob/master/src/pynmeagps/nmeatypes_core.py#L224) for the complete dictionary of standard and proprietary messages currently supported. While the [NMEA 0183 protocol itself is proprietary](https://www.nmea.org/nmea-0183.html), the definitions here have been collated from public domain sources.

Sphinx API Documentation in HTML format is available at [https://www.semuconsulting.com/pynmeagps](https://www.semuconsulting.com/pynmeagps).

Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# pynmeagps Release Notes

### RELEASE 1.0.42

ENHANCEMENTS:

1. Add additional maritime talker IDs and NMEA sentence definitions.
1. Add `DTL` date format ddmmyyyy.

### RELEASE 1.0.41

ENHANCEMENTS:
Expand Down
8 changes: 8 additions & 0 deletions docs/pynmeagps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ pynmeagps.nmeatypes\_get module
:undoc-members:
:show-inheritance:

pynmeagps.nmeatypes\_get\_prop module
-------------------------------------

.. automodule:: pynmeagps.nmeatypes_get_prop
:members:
:undoc-members:
:show-inheritance:

pynmeagps.nmeatypes\_poll module
--------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pynmeagps"
authors = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }]
maintainers = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }]
description = "NMEA protocol parser and generator"
version = "1.0.41"
version = "1.0.42"
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.8"
Expand Down
3 changes: 3 additions & 0 deletions src/pynmeagps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from pynmeagps.nmeareader import NMEAReader
from pynmeagps.nmeatypes_core import *
from pynmeagps.nmeatypes_get import *
from pynmeagps.nmeatypes_get_prop import *
from pynmeagps.nmeatypes_poll import *
from pynmeagps.nmeatypes_set import *
from pynmeagps.socket_wrapper import SocketWrapper

version = __version__
2 changes: 1 addition & 1 deletion src/pynmeagps/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:license: BSD 3-Clause
"""

__version__ = "1.0.41"
__version__ = "1.0.42"
19 changes: 15 additions & 4 deletions src/pynmeagps/nmeahelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pynmeagps.nmeatypes_core import (
DM,
DT,
DTL,
GPSEPOCH0,
LA,
LN,
Expand Down Expand Up @@ -150,13 +151,18 @@ def date2utc(dates: str, form: str = DT) -> datetime.date:
Convert NMEA Date to UTC datetime.
:param str dates: NMEA date
:param str form: date format DT = ddmmyy, DM = mmddyy (DT)
:param str form: date format DT = ddmmyy, DTL = ddmmyyyy, DM = mmddyy (DT)
:return: UTC date YYyy:mm:dd
:rtype: datetime.date
"""

try:
dform = "%m%d%y" if form == DM else "%d%m%y"
if form == "DM":
dform = "%m%d%y"
elif form == "DTL":
dform = "%d%m%Y"
else:
dform = "%d%m%y"
utc = datetime.strptime(dates, dform)
return utc.date()
except (TypeError, ValueError):
Expand Down Expand Up @@ -201,13 +207,18 @@ def date2str(dat: datetime.date, form: str = DT) -> str:
Convert datetime.date to NMEA formatted string.
:param datetime.date dat: date
:param str form: date format DT = ddmmyy, DM = mmddyy (DT)
:param str form: date format DT = ddmmyy, DTL = ddmmyyyy, DM = mmddyy (DT)
:return: NMEA formatted date string
:rtype: str
"""

try:
dform = "%m%d%y" if form == DM else "%d%m%y"
if form == DM:
dform = "%m%d%y"
elif form == DTL:
dform = "%d%m%Y"
else:
dform = "%d%m%y"
return dat.strftime(dform)
except (AttributeError, TypeError, ValueError):
return ""
Expand Down
18 changes: 11 additions & 7 deletions src/pynmeagps/nmeamessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pynmeagps.exceptions as nme
import pynmeagps.nmeatypes_core as nmt
import pynmeagps.nmeatypes_get as nmg
import pynmeagps.nmeatypes_get_prop as nmgp
import pynmeagps.nmeatypes_poll as nmp
import pynmeagps.nmeatypes_set as nms
from pynmeagps.nmeahelpers import (
Expand Down Expand Up @@ -64,18 +65,19 @@ def __init__(
self._logger = getLogger(__name__)
self._validate = validate
self._nominal = False # flag for unrecognised NMEA sentence types
self._proprietary = False # proprietary message definition

if msgmode not in (0, 1, 2):
raise nme.NMEAMessageError(
f"Invalid msgmode {msgmode} - must be 0, 1 or 2."
)
if talker not in nmt.NMEA_TALKERS:
raise nme.NMEAMessageError(f"Unknown talker {talker}.")
if (
msgID not in (nmt.NMEA_MSGIDS)
and msgID not in (nmt.NMEA_MSGIDS_PROP)
and msgID not in (nmt.PROP_MSGIDS)
):
if msgID in nmt.NMEA_MSGIDS:
self._proprietary = False
elif msgID in nmt.NMEA_MSGIDS_PROP or msgID in nmt.PROP_MSGIDS:
self._proprietary = True
else:
if self._validate & nmt.VALMSGID:
raise nme.NMEAMessageError(
f"Unknown msgID {talker}{msgID}, msgmode {('GET','SET','POLL')[msgmode]}."
Expand Down Expand Up @@ -293,6 +295,8 @@ def _get_dict(self, **kwargs) -> dict:
return nmp.NMEA_PAYLOADS_POLL[key]
if self._mode == nmt.SET:
return nms.NMEA_PAYLOADS_SET[key]
if self._proprietary:
return nmgp.NMEA_PAYLOADS_GET_PROP[key]
return nmg.NMEA_PAYLOADS_GET[key]
except KeyError as err:
erm = f"Unknown msgID {key} msgmode {('GET', 'SET', 'POLL')[self._mode]}."
Expand Down Expand Up @@ -520,7 +524,7 @@ def val2str(val, att: str, hpmode: bool = False) -> str:
vals = ddd2dmm(val, att, hpmode)
elif att == nmt.TM:
vals = time2str(val)
elif att in (nmt.DT, nmt.DM):
elif att in (nmt.DT, nmt.DTL, nmt.DM):
vals = date2str(val, att)
else:
raise nme.NMEATypeError(f"Unknown attribute type {att}.")
Expand Down Expand Up @@ -551,7 +555,7 @@ def nomval(att: str) -> object:
val = 0
elif att == nmt.TM:
val = datetime.now(timezone.utc).time()
elif att == nmt.DT:
elif att in (nmt.DT, nmt.DTL, nmt.DM):
val = datetime.now(timezone.utc).date()
else:
raise nme.NMEATypeError(f"Unknown attribute type {att}.")
Expand Down
Loading

0 comments on commit 6041dfa

Please sign in to comment.