pygnssutils 1.3.0__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pygnssutils-1.3.0/src/pygnssutils.egg-info → pygnssutils-1.3.2}/PKG-INFO +7 -8
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/README.md +3 -3
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/pyproject.toml +9 -16
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/__init__.py +3 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/_version.py +1 -1
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/globals.py +2 -1
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssntripclient.py +108 -59
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssreader.py +131 -13
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssserver.py +1 -1
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssserver_cli.py +3 -3
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssstreamer.py +28 -5
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssstreamer_cli.py +34 -3
- {pygnssutils-1.3.0 → pygnssutils-1.3.2/src/pygnssutils.egg-info}/PKG-INFO +7 -8
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils.egg-info/requires.txt +3 -3
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_cli.py +4 -4
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_gnssstreamer.py +11 -4
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_static.py +3 -3
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/LICENSE +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/setup.cfg +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/exceptions.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/gnssntripclient_cli.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/helpers.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_reader.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_bds.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_gal.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_glo.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_gps.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_irn.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_qzs.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rawnav_subframes_sba.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_conv.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_conv_cli.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_conv_met.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_conv_nav.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_conv_obs.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_globals.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/rinex_helpers.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils/socket_server.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils.egg-info/SOURCES.txt +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils.egg-info/dependency_links.txt +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils.egg-info/entry_points.txt +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/src/pygnssutils.egg-info/top_level.txt +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_rawnav.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_rinex.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_rinex_defs.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_rinex_parse.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_socketwrapper.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_sourcetable.py +0 -0
- {pygnssutils-1.3.0 → pygnssutils-1.3.2}/tests/test_stream.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygnssutils
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: GNSS Command Line Utilities
|
|
5
5
|
Author: Steve Smith
|
|
6
6
|
Author-email: semuadmin@semuconsulting.com
|
|
@@ -21,7 +21,6 @@ Classifier: Intended Audience :: Developers
|
|
|
21
21
|
Classifier: Intended Audience :: Science/Research
|
|
22
22
|
Classifier: Intended Audience :: End Users/Desktop
|
|
23
23
|
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
25
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
26
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
27
26
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -34,13 +33,13 @@ Requires-Python: >=3.10
|
|
|
34
33
|
Description-Content-Type: text/markdown
|
|
35
34
|
License-File: LICENSE
|
|
36
35
|
Requires-Dist: certifi>=2026.0.0
|
|
37
|
-
Requires-Dist: pynmeagps>=1.
|
|
36
|
+
Requires-Dist: pynmeagps>=1.2.0
|
|
38
37
|
Requires-Dist: pyqgc>=1.0.1
|
|
39
38
|
Requires-Dist: pyrtcm>=1.2.1
|
|
40
39
|
Requires-Dist: pysbf2>=1.0.7
|
|
41
40
|
Requires-Dist: pyserial>=3.5
|
|
42
|
-
Requires-Dist: pyspartn>=1.1.
|
|
43
|
-
Requires-Dist: pyubx2>=1.
|
|
41
|
+
Requires-Dist: pyspartn>=1.1.2
|
|
42
|
+
Requires-Dist: pyubx2>=1.4.1
|
|
44
43
|
Requires-Dist: pyubxutils>=1.0.6
|
|
45
44
|
Requires-Dist: pyunigps>=1.0.1
|
|
46
45
|
Dynamic: license-file
|
|
@@ -73,8 +72,8 @@ pygnssutils is an original series of Python GNSS utility classes and CLI tools b
|
|
|
73
72
|
|
|
74
73
|
Originally developed in support of the [PyGPSClient](https://github.com/semuconsulting/PyGPSClient) GUI GNSS application, the utilities provided by pygnssutils can also be used in their own right:
|
|
75
74
|
|
|
76
|
-
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC and
|
|
77
|
-
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC and
|
|
75
|
+
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN message protocols concurrently from a single stream.
|
|
76
|
+
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN protocols.
|
|
78
77
|
1. `GNSSSocketServer` class and its associated [`gnssserver`](#gnssserver) CLI utility. This implements a TCP Socket Server for GNSS data streams which is also capable of being run as a simple NTRIP Server/Caster.
|
|
79
78
|
1. `GNSSNTRIPClient` class and its associated [`gnssntripclient`](#gnssntripclient) CLI utility. This implements
|
|
80
79
|
a simple NTRIP Client which receives RTCM3 or SPARTN correction data from an NTRIP Server and (optionally) sends this to a
|
|
@@ -154,7 +153,7 @@ Refer to the [Sphinx API documentation](https://www.semuconsulting.com/pygnssuti
|
|
|
154
153
|
class pygnssutils.gnssstreamer.GNSSStreamer(**kwargs)
|
|
155
154
|
```
|
|
156
155
|
|
|
157
|
-
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN
|
|
156
|
+
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN and NTRIP protocols - individual protocols can be filtered via the `protfilter` arguments.
|
|
158
157
|
|
|
159
158
|
- The CLI utility can acquire data from any one of the following sources:
|
|
160
159
|
- `port`: serial port e.g. `COM3` or `/dev/ttyACM1` (can specify `--baudrate` and `--timeout`)
|
|
@@ -26,8 +26,8 @@ pygnssutils is an original series of Python GNSS utility classes and CLI tools b
|
|
|
26
26
|
|
|
27
27
|
Originally developed in support of the [PyGPSClient](https://github.com/semuconsulting/PyGPSClient) GUI GNSS application, the utilities provided by pygnssutils can also be used in their own right:
|
|
28
28
|
|
|
29
|
-
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC and
|
|
30
|
-
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC and
|
|
29
|
+
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN message protocols concurrently from a single stream.
|
|
30
|
+
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN protocols.
|
|
31
31
|
1. `GNSSSocketServer` class and its associated [`gnssserver`](#gnssserver) CLI utility. This implements a TCP Socket Server for GNSS data streams which is also capable of being run as a simple NTRIP Server/Caster.
|
|
32
32
|
1. `GNSSNTRIPClient` class and its associated [`gnssntripclient`](#gnssntripclient) CLI utility. This implements
|
|
33
33
|
a simple NTRIP Client which receives RTCM3 or SPARTN correction data from an NTRIP Server and (optionally) sends this to a
|
|
@@ -107,7 +107,7 @@ Refer to the [Sphinx API documentation](https://www.semuconsulting.com/pygnssuti
|
|
|
107
107
|
class pygnssutils.gnssstreamer.GNSSStreamer(**kwargs)
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN
|
|
110
|
+
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN and NTRIP protocols - individual protocols can be filtered via the `protfilter` arguments.
|
|
111
111
|
|
|
112
112
|
- The CLI utility can acquire data from any one of the following sources:
|
|
113
113
|
- `port`: serial port e.g. `COM3` or `/dev/ttyACM1` (can specify `--baudrate` and `--timeout`)
|
|
@@ -26,7 +26,6 @@ classifiers = [
|
|
|
26
26
|
"Intended Audience :: Science/Research",
|
|
27
27
|
"Intended Audience :: End Users/Desktop",
|
|
28
28
|
"Programming Language :: Python :: 3",
|
|
29
|
-
"Programming Language :: Python :: 3.10",
|
|
30
29
|
"Programming Language :: Python :: 3.11",
|
|
31
30
|
"Programming Language :: Python :: 3.12",
|
|
32
31
|
"Programming Language :: Python :: 3.13",
|
|
@@ -39,13 +38,13 @@ classifiers = [
|
|
|
39
38
|
|
|
40
39
|
dependencies = [
|
|
41
40
|
"certifi>=2026.0.0",
|
|
42
|
-
"pynmeagps>=1.
|
|
41
|
+
"pynmeagps>=1.2.0",
|
|
43
42
|
"pyqgc>=1.0.1",
|
|
44
43
|
"pyrtcm>=1.2.1",
|
|
45
44
|
"pysbf2>=1.0.7",
|
|
46
45
|
"pyserial>=3.5",
|
|
47
|
-
"pyspartn>=1.1.
|
|
48
|
-
"pyubx2>=1.
|
|
46
|
+
"pyspartn>=1.1.2",
|
|
47
|
+
"pyubx2>=1.4.1",
|
|
49
48
|
"pyubxutils>=1.0.6",
|
|
50
49
|
"pyunigps>=1.0.1",
|
|
51
50
|
]
|
|
@@ -83,34 +82,28 @@ test = [
|
|
|
83
82
|
"Sphinx",
|
|
84
83
|
"sphinx-rtd-theme",
|
|
85
84
|
]
|
|
86
|
-
optional = []
|
|
85
|
+
optional = ["cryptography>=45.0.0"]
|
|
87
86
|
deploy = [{ include-group = "build" }, { include-group = "test" }]
|
|
88
87
|
|
|
89
88
|
[tool.setuptools.dynamic]
|
|
90
89
|
version = { attr = "pygnssutils._version.__version__" }
|
|
91
90
|
|
|
92
91
|
[tool.black]
|
|
93
|
-
target-version = ['
|
|
92
|
+
target-version = ['py311']
|
|
94
93
|
|
|
95
94
|
[tool.isort]
|
|
96
|
-
py_version =
|
|
95
|
+
py_version = 311
|
|
97
96
|
profile = "black"
|
|
98
97
|
|
|
99
98
|
[tool.bandit]
|
|
100
|
-
exclude_dirs = [
|
|
101
|
-
skips = [
|
|
102
|
-
"B104",
|
|
103
|
-
"B105",
|
|
104
|
-
"B307",
|
|
105
|
-
"B311",
|
|
106
|
-
] # bind 0.0.0.0; hard coded pwd, use of eval, random gen
|
|
107
|
-
|
|
99
|
+
exclude_dirs = []
|
|
100
|
+
skips = []
|
|
108
101
|
|
|
109
102
|
[tool.pylint]
|
|
110
103
|
jobs = 0
|
|
111
104
|
recursive = "y"
|
|
112
105
|
reports = "y"
|
|
113
|
-
py-version = "3.
|
|
106
|
+
py-version = "3.11"
|
|
114
107
|
fail-under = "9.8"
|
|
115
108
|
fail-on = "E,F"
|
|
116
109
|
clear-cache-post-run = "y"
|
|
@@ -7,6 +7,8 @@ Created on 27 Sep 2020
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from pynmeagps import SocketWrapper
|
|
10
|
+
from pyspartn import date2timetag, naive2aware
|
|
11
|
+
from pyubx2 import ERR_IGNORE, ERR_LOG, ERR_RAISE
|
|
10
12
|
from pyubxutils.ubxsimulator import UBXSimulator
|
|
11
13
|
|
|
12
14
|
from pygnssutils._version import __version__
|
|
@@ -18,6 +20,7 @@ from pygnssutils.gnssreader import (
|
|
|
18
20
|
QGC_PROTOCOL,
|
|
19
21
|
RTCM3_PROTOCOL,
|
|
20
22
|
SBF_PROTOCOL,
|
|
23
|
+
SPARTN_PROTOCOL,
|
|
21
24
|
UBX_PROTOCOL,
|
|
22
25
|
UNI_PROTOCOL,
|
|
23
26
|
GNSSReader,
|
|
@@ -21,7 +21,7 @@ DEFAULT_BUFSIZE = 4096 # buffer size for NTRIP client
|
|
|
21
21
|
"""Default socket buffer size"""
|
|
22
22
|
EARTH_RADIUS = 6371 # km
|
|
23
23
|
"""Earth radius in km"""
|
|
24
|
-
ENV_NTRIP_PASSWORD = "PYGPSCLIENT_PASSWORD"
|
|
24
|
+
ENV_NTRIP_PASSWORD = "PYGPSCLIENT_PASSWORD" # nosec
|
|
25
25
|
""" Environment variable for NTRIP password """
|
|
26
26
|
ENV_NTRIP_USER = "PYGPSCLIENT_USER"
|
|
27
27
|
""" Environment variable for NTRIP user """
|
|
@@ -221,6 +221,7 @@ TOPIC_FREQ = "/pp/frequencies/Lb"
|
|
|
221
221
|
NTRIP_EVENT = "<<ntrip_read>>"
|
|
222
222
|
SPARTN_EVENT = "<<spartn_read>>"
|
|
223
223
|
SPARTN_PPSERVER = "pp.services.u-blox.com"
|
|
224
|
+
SPARTN_DEFAULTKEY = "abcd1234abcd1234abcd1234abcd1234"
|
|
224
225
|
OUTPORT_SPARTN = 8883
|
|
225
226
|
PMP_DATARATES = {
|
|
226
227
|
"B600": 600,
|
|
@@ -39,16 +39,15 @@ from socket import (
|
|
|
39
39
|
gaierror,
|
|
40
40
|
gethostbyname,
|
|
41
41
|
socket,
|
|
42
|
-
timeout,
|
|
43
42
|
)
|
|
43
|
+
from socket import timeout as socktimeout
|
|
44
44
|
from ssl import PROTOCOL_TLS_CLIENT, SSLCertVerificationError, SSLContext, SSLError
|
|
45
45
|
from threading import Event, Thread
|
|
46
46
|
from types import NoneType
|
|
47
|
-
from typing import Any
|
|
47
|
+
from typing import Any, Literal
|
|
48
48
|
|
|
49
49
|
from certifi import where as findcacerts
|
|
50
50
|
from pynmeagps import GET, NMEAMessage, SocketWrapper
|
|
51
|
-
from pyspartn import SPARTNReader
|
|
52
51
|
from serial import Serial
|
|
53
52
|
|
|
54
53
|
from pygnssutils._version import __version__ as VERSION
|
|
@@ -75,9 +74,10 @@ from pygnssutils.globals import (
|
|
|
75
74
|
OUTPORT_NTRIP,
|
|
76
75
|
PYGNSSUTILS_CRT,
|
|
77
76
|
PYGNSSUTILS_CRTPATH,
|
|
77
|
+
SPARTN_DEFAULTKEY,
|
|
78
78
|
VERBOSITY_MEDIUM,
|
|
79
79
|
)
|
|
80
|
-
from pygnssutils.gnssreader import ERR_LOG, RTCM3_PROTOCOL, GNSSReader
|
|
80
|
+
from pygnssutils.gnssreader import ERR_LOG, RTCM3_PROTOCOL, SPARTN_PROTOCOL, GNSSReader
|
|
81
81
|
from pygnssutils.helpers import find_mp_distance, ipprot2int, set_logging
|
|
82
82
|
|
|
83
83
|
TIMEOUT = 3
|
|
@@ -100,25 +100,30 @@ class GNSSNTRIPClient:
|
|
|
100
100
|
def __init__(
|
|
101
101
|
self,
|
|
102
102
|
app: Any | NoneType = None,
|
|
103
|
-
|
|
103
|
+
retries: int = MAX_RETRY,
|
|
104
|
+
retryinterval: int = RETRY_INTERVAL,
|
|
105
|
+
timeout: int = INACTIVITY_TIMEOUT,
|
|
106
|
+
tlscrtpath: str = getenv(PYGNSSUTILS_CRTPATH, PYGNSSUTILS_CRT),
|
|
107
|
+
verbosity: int = VERBOSITY_MEDIUM,
|
|
108
|
+
logtofile: str = "",
|
|
104
109
|
):
|
|
105
110
|
"""
|
|
106
111
|
Constructor.
|
|
107
112
|
|
|
108
113
|
:param Any | NoneType app: application from which this class is invoked (None)
|
|
109
|
-
:param int retries:
|
|
110
|
-
:param int retryinterval:
|
|
111
|
-
:param int timeout:
|
|
112
|
-
:param str tlscrtpath:
|
|
114
|
+
:param int retries: maximum failed connection retries (5)
|
|
115
|
+
:param int retryinterval: retry interval in seconds (10)
|
|
116
|
+
:param int timeout: inactivity timeout in seconds (10)
|
|
117
|
+
:param str tlscrtpath: Path to self-sign TLS certificate ("pygnssutils.crt")
|
|
118
|
+
:param int verbosity: verbosity (1)
|
|
119
|
+
:param str logtofile: fully qualified path to logfile, or "" for none ("")
|
|
113
120
|
"""
|
|
114
121
|
|
|
115
122
|
self.__app = app # Reference to calling application class (if applicable)
|
|
116
123
|
# configure logger with name "pygnssutils" in calling module
|
|
117
|
-
self.verbosity =
|
|
118
|
-
self.logtofile =
|
|
119
|
-
self._tlscrtpath =
|
|
120
|
-
"tlscrtpath", getenv(PYGNSSUTILS_CRTPATH, PYGNSSUTILS_CRT)
|
|
121
|
-
)
|
|
124
|
+
self.verbosity = verbosity
|
|
125
|
+
self.logtofile = logtofile
|
|
126
|
+
self._tlscrtpath = tlscrtpath
|
|
122
127
|
self.logger = getLogger(__name__)
|
|
123
128
|
for module in ("pyrtcm", "pyspartn"):
|
|
124
129
|
set_logging(getLogger(module), self.verbosity, self.logtofile)
|
|
@@ -128,9 +133,9 @@ class GNSSNTRIPClient:
|
|
|
128
133
|
self.settings = self._settings
|
|
129
134
|
|
|
130
135
|
try:
|
|
131
|
-
self._retries =
|
|
132
|
-
self._retryinterval =
|
|
133
|
-
self._timeout =
|
|
136
|
+
self._retries = retries
|
|
137
|
+
self._retryinterval = retryinterval
|
|
138
|
+
self._timeout = timeout
|
|
134
139
|
except (ParameterError, ValueError, TypeError) as err:
|
|
135
140
|
msg = f"Invalid input arguments {err}"
|
|
136
141
|
self._app_update_status(False, (str(err), ERRCOL))
|
|
@@ -163,7 +168,32 @@ class GNSSNTRIPClient:
|
|
|
163
168
|
|
|
164
169
|
self.stop()
|
|
165
170
|
|
|
166
|
-
def run(
|
|
171
|
+
def run(
|
|
172
|
+
self,
|
|
173
|
+
server: str = "",
|
|
174
|
+
port: int = 2101,
|
|
175
|
+
https: bool = False,
|
|
176
|
+
selfsign: bool = False,
|
|
177
|
+
mountpoint: str = "",
|
|
178
|
+
datatype: Literal["RTCM", "SPARTN"] = "RTCM",
|
|
179
|
+
version: Literal["1.0", "2.0"] = "2.0",
|
|
180
|
+
ntripuser: str = "anon",
|
|
181
|
+
ntrippassword: str = "password",
|
|
182
|
+
ggainterval: int = -1, # -1 = None
|
|
183
|
+
ggamode: Literal[0, 1] = 0,
|
|
184
|
+
reflat: float = 0.0,
|
|
185
|
+
reflon: float = 0.0,
|
|
186
|
+
refalt: float = 0.0,
|
|
187
|
+
refsep: float = 0.0,
|
|
188
|
+
spartndecode: bool = False,
|
|
189
|
+
spartnkey: str = SPARTN_DEFAULTKEY,
|
|
190
|
+
spartnbasedate: int | datetime = 0,
|
|
191
|
+
ipprot: str = "IPv4",
|
|
192
|
+
flowinfo: int = 0, # IPv6, redundant
|
|
193
|
+
scopeid: int = 0, # IPv6, redundant
|
|
194
|
+
output: Any | NoneType = None,
|
|
195
|
+
stopevent: Event = Event(),
|
|
196
|
+
) -> bool:
|
|
167
197
|
"""
|
|
168
198
|
Open NTRIP client connection.
|
|
169
199
|
|
|
@@ -174,27 +204,27 @@ class GNSSNTRIPClient:
|
|
|
174
204
|
User login credentials can be obtained from environment variables
|
|
175
205
|
PYGPSCLIENT_USER and PYGPSCLIENT_PASSWORD, or passed as kwargs.
|
|
176
206
|
|
|
177
|
-
:param str server:
|
|
178
|
-
:param int port:
|
|
179
|
-
:param bool https:
|
|
180
|
-
:param bool selfsign:
|
|
181
|
-
:param str mountpoint:
|
|
182
|
-
:param Literal["RTCM","SPARTN"] datatype:
|
|
183
|
-
:param Literal["1.0","2.0"] version:
|
|
184
|
-
:param str ntripuser:
|
|
185
|
-
:param str ntrippassword:
|
|
186
|
-
:param int ggainterval:
|
|
187
|
-
:param Literal[0,1] ggamode:
|
|
207
|
+
:param str server: NTRIP server URL ("")
|
|
208
|
+
:param int port: NTRIP port (2101)
|
|
209
|
+
:param bool https: Enable HTTPS (TLS) connection? (0)
|
|
210
|
+
:param bool selfsign: Allow self-sign TLS certificate (0)
|
|
211
|
+
:param str mountpoint: NTRIP mountpoint ("", leave blank to get sourcetable)
|
|
212
|
+
:param Literal["RTCM","SPARTN"] datatype: Data type - RTCM or SPARTN ("RTCM")
|
|
213
|
+
:param Literal["1.0","2.0"] version: NTRIP protocol version ("2.0")
|
|
214
|
+
:param str ntripuser: NTRIP authentication user ("anon")
|
|
215
|
+
:param str ntrippassword: NTRIP authentication password ("password")
|
|
216
|
+
:param int ggainterval: GGA sentence transmission interval (-1 = None)
|
|
217
|
+
:param Literal[0,1] ggamode: GGA pos source; 0 = live from receiver, \
|
|
188
218
|
1 = fixed reference (0)
|
|
189
|
-
:param str reflat:
|
|
190
|
-
:param str reflon:
|
|
191
|
-
:param str refalt:
|
|
192
|
-
:param str refsep:
|
|
193
|
-
:param bool spartndecode:
|
|
194
|
-
:param str
|
|
195
|
-
:param str | datetime
|
|
196
|
-
:param Any output:
|
|
197
|
-
:param Event stopevent:
|
|
219
|
+
:param str reflat: reference latitude (0.0)
|
|
220
|
+
:param str reflon: reference longitude (0.0)
|
|
221
|
+
:param str refalt: reference altitude (0.0)
|
|
222
|
+
:param str refsep: reference separation (0.0)
|
|
223
|
+
:param bool spartndecode: decode SPARTN messages (0)
|
|
224
|
+
:param str spartnkey: SPARTN decryption key
|
|
225
|
+
:param str | datetime spartnbasedate: SPARTN decryption basedate (now(utc))
|
|
226
|
+
:param Any output: writeable output medium (serial, file, socket, queue) (None)
|
|
227
|
+
:param Event stopevent: stopevent to terminate `run()` (internal `Event()`)
|
|
198
228
|
:returns: boolean flag 0 = stream terminated, 1 = streaming data
|
|
199
229
|
:rtype: bool
|
|
200
230
|
"""
|
|
@@ -202,10 +232,34 @@ class GNSSNTRIPClient:
|
|
|
202
232
|
# pylint: disable=unused-variable
|
|
203
233
|
|
|
204
234
|
try:
|
|
205
|
-
self._stopevent =
|
|
235
|
+
self._stopevent = stopevent
|
|
206
236
|
self._last_gga = datetime.fromordinal(1)
|
|
207
|
-
self.settings =
|
|
208
|
-
|
|
237
|
+
self.settings = {
|
|
238
|
+
"server": server,
|
|
239
|
+
"port": port,
|
|
240
|
+
"https": https,
|
|
241
|
+
"selfsign": selfsign,
|
|
242
|
+
"mountpoint": mountpoint,
|
|
243
|
+
"datatype": datatype,
|
|
244
|
+
"version": version,
|
|
245
|
+
"ntripuser": ntripuser,
|
|
246
|
+
"ntrippassword": ntrippassword,
|
|
247
|
+
"ggainterval": ggainterval,
|
|
248
|
+
"ggamode": ggamode,
|
|
249
|
+
"reflat": reflat,
|
|
250
|
+
"reflon": reflon,
|
|
251
|
+
"refalt": refalt,
|
|
252
|
+
"refsep": refsep,
|
|
253
|
+
"spartndecode": spartndecode,
|
|
254
|
+
"spartnkey": spartnkey,
|
|
255
|
+
"spartnbasedate": spartnbasedate,
|
|
256
|
+
"output": output,
|
|
257
|
+
"stopevent": stopevent,
|
|
258
|
+
"ipprot": ipprot,
|
|
259
|
+
"flowinfo": flowinfo, # redundant
|
|
260
|
+
"scopeid": scopeid, # redundant
|
|
261
|
+
}
|
|
262
|
+
self._output = output
|
|
209
263
|
if self._settings["server"] == "":
|
|
210
264
|
raise ParameterError(f"Invalid server URL {self._settings['server']}")
|
|
211
265
|
if not 1 < self._settings["port"] < MAXPORT:
|
|
@@ -280,7 +334,7 @@ class GNSSNTRIPClient:
|
|
|
280
334
|
ConnectionResetError,
|
|
281
335
|
OverflowError,
|
|
282
336
|
gaierror,
|
|
283
|
-
|
|
337
|
+
socktimeout, # subclass of OSError in Python<=3.9
|
|
284
338
|
TimeoutError,
|
|
285
339
|
) as err:
|
|
286
340
|
errm = str(repr(err))
|
|
@@ -540,24 +594,19 @@ class GNSSNTRIPClient:
|
|
|
540
594
|
|
|
541
595
|
# parser will wrap socket as SocketStream
|
|
542
596
|
if settings["datatype"].lower() == SPARTN:
|
|
543
|
-
|
|
544
|
-
stream,
|
|
545
|
-
quitonerror=ERR_LOG,
|
|
546
|
-
bufsize=DEFAULT_BUFSIZE,
|
|
547
|
-
decode=settings.get("spartndecode", False),
|
|
548
|
-
key=settings.get("spartnkey", "ABCD1234"),
|
|
549
|
-
basedate=settings.get("spartnbasedate", 0),
|
|
550
|
-
errorhandler=self._error_handler,
|
|
551
|
-
)
|
|
597
|
+
protocol = SPARTN_PROTOCOL
|
|
552
598
|
else:
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
599
|
+
protocol = RTCM3_PROTOCOL
|
|
600
|
+
parser = GNSSReader(
|
|
601
|
+
stream,
|
|
602
|
+
protfilter=protocol,
|
|
603
|
+
quitonerror=ERR_LOG,
|
|
604
|
+
bufsize=DEFAULT_BUFSIZE,
|
|
605
|
+
labelmsm=1,
|
|
606
|
+
errorhandler=self._error_handler,
|
|
607
|
+
spartnkey=settings.get("spartnkey", "ABCD1234"),
|
|
608
|
+
spartnbasedate=settings.get("spartnbasedate", 0),
|
|
609
|
+
)
|
|
561
610
|
|
|
562
611
|
while not stopevent.is_set():
|
|
563
612
|
raw_data, parsed_data = parser.read()
|
|
@@ -3,11 +3,11 @@ gnssreader.py
|
|
|
3
3
|
|
|
4
4
|
Generic GNSS reader / parser class.
|
|
5
5
|
|
|
6
|
-
Reads and parses individual UBX, SBF, QGC, UNI, NMEA or
|
|
7
|
-
GNSS data stream which supports a read(n) -> bytes method.
|
|
6
|
+
Reads and parses individual UBX, SBF, QGC, UNI, NMEA, RTCM3 or SPARTN messages from
|
|
7
|
+
any viable GNSS data stream which supports a read(n) -> bytes method.
|
|
8
8
|
|
|
9
9
|
It is essentially an amalgamation of the Reader classes in the separate pyubx2, pynmeagps,
|
|
10
|
-
pyrtcm, pysbf2, pyqgc
|
|
10
|
+
pyrtcm, pysbf2, pyqgc, pyunigps & pyspartn packages.
|
|
11
11
|
|
|
12
12
|
Returns both the raw binary data (as bytes) and the parsed data.
|
|
13
13
|
|
|
@@ -17,6 +17,7 @@ Returns both the raw binary data (as bytes) and the parsed data.
|
|
|
17
17
|
- 'quitonerror' governs how errors are handled.
|
|
18
18
|
- 'msgmode' indicates the type of UBX datastream (output GET, input SET, query POLL).
|
|
19
19
|
If msgmode is set to SETPOLL, input/query mode will be automatically detected by parser.
|
|
20
|
+
- spartnkey and spartnbasedate are required to decrypt encrypted SPARTN datastreams.
|
|
20
21
|
|
|
21
22
|
Created on 6 Oct 2025
|
|
22
23
|
|
|
@@ -27,10 +28,11 @@ Created on 6 Oct 2025
|
|
|
27
28
|
|
|
28
29
|
# pylint: disable=too-many-positional-arguments
|
|
29
30
|
|
|
31
|
+
from datetime import datetime
|
|
30
32
|
from logging import getLogger
|
|
31
33
|
from socket import socket
|
|
32
|
-
from types import
|
|
33
|
-
from typing import Any, Literal
|
|
34
|
+
from types import NoneType
|
|
35
|
+
from typing import Any, Callable, Literal
|
|
34
36
|
|
|
35
37
|
from pynmeagps import (
|
|
36
38
|
NMEA_HDR,
|
|
@@ -68,6 +70,20 @@ from pysbf2 import (
|
|
|
68
70
|
SBFStreamError,
|
|
69
71
|
SBFTypeError,
|
|
70
72
|
)
|
|
73
|
+
from pyspartn import (
|
|
74
|
+
ALN_ENUM,
|
|
75
|
+
SPARTN_PREB,
|
|
76
|
+
VALCRC,
|
|
77
|
+
SPARTNDecryptionError,
|
|
78
|
+
SPARTNMessage,
|
|
79
|
+
SPARTNMessageError,
|
|
80
|
+
SPARTNParseError,
|
|
81
|
+
SPARTNReader,
|
|
82
|
+
SPARTNStreamError,
|
|
83
|
+
SPARTNTypeError,
|
|
84
|
+
date2timetag,
|
|
85
|
+
valid_crc,
|
|
86
|
+
)
|
|
71
87
|
from pyubx2 import (
|
|
72
88
|
ERR_LOG,
|
|
73
89
|
ERR_RAISE,
|
|
@@ -96,7 +112,7 @@ from pyunigps import (
|
|
|
96
112
|
)
|
|
97
113
|
|
|
98
114
|
from pygnssutils.exceptions import GNSSStreamError
|
|
99
|
-
from pygnssutils.globals import DEFAULT_BUFSIZE
|
|
115
|
+
from pygnssutils.globals import DEFAULT_BUFSIZE, SPARTN_DEFAULTKEY
|
|
100
116
|
|
|
101
117
|
NMEA_PROTOCOL = 1
|
|
102
118
|
"""NMEA Protocol"""
|
|
@@ -110,6 +126,8 @@ QGC_PROTOCOL = 16
|
|
|
110
126
|
"""QGC Protocol (Quectel)"""
|
|
111
127
|
UNI_PROTOCOL = 32
|
|
112
128
|
"""UNI Protocol (Unicore)"""
|
|
129
|
+
SPARTN_PROTOCOL = 256
|
|
130
|
+
"""SPARTN Protocol"""
|
|
113
131
|
PARSE_NONE = 0
|
|
114
132
|
"""No Parsing, raw output only"""
|
|
115
133
|
PARSE_FULL = 1
|
|
@@ -229,14 +247,17 @@ class GNSSReader:
|
|
|
229
247
|
| RTCM3_PROTOCOL
|
|
230
248
|
| SBF_PROTOCOL
|
|
231
249
|
| QGC_PROTOCOL
|
|
232
|
-
| UNI_PROTOCOL
|
|
250
|
+
| UNI_PROTOCOL
|
|
251
|
+
| SPARTN_PROTOCOL,
|
|
233
252
|
quitonerror: Literal[0, 1, 2] = ERR_LOG,
|
|
234
253
|
parsebitfield: bool = True,
|
|
235
254
|
labelmsm: Literal[0, 1] = 1,
|
|
236
255
|
bufsize: int = DEFAULT_BUFSIZE,
|
|
237
256
|
parsing: Literal[0, 1, 2] = PARSE_FULL,
|
|
238
257
|
msgfilter: tuple | int | str = "",
|
|
239
|
-
errorhandler:
|
|
258
|
+
errorhandler: Callable | NoneType = None,
|
|
259
|
+
spartnkey: str = SPARTN_DEFAULTKEY,
|
|
260
|
+
spartnbasedate: int | datetime = 0, # TIMEBASE
|
|
240
261
|
):
|
|
241
262
|
"""Constructor.
|
|
242
263
|
|
|
@@ -244,8 +265,9 @@ class GNSSReader:
|
|
|
244
265
|
:param Literal[0,1,2] msgmode: 0=GET, 1=SET, 2=POLL, 3=SETPOLL (0)
|
|
245
266
|
:param int validate: VALCKSUM (1) = Validate checksum,
|
|
246
267
|
VALNONE (0) = ignore invalid checksum (1)
|
|
247
|
-
:param int protfilter: NMEA_PROTOCOL (1), UBX_PROTOCOL (2), RTCM3_PROTOCOL (4),
|
|
248
|
-
SBF_PROTOCOL (8), QGC_PROTOCOL (16), UNI_PROTOCOL (32)
|
|
268
|
+
:param int protfilter: NMEA_PROTOCOL (1), UBX_PROTOCOL (2), RTCM3_PROTOCOL (4), \
|
|
269
|
+
SBF_PROTOCOL (8), QGC_PROTOCOL (16), UNI_PROTOCOL (32), SPARTN_PROTOCOL (256). \
|
|
270
|
+
Can be OR'd (319)
|
|
249
271
|
:param Literal[0,1,2] quitonerror: ERR_IGNORE (0) = ignore errors, \
|
|
250
272
|
ERR_LOG (1) = log continue, ERR_RAISE (2) = (re)raise (1)
|
|
251
273
|
:param bool parsebitfield: 1 = parse bitfields, 0 = leave as bytes (1)
|
|
@@ -254,7 +276,10 @@ class GNSSReader:
|
|
|
254
276
|
:param Literal[0,1,2] parsing: PARSE_NONE (0) = no parsing (raw only), \
|
|
255
277
|
PARSE_FULL (1) = full parsing, PARSE_META (2) = parse metadata only (1)
|
|
256
278
|
:param tuple | int | str msgfilter: parsed message filter ("" = ALL)
|
|
257
|
-
:param
|
|
279
|
+
:param Callable | NoneType errorhandler: error handling object or function (None)
|
|
280
|
+
:param str spartnkey: SPARTN decryption key
|
|
281
|
+
:param int | datetime spartnbasedate: SPARTN decryption basedate as integer \
|
|
282
|
+
(0 = use datastream, -1 = current UTC; use date2timetag to convert datetime)
|
|
258
283
|
:raises: UBXStreamError (if mode is invalid)
|
|
259
284
|
"""
|
|
260
285
|
# pylint: disable=too-many-arguments
|
|
@@ -271,6 +296,12 @@ class GNSSReader:
|
|
|
271
296
|
self._labelmsm = labelmsm
|
|
272
297
|
self._msgmode = msgmode
|
|
273
298
|
self._parsing = parsing
|
|
299
|
+
self._spartnkey = spartnkey
|
|
300
|
+
if isinstance(spartnbasedate, datetime):
|
|
301
|
+
self._spartnbasedate = date2timetag(spartnbasedate)
|
|
302
|
+
else:
|
|
303
|
+
self._spartnbasedate = int(spartnbasedate)
|
|
304
|
+
self._timetags = {}
|
|
274
305
|
self._msgfilter = (
|
|
275
306
|
(msgfilter,) if not isinstance(msgfilter, tuple) else msgfilter
|
|
276
307
|
)
|
|
@@ -324,8 +355,14 @@ class GNSSReader:
|
|
|
324
355
|
# raw_data = b""
|
|
325
356
|
parsed_data = None
|
|
326
357
|
byte1 = self._read_bytes(1) # read the first byte
|
|
327
|
-
# if not UBX, SBF, QGC, UNI, NMEA or
|
|
328
|
-
if byte1 not in (b"\xb5", b"\x24", b"\x51", b"\xd3", b"\xaa"):
|
|
358
|
+
# if not UBX, SBF, QGC, UNI, NMEA, RTCM3 or SPARTN, discard and continue
|
|
359
|
+
if byte1 not in (b"\xb5", b"\x24", b"\x51", b"\xd3", b"\xaa", b"\x73"):
|
|
360
|
+
continue
|
|
361
|
+
# if it's a SPARTN message (b'\x73' == b"s")
|
|
362
|
+
if byte1 == SPARTN_PREB:
|
|
363
|
+
raw_data, parsed_data = self._parse_spartn(byte1)
|
|
364
|
+
if self._protfilter & SPARTN_PROTOCOL:
|
|
365
|
+
break
|
|
329
366
|
continue
|
|
330
367
|
byte2 = self._read_bytes(1)
|
|
331
368
|
bytehdr = byte1 + byte2
|
|
@@ -412,6 +449,11 @@ class GNSSReader:
|
|
|
412
449
|
UNIParseError,
|
|
413
450
|
UNIStreamError,
|
|
414
451
|
UNITypeError,
|
|
452
|
+
SPARTNMessageError,
|
|
453
|
+
SPARTNParseError,
|
|
454
|
+
SPARTNStreamError,
|
|
455
|
+
SPARTNTypeError,
|
|
456
|
+
SPARTNDecryptionError,
|
|
415
457
|
GNSSStreamError,
|
|
416
458
|
) as err:
|
|
417
459
|
if self._quitonerror:
|
|
@@ -622,6 +664,82 @@ class GNSSReader:
|
|
|
622
664
|
parsed_data = GNSSMessage(RTCM3_PROTOCOL, msgidi, raw_data)
|
|
623
665
|
return raw_data, parsed_data
|
|
624
666
|
|
|
667
|
+
def _parse_spartn(self, preamble: bytes) -> tuple[bytes, SPARTNMessage]:
|
|
668
|
+
"""
|
|
669
|
+
Parse any SPARTN data in the stream. The structure of the transport layer
|
|
670
|
+
depends on encryption type, GNSS timetag format and CRC format.
|
|
671
|
+
|
|
672
|
+
:param preamble hdr: preamble of SPARTN message
|
|
673
|
+
:return: raw_data as bytes, parsed_stub as SPARTNMessage
|
|
674
|
+
:rtype: tuple[bytes, SPARTNMessage]
|
|
675
|
+
:raises: SPARTN...Error if CRC invalid or other parsing error
|
|
676
|
+
"""
|
|
677
|
+
|
|
678
|
+
# pylint: disable=invalid-name
|
|
679
|
+
|
|
680
|
+
def bitsval(bitfield: bytes, position: int, length: int):
|
|
681
|
+
lbb = len(bitfield) * 8
|
|
682
|
+
if position + length > lbb:
|
|
683
|
+
raise SPARTNMessageError(
|
|
684
|
+
f"Attribute size {length} exceeds remaining payload length {lbb - position}"
|
|
685
|
+
)
|
|
686
|
+
return int.from_bytes(bitfield, "big") >> (lbb - position - length) & (
|
|
687
|
+
(1 << length) - 1
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
framestart = self._read_bytes(3)
|
|
691
|
+
# msgType = bitsval(framestart, 0, 7)
|
|
692
|
+
nData = bitsval(framestart, 7, 10)
|
|
693
|
+
eaf = bitsval(framestart, 17, 1)
|
|
694
|
+
crcType = bitsval(framestart, 18, 2)
|
|
695
|
+
# frameCrc = bitsval(framestart, 20, 4)
|
|
696
|
+
|
|
697
|
+
payDesc = self._read_bytes(4)
|
|
698
|
+
# msgSubtype denotes constellation - GPS, GLO, GAL, etc.
|
|
699
|
+
msgSubtype = bitsval(payDesc, 0, 4)
|
|
700
|
+
timeTagtype = bitsval(payDesc, 4, 1)
|
|
701
|
+
if timeTagtype:
|
|
702
|
+
payDesc += self._read_bytes(2)
|
|
703
|
+
gtlen = 32 if timeTagtype else 16
|
|
704
|
+
gnssTimeTag = bitsval(payDesc, 5, gtlen)
|
|
705
|
+
# store 32-bit timetag for this subtype for later use in decryption
|
|
706
|
+
if timeTagtype == 1:
|
|
707
|
+
self._timetags[msgSubtype] = gnssTimeTag
|
|
708
|
+
# solutionId = bitsval(payDesc, gtlen + 5, 7)
|
|
709
|
+
# solutionProcId = bitsval(payDesc, gtlen + 12, 4)
|
|
710
|
+
authInd = 0
|
|
711
|
+
embAuthLen = 0
|
|
712
|
+
if eaf:
|
|
713
|
+
payDesc += self._read_bytes(2)
|
|
714
|
+
# encryptionId = bitsval(payDesc, gtlen + 16, 4)
|
|
715
|
+
# encryptionSeq = bitsval(payDesc, gtlen + 20, 6)
|
|
716
|
+
authInd = bitsval(payDesc, gtlen + 26, 3)
|
|
717
|
+
embAuthLen = bitsval(payDesc, gtlen + 29, 3)
|
|
718
|
+
payload = self._read_bytes(nData)
|
|
719
|
+
embAuth = b""
|
|
720
|
+
if authInd > 1:
|
|
721
|
+
aln = ALN_ENUM.get(embAuthLen, 0)
|
|
722
|
+
embAuth = self._read_bytes(aln)
|
|
723
|
+
crcb = self._read_bytes(crcType + 1)
|
|
724
|
+
crc = int.from_bytes(crcb, "big")
|
|
725
|
+
|
|
726
|
+
# validate CRC
|
|
727
|
+
core = framestart + payDesc + payload + embAuth
|
|
728
|
+
raw_data = preamble + core + crcb
|
|
729
|
+
if self._validate & VALCRC:
|
|
730
|
+
if not valid_crc(core, crc, crcType):
|
|
731
|
+
raise SPARTNParseError(f"Invalid CRC {crc}")
|
|
732
|
+
|
|
733
|
+
parsed_data = SPARTNReader.parse(
|
|
734
|
+
raw_data,
|
|
735
|
+
validate=self._validate,
|
|
736
|
+
decode=True,
|
|
737
|
+
key=self._spartnkey,
|
|
738
|
+
basedate=self._spartnbasedate,
|
|
739
|
+
timetags=self._timetags,
|
|
740
|
+
)
|
|
741
|
+
return (raw_data, parsed_data)
|
|
742
|
+
|
|
625
743
|
def _read_bytes(self, size: int) -> bytes:
|
|
626
744
|
"""
|
|
627
745
|
Read a specified number of bytes from stream.
|
|
@@ -141,7 +141,7 @@ def main():
|
|
|
141
141
|
"--hostip",
|
|
142
142
|
required=False,
|
|
143
143
|
help="Host IP Address Binding (0.0.0.0/:: = all)",
|
|
144
|
-
default="0.0.0.0",
|
|
144
|
+
default="0.0.0.0", # nosec
|
|
145
145
|
)
|
|
146
146
|
ap.add_argument(
|
|
147
147
|
"-N",
|
|
@@ -280,8 +280,8 @@ def main():
|
|
|
280
280
|
)
|
|
281
281
|
kwargs = set_common_args("gnssserver", ap)
|
|
282
282
|
|
|
283
|
-
if kwargs["hostip"] == "0.0.0.0" and kwargs["ipprot"] == "IPv6":
|
|
284
|
-
kwargs["hostip"] = "::"
|
|
283
|
+
if kwargs["hostip"] == "0.0.0.0" and kwargs["ipprot"] == "IPv6": # nosec
|
|
284
|
+
kwargs["hostip"] = "::" # nosec
|
|
285
285
|
|
|
286
286
|
kwargs["outformat"] = kwargs.pop("format") # avoid 'redefines format' warning
|
|
287
287
|
_setup_datastream(**kwargs)
|
|
@@ -13,6 +13,7 @@ Created on 27 Jul 2023
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
from collections import defaultdict
|
|
16
|
+
from datetime import datetime
|
|
16
17
|
from io import UnsupportedOperation
|
|
17
18
|
from logging import getLogger
|
|
18
19
|
from queue import Empty, Queue
|
|
@@ -25,6 +26,7 @@ from pynmeagps import NMEAMessage
|
|
|
25
26
|
from pyqgc import QGCMessage
|
|
26
27
|
from pyrtcm import RTCMMessage
|
|
27
28
|
from pysbf2 import SBFMessage
|
|
29
|
+
from pyspartn import DEFAULTKEY, SPARTNMessage, date2timetag
|
|
28
30
|
from pyubx2 import (
|
|
29
31
|
CARRSOLN,
|
|
30
32
|
ERR_RAISE,
|
|
@@ -35,6 +37,7 @@ from pyubx2 import (
|
|
|
35
37
|
UBXMessage,
|
|
36
38
|
hextable,
|
|
37
39
|
)
|
|
40
|
+
from pyunigps import UNIMessage
|
|
38
41
|
from serial import Serial
|
|
39
42
|
|
|
40
43
|
from pygnssutils.exceptions import ParameterError
|
|
@@ -56,7 +59,9 @@ from pygnssutils.gnssreader import (
|
|
|
56
59
|
QGC_PROTOCOL,
|
|
57
60
|
RTCM3_PROTOCOL,
|
|
58
61
|
SBF_PROTOCOL,
|
|
62
|
+
SPARTN_PROTOCOL,
|
|
59
63
|
UBX_PROTOCOL,
|
|
64
|
+
UNI_PROTOCOL,
|
|
60
65
|
GNSSMessage,
|
|
61
66
|
GNSSReader,
|
|
62
67
|
)
|
|
@@ -80,7 +85,7 @@ class GNSSStreamer:
|
|
|
80
85
|
|
|
81
86
|
The class implements public methods which can be used by other pygnssutils
|
|
82
87
|
classes:
|
|
83
|
-
|
|
88
|
+
|
|
84
89
|
- `get_coordinates()`, returns current GNSS status.
|
|
85
90
|
- `status` property, returns current GNSS status.
|
|
86
91
|
|
|
@@ -101,7 +106,9 @@ class GNSSStreamer:
|
|
|
101
106
|
| UBX_PROTOCOL
|
|
102
107
|
| RTCM3_PROTOCOL
|
|
103
108
|
| SBF_PROTOCOL
|
|
104
|
-
| QGC_PROTOCOL
|
|
109
|
+
| QGC_PROTOCOL
|
|
110
|
+
| UNI_PROTOCOL
|
|
111
|
+
| SPARTN_PROTOCOL,
|
|
105
112
|
msgfilter: str = "",
|
|
106
113
|
parsing: Literal[0, 1, 2] = PARSE_FULL,
|
|
107
114
|
limit: int = 0,
|
|
@@ -112,6 +119,8 @@ class GNSSStreamer:
|
|
|
112
119
|
stopevent: Event | NoneType = None,
|
|
113
120
|
verbosity: Literal[-1, 0, 1, 2, 3] = VERBOSITY_MEDIUM,
|
|
114
121
|
logtofile: str = "",
|
|
122
|
+
spartnkey: str = DEFAULTKEY,
|
|
123
|
+
spartnbasedate: int | datetime = 0, # TIMEBASE
|
|
115
124
|
**kwargs,
|
|
116
125
|
):
|
|
117
126
|
"""
|
|
@@ -126,7 +135,8 @@ class GNSSStreamer:
|
|
|
126
135
|
16 = parsed as string, 32 = JSON (can be OR'd) (1)
|
|
127
136
|
:param Literal[0,1,2] quitonerror: 0 = ignore errors, 1 = log errors and continue, \
|
|
128
137
|
2 = (re)raise errors (1)
|
|
129
|
-
:param int protfilter: 1 = NMEA, 2 = UBX, 4 = RTCM3, 8 = SBF, 16 = QGC
|
|
138
|
+
:param int protfilter: 1 = NMEA, 2 = UBX, 4 = RTCM3, 8 = SBF, 16 = QGC, \
|
|
139
|
+
32 = UNI, 256 = SPARTN (can be OR'd) (319)
|
|
130
140
|
:param str msgfilter: comma-separated string of message identities to include in output \
|
|
131
141
|
e.g. 'NAV-PVT,GNGSA'. A periodicity clause can be added e.g. NAV-SAT(10), signifying \
|
|
132
142
|
the minimum period in seconds between successive messages of this type ("")
|
|
@@ -141,6 +151,9 @@ class GNSSStreamer:
|
|
|
141
151
|
:param Literal[-1,0,1,2,3] verbosity: log message verbosity -1 = critical, 0 = error, \
|
|
142
152
|
1 = warning, 2 = info, 3 = debug (1)
|
|
143
153
|
:param str logtofile: fully qualified path to logfile ("" = no logfile)
|
|
154
|
+
:param str spartnkey: SPARTN decryption key
|
|
155
|
+
:param int | datetime spartnbasedate: SPARTN decryption basedate as integer \
|
|
156
|
+
(0 = use datastream, -1 = current UTC; use date2timetag to convert datetime)
|
|
144
157
|
:param dict kwargs: user-defined keyword arguments to pass to custom input/output handlers
|
|
145
158
|
:raises ValueError: If invalid arguments
|
|
146
159
|
"""
|
|
@@ -167,6 +180,11 @@ class GNSSStreamer:
|
|
|
167
180
|
self._limit = int(limit)
|
|
168
181
|
self._outqueue = outqueue
|
|
169
182
|
self._inqueue = inqueue
|
|
183
|
+
self._spartnkey = spartnkey
|
|
184
|
+
if isinstance(spartnbasedate, datetime):
|
|
185
|
+
self._spartnbasedate = date2timetag(spartnbasedate)
|
|
186
|
+
else:
|
|
187
|
+
self._spartnbasedate = int(spartnbasedate)
|
|
170
188
|
if outputhandler is None:
|
|
171
189
|
self._outputhandler = self.do_output
|
|
172
190
|
else:
|
|
@@ -314,11 +332,12 @@ class GNSSStreamer:
|
|
|
314
332
|
validate=self._validate,
|
|
315
333
|
quitonerror=self._quitonerror,
|
|
316
334
|
parsebitfield=self._parsebitfield,
|
|
335
|
+
spartnkey=self._spartnkey,
|
|
336
|
+
spartnbasedate=self._spartnbasedate,
|
|
317
337
|
)
|
|
318
338
|
|
|
319
339
|
while not stopevent.is_set():
|
|
320
340
|
try:
|
|
321
|
-
|
|
322
341
|
raw_data, parsed_data = ubr.read()
|
|
323
342
|
if raw_data is None or parsed_data is None:
|
|
324
343
|
stopevent.set()
|
|
@@ -420,6 +439,10 @@ class GNSSStreamer:
|
|
|
420
439
|
protocol = SBF_PROTOCOL
|
|
421
440
|
elif isinstance(parsed_data, QGCMessage):
|
|
422
441
|
protocol = QGC_PROTOCOL
|
|
442
|
+
elif isinstance(parsed_data, UNIMessage):
|
|
443
|
+
protocol = UNI_PROTOCOL
|
|
444
|
+
elif isinstance(parsed_data, SPARTNMessage):
|
|
445
|
+
protocol = SPARTN_PROTOCOL
|
|
423
446
|
elif isinstance(parsed_data, GNSSMessage):
|
|
424
447
|
protocol = parsed_data.protocol
|
|
425
448
|
else:
|
|
@@ -541,7 +564,7 @@ class GNSSStreamer:
|
|
|
541
564
|
- (sourcetable: list, nearest mountpoint, distance: tuple) e.g. NTRIP Sourcetable data
|
|
542
565
|
|
|
543
566
|
In the default input handler, only bytes data is written to datastream,
|
|
544
|
-
but this may be
|
|
567
|
+
but this may be overridden by user to handle other data types.
|
|
545
568
|
|
|
546
569
|
:param object datastream: bidirectional GNSS datastream
|
|
547
570
|
:param Queue inqueue: queue containing data to be sent to GNSS datastream
|
|
@@ -36,6 +36,7 @@ from time import sleep
|
|
|
36
36
|
from types import FunctionType
|
|
37
37
|
|
|
38
38
|
from pynmeagps import SocketWrapper
|
|
39
|
+
from pyspartn import DEFAULTKEY
|
|
39
40
|
from pyubxutils.ubxsimulator import UBXSimulator
|
|
40
41
|
from serial import Serial, SerialException
|
|
41
42
|
|
|
@@ -74,10 +75,17 @@ from pygnssutils.globals import (
|
|
|
74
75
|
from pygnssutils.gnssntripclient import GNSSNTRIPClient
|
|
75
76
|
from pygnssutils.gnssreader import (
|
|
76
77
|
ERR_LOG,
|
|
78
|
+
NMEA_PROTOCOL,
|
|
77
79
|
PARSE_FULL,
|
|
78
80
|
PARSE_META,
|
|
79
81
|
PARSE_NONE,
|
|
82
|
+
QGC_PROTOCOL,
|
|
83
|
+
RTCM3_PROTOCOL,
|
|
84
|
+
SBF_PROTOCOL,
|
|
80
85
|
SETPOLL,
|
|
86
|
+
SPARTN_PROTOCOL,
|
|
87
|
+
UBX_PROTOCOL,
|
|
88
|
+
UNI_PROTOCOL,
|
|
81
89
|
GNSSReader,
|
|
82
90
|
)
|
|
83
91
|
from pygnssutils.gnssstreamer import GNSSStreamer
|
|
@@ -264,7 +272,7 @@ def _setup_output(**kwargs):
|
|
|
264
272
|
kwargs["output"] = output
|
|
265
273
|
_setup_datastream(**kwargs)
|
|
266
274
|
elif cliout == OUTPUT_HANDLER:
|
|
267
|
-
output = eval(output) # pylint: disable=eval-used
|
|
275
|
+
output = eval(output) # pylint: disable=eval-used #nosec
|
|
268
276
|
kwargs["output"] = output
|
|
269
277
|
_setup_datastream(**kwargs)
|
|
270
278
|
else:
|
|
@@ -468,9 +476,19 @@ def main():
|
|
|
468
476
|
ap.add_argument(
|
|
469
477
|
"--protfilter",
|
|
470
478
|
required=False,
|
|
471
|
-
help=
|
|
479
|
+
help=(
|
|
480
|
+
f"{NMEA_PROTOCOL} = NMEA, {UBX_PROTOCOL} = UBX, {RTCM3_PROTOCOL} = RTCM3, "
|
|
481
|
+
f"{SBF_PROTOCOL} = SBF, {QGC_PROTOCOL} = QGC, {UNI_PROTOCOL} = UNI, "
|
|
482
|
+
f"{SPARTN_PROTOCOL} = SPARTN (can be OR'd)"
|
|
483
|
+
),
|
|
472
484
|
type=int,
|
|
473
|
-
default=
|
|
485
|
+
default=NMEA_PROTOCOL
|
|
486
|
+
| UBX_PROTOCOL
|
|
487
|
+
| RTCM3_PROTOCOL
|
|
488
|
+
| SBF_PROTOCOL
|
|
489
|
+
| QGC_PROTOCOL
|
|
490
|
+
| UNI_PROTOCOL
|
|
491
|
+
| SPARTN_PROTOCOL,
|
|
474
492
|
)
|
|
475
493
|
ap.add_argument(
|
|
476
494
|
"--msgfilter",
|
|
@@ -592,6 +610,19 @@ def main():
|
|
|
592
610
|
type=int,
|
|
593
611
|
default=-1,
|
|
594
612
|
)
|
|
613
|
+
ap.add_argument(
|
|
614
|
+
"--spartnkey",
|
|
615
|
+
help="SPARTN decryption key",
|
|
616
|
+
default=DEFAULTKEY,
|
|
617
|
+
)
|
|
618
|
+
ap.add_argument(
|
|
619
|
+
"--spartnbasedate",
|
|
620
|
+
help=(
|
|
621
|
+
"SPARTN decryption basedate as integer (0 = use datastream; -1 = current UTC; "
|
|
622
|
+
"use date2timetag to convert datetime)"
|
|
623
|
+
),
|
|
624
|
+
default=0,
|
|
625
|
+
)
|
|
595
626
|
kwargs = set_common_args("gnssstreamer", ap)
|
|
596
627
|
kwargs["outformat"] = kwargs.pop("format") # avoid 'redefines format' warning
|
|
597
628
|
_setup_output(**kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygnssutils
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: GNSS Command Line Utilities
|
|
5
5
|
Author: Steve Smith
|
|
6
6
|
Author-email: semuadmin@semuconsulting.com
|
|
@@ -21,7 +21,6 @@ Classifier: Intended Audience :: Developers
|
|
|
21
21
|
Classifier: Intended Audience :: Science/Research
|
|
22
22
|
Classifier: Intended Audience :: End Users/Desktop
|
|
23
23
|
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
25
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
26
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
27
26
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -34,13 +33,13 @@ Requires-Python: >=3.10
|
|
|
34
33
|
Description-Content-Type: text/markdown
|
|
35
34
|
License-File: LICENSE
|
|
36
35
|
Requires-Dist: certifi>=2026.0.0
|
|
37
|
-
Requires-Dist: pynmeagps>=1.
|
|
36
|
+
Requires-Dist: pynmeagps>=1.2.0
|
|
38
37
|
Requires-Dist: pyqgc>=1.0.1
|
|
39
38
|
Requires-Dist: pyrtcm>=1.2.1
|
|
40
39
|
Requires-Dist: pysbf2>=1.0.7
|
|
41
40
|
Requires-Dist: pyserial>=3.5
|
|
42
|
-
Requires-Dist: pyspartn>=1.1.
|
|
43
|
-
Requires-Dist: pyubx2>=1.
|
|
41
|
+
Requires-Dist: pyspartn>=1.1.2
|
|
42
|
+
Requires-Dist: pyubx2>=1.4.1
|
|
44
43
|
Requires-Dist: pyubxutils>=1.0.6
|
|
45
44
|
Requires-Dist: pyunigps>=1.0.1
|
|
46
45
|
Dynamic: license-file
|
|
@@ -73,8 +72,8 @@ pygnssutils is an original series of Python GNSS utility classes and CLI tools b
|
|
|
73
72
|
|
|
74
73
|
Originally developed in support of the [PyGPSClient](https://github.com/semuconsulting/PyGPSClient) GUI GNSS application, the utilities provided by pygnssutils can also be used in their own right:
|
|
75
74
|
|
|
76
|
-
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC and
|
|
77
|
-
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC and
|
|
75
|
+
1. `GNSSReader` class. This is essentially an amalgamation of the `*Reader` classes in all the subsidiary parsers listed above, allowing the user to seamlessly stream any of NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN message protocols concurrently from a single stream.
|
|
76
|
+
1. `GNSSStreamer` class and its associated [`gnssstreamer`](#gnssstreamer) (*formerly `gnssdump`*) CLI utility. This is essentially a configurable bidirectional input/output wrapper around the `GNSSReader` class with flexible message formatting, filtering and output handling options for NMEA, UBX, SBF, UNI, QGC, RTCM3 and SPARTN protocols.
|
|
78
77
|
1. `GNSSSocketServer` class and its associated [`gnssserver`](#gnssserver) CLI utility. This implements a TCP Socket Server for GNSS data streams which is also capable of being run as a simple NTRIP Server/Caster.
|
|
79
78
|
1. `GNSSNTRIPClient` class and its associated [`gnssntripclient`](#gnssntripclient) CLI utility. This implements
|
|
80
79
|
a simple NTRIP Client which receives RTCM3 or SPARTN correction data from an NTRIP Server and (optionally) sends this to a
|
|
@@ -154,7 +153,7 @@ Refer to the [Sphinx API documentation](https://www.semuconsulting.com/pygnssuti
|
|
|
154
153
|
class pygnssutils.gnssstreamer.GNSSStreamer(**kwargs)
|
|
155
154
|
```
|
|
156
155
|
|
|
157
|
-
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN
|
|
156
|
+
`gnssstreamer` (*formerly `gnssdump`*) is a command line utility for concurrent bidirectional communication with a GNSS datastream - typically a GNSS receiver. It supports NMEA, UBX, SBF, UNI, QGC, RTCM3, SPARTN and NTRIP protocols - individual protocols can be filtered via the `protfilter` arguments.
|
|
158
157
|
|
|
159
158
|
- The CLI utility can acquire data from any one of the following sources:
|
|
160
159
|
- `port`: serial port e.g. `COM3` or `/dev/ttyACM1` (can specify `--baudrate` and `--timeout`)
|
|
@@ -10,7 +10,7 @@ Created on 26 May 2022
|
|
|
10
10
|
|
|
11
11
|
# pylint: disable=line-too-long, invalid-name, missing-docstring, no-member
|
|
12
12
|
|
|
13
|
-
from subprocess import run, PIPE
|
|
13
|
+
from subprocess import run, PIPE #nosec
|
|
14
14
|
import sys
|
|
15
15
|
import unittest
|
|
16
16
|
from io import StringIO
|
|
@@ -41,17 +41,17 @@ class StreamTest(unittest.TestCase):
|
|
|
41
41
|
return self._strout.getvalue().strip()
|
|
42
42
|
|
|
43
43
|
def teststreamer(self):
|
|
44
|
-
res = run(["gnssstreamer", "-h"], stdout=PIPE, check=False)
|
|
44
|
+
res = run(["gnssstreamer", "-h"], stdout=PIPE, check=False) #nosec
|
|
45
45
|
res = res.stdout.decode("utf-8")
|
|
46
46
|
self.assertEqual(res[0:19], "usage: gnssstreamer")
|
|
47
47
|
|
|
48
48
|
def testserver(self):
|
|
49
|
-
res = run(["gnssserver", "-h"], stdout=PIPE, check=False)
|
|
49
|
+
res = run(["gnssserver", "-h"], stdout=PIPE, check=False) #nosec
|
|
50
50
|
res = res.stdout.decode("utf-8")
|
|
51
51
|
self.assertEqual(res[0:17], "usage: gnssserver")
|
|
52
52
|
|
|
53
53
|
def testntripclient(self):
|
|
54
|
-
res = run(["gnssntripclient", "-h"], stdout=PIPE, check=False)
|
|
54
|
+
res = run(["gnssntripclient", "-h"], stdout=PIPE, check=False) #nosec
|
|
55
55
|
res = res.stdout.decode("utf-8")
|
|
56
56
|
self.assertEqual(res[0:22], "usage: gnssntripclient")
|
|
57
57
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Test GNSSStreamer class
|
|
2
|
+
Test GNSSStreamer class
|
|
3
3
|
|
|
4
|
-
Created on 3 Oct 2020
|
|
4
|
+
Created on 3 Oct 2020
|
|
5
5
|
|
|
6
6
|
@author: semuadmin
|
|
7
7
|
"""
|
|
@@ -13,7 +13,6 @@ import sys
|
|
|
13
13
|
import unittest
|
|
14
14
|
from io import StringIO
|
|
15
15
|
|
|
16
|
-
from pygnssutils import exceptions as pge
|
|
17
16
|
from pygnssutils.gnssstreamer import (
|
|
18
17
|
FORMAT_BINARY,
|
|
19
18
|
FORMAT_HEX,
|
|
@@ -114,6 +113,14 @@ class gnssstreamerTest(unittest.TestCase):
|
|
|
114
113
|
sys.stdout = saved_stdout
|
|
115
114
|
print(f"output = {out.getvalue().strip()}")
|
|
116
115
|
|
|
116
|
+
def testgnssstreamer_filter_uni(self):
|
|
117
|
+
# Unicore messages must pass a protocol filter that includes UNI (32)
|
|
118
|
+
from pyunigps import UNIMessage
|
|
119
|
+
|
|
120
|
+
gns = GNSSStreamer(None, StringIO(), protfilter=63)
|
|
121
|
+
msg = UNIMessage(msgid=102, length=0, payload=b"\x00" * 28)
|
|
122
|
+
self.assertFalse(gns._filtered(msg))
|
|
123
|
+
|
|
117
124
|
def testgnssstreamer_outputhandler(self):
|
|
118
125
|
saved_stdout = sys.stdout
|
|
119
126
|
out = StringIO()
|
|
@@ -126,7 +133,7 @@ class gnssstreamerTest(unittest.TestCase):
|
|
|
126
133
|
protfilter=2,
|
|
127
134
|
msgfilter="NAV-PVT",
|
|
128
135
|
limit=2,
|
|
129
|
-
output=eval("lambda msg: print(f'lat: {msg.lat}, lon: {msg.lon}')"),
|
|
136
|
+
output=eval("lambda msg: print(f'lat: {msg.lat}, lon: {msg.lon}')"), #nosec
|
|
130
137
|
)
|
|
131
138
|
gns.run()
|
|
132
139
|
sys.stdout = saved_stdout
|
|
@@ -200,15 +200,15 @@ class StaticTest(unittest.TestCase):
|
|
|
200
200
|
msg = GNSSMessage(2,533,b"1234567890")
|
|
201
201
|
self.assertEqual(str(msg),"<UBX(0x0215, length=10, data=b'\\x31\\x32\\x33\\x34\\x35\\x36\\x37\\x38\\x39\\x30')>")
|
|
202
202
|
# print(repr(msg))
|
|
203
|
-
self.assertEqual(str(eval(repr(msg))),str(msg))
|
|
203
|
+
self.assertEqual(str(eval(repr(msg))),str(msg)) #nosec
|
|
204
204
|
msg = GNSSMessage(1,"GNGSA",b"abcdefghij")
|
|
205
205
|
self.assertEqual(str(msg),"<NMEA(GNGSA, length=10, data=b'\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6a')>")
|
|
206
206
|
# print(repr(msg))
|
|
207
|
-
self.assertEqual(str(eval(repr(msg))),str(msg))
|
|
207
|
+
self.assertEqual(str(eval(repr(msg))),str(msg)) #nosec
|
|
208
208
|
msg = GNSSMessage(32,5133,b"12345678901")
|
|
209
209
|
self.assertEqual(str(msg),"<UNI(5133, length=11, data=b'\\x31\\x32\\x33\\x34\\x35\\x36\\x37\\x38\\x39\\x30\\x31')>")
|
|
210
210
|
# print(repr(msg))
|
|
211
|
-
self.assertEqual(str(eval(repr(msg))),str(msg))
|
|
211
|
+
self.assertEqual(str(eval(repr(msg))),str(msg)) #nosec
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
if __name__ == "__main__":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|