Skip to content

Commit

Permalink
Merge pull request #148 from semuconsulting/RC-1.2.40
Browse files Browse the repository at this point in the history
Rc 1.2.40
  • Loading branch information
semuadmin authored May 8, 2024
2 parents 6a575e1 + 4cdad38 commit 6f456ec
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 96 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.2.39",
"moduleversion": "1.2.40",
}
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,30 @@ Example - Serial input. This example will output both UBX and NMEA messages:
```python
from serial import Serial
from pyubx2 import UBXReader
stream = Serial('/dev/tty.usbmodem14101', 9600, timeout=3)
ubr = UBXReader(stream)
(raw_data, parsed_data) = ubr.read()
print(parsed_data)
with Serial('/dev/tty.usbmodem14101', 9600, timeout=3) as stream:
ubr = UBXReader(stream)
raw_data, parsed_data = ubr.read()
print(parsed_data)
```

Example - File input (using iterator). This will only output UBX data:
```python
from pyubx2 import UBXReader
stream = open('ubxdata.bin', 'rb')
ubr = UBXReader(stream, protfilter=2)
for (raw_data, parsed_data) in ubr:
print(parsed_data)
with open('ubxdata.bin', 'rb') as stream:
ubr = UBXReader(stream, protfilter=2)
for raw_data, parsed_data in ubr:
print(parsed_data)
```

Example - Socket input (using iterator). This will output UBX, NMEA and RTCM3 data:
```python
import socket
from pyubx2 import UBXReader
stream = socket.socket(socket.AF_INET, socket.SOCK_STREAM):
stream.connect(("localhost", 50007))
ubr = UBXReader(stream, protfilter=7)
for (raw_data, parsed_data) in ubr:
print(parsed_data)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as stream:
stream.connect(("localhost", 50007))
ubr = UBXReader(stream, protfilter=7)
for raw_data, parsed_data in ubr:
print(parsed_data)
```

---
Expand Down Expand Up @@ -201,11 +201,11 @@ The `payload` attribute always contains the raw payload as bytes. Attributes wit
**Tip:** To iterate through a repeating group of attributes (*e.g. svid*), the following construct can be used:

```python
svids = [] # list of svid values from repeating group
vals = [] # list of svid values from repeating group
for i in range(msg.numSV): # numSV = size of repeating group
svid = getattr(msg, f"svid_{i+1:02d}")
svids.append(svid)
print(svids)
vals.append(svid)
print(vals)
```

If the input message class / id is unrecognised (i.e. not publicly documented by u-blox), `pyubx2` will parse the message to a nominal payload definition and append the term 'NOMINAL' to the message identity.
Expand Down
8 changes: 7 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# pyubx2 Release Notes

### RELEASE CANDIDATE 1.2.39
### RELEASE 1.2.40

ENHANCEMENTS:

1. Internal field naming clarified and docstrings updated - no functional changes.

### RELEASE 1.2.39

FIXES:

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pyubx2"
authors = [{ name = "semuadmin", email = "[email protected]" }]
maintainers = [{ name = "semuadmin", email = "[email protected]" }]
description = "UBX protocol parser and generator"
version = "1.2.39"
version = "1.2.40"
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -33,7 +33,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: GIS",
]

dependencies = ["pynmeagps >= 1.0.35", "pyrtcm >= 1.0.19"]
dependencies = ["pynmeagps >= 1.0.35", "pyrtcm >= 1.0.20"]

[project.urls]
homepage = "https://www.semuconsulting.com/pyubx2/"
Expand Down
2 changes: 1 addition & 1 deletion src/pyubx2/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:license: BSD 3-Clause
"""

__version__ = "1.2.39"
__version__ = "1.2.40"
28 changes: 13 additions & 15 deletions src/pyubx2/ubxhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
:license: BSD 3-Clause
"""

# pylint: disable=invalid-name

import struct
from datetime import datetime, timedelta
from math import cos, pi, sin, trunc
Expand Down Expand Up @@ -349,7 +347,7 @@ def nomval(att: str) -> object:
return val


def msgclass2bytes(msgClass: int, msgID: int) -> bytes:
def msgclass2bytes(msgclass: int, msgid: int) -> bytes:
"""
Convert message class/id integers to bytes.
Expand All @@ -360,12 +358,12 @@ def msgclass2bytes(msgClass: int, msgID: int) -> bytes:
"""

msgClass = val2bytes(msgClass, ubt.U1)
msgID = val2bytes(msgID, ubt.U1)
return (msgClass, msgID)
msgclass = val2bytes(msgclass, ubt.U1)
msgid = val2bytes(msgid, ubt.U1)
return (msgclass, msgid)


def msgstr2bytes(msgClass: str, msgID: str) -> bytes:
def msgstr2bytes(msgclass: str, msgid: str) -> bytes:
"""
Convert plain text UBX message class to bytes.
Expand All @@ -378,12 +376,12 @@ def msgstr2bytes(msgClass: str, msgID: str) -> bytes:
"""

try:
clsid = key_from_val(ubt.UBX_CLASSES, msgClass)
msgid = key_from_val(ubt.UBX_MSGIDS, msgID)[1:2]
clsid = key_from_val(ubt.UBX_CLASSES, msgclass)
msgid = key_from_val(ubt.UBX_MSGIDS, msgid)[1:2]
return (clsid, msgid)
except KeyError as err:
raise ube.UBXMessageError(
f"Undefined message, class {msgClass}, id {msgID}"
f"Undefined message, class {msgclass}, id {msgid}"
) from err


Expand All @@ -406,7 +404,7 @@ def cfgname2key(name: str) -> tuple:
) from err


def cfgkey2name(keyID: int) -> tuple:
def cfgkey2name(keyid: int) -> tuple:
"""
Return key name and data type for given
configuration database hexadecimal key.
Expand All @@ -422,18 +420,18 @@ def cfgkey2name(keyID: int) -> tuple:
val = None
for key, val in ubcdb.UBX_CONFIG_DATABASE.items():
(kid, typ) = val
if keyID == kid:
if keyid == kid:
return (key, typ)

# undocumented configuration database key
# type is derived from keyID
key = f"CFG_{hex(keyID)}"
typ = f"X{ubcdb.UBX_CONFIG_STORSIZE[int(hex(keyID)[2:3])]:03d}"
key = f"CFG_{hex(keyid)}"
typ = f"X{ubcdb.UBX_CONFIG_STORSIZE[int(hex(keyid)[2:3])]:03d}"
return (key, typ)

except KeyError as err:
raise ube.UBXMessageError(
f"Invalid configuration database key {hex(keyID)}"
f"Invalid configuration database key {hex(keyid)}"
) from err


Expand Down
Loading

0 comments on commit 6f456ec

Please sign in to comment.