Skip to content

Commit f4b3bc8

Browse files
committed
update uni handler
1 parent 2213213 commit f4b3bc8

10 files changed

Lines changed: 54 additions & 23 deletions

File tree

INSTALLATION.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@ TBC. Anyone conversant with PowerShell is welcome to contribute an equivalent in
243243
244244
## <a name="troubleshooting">Troubleshooting</a>
245245
246-
1. The optional `rasterio` package is only available as an [sdist](#sdist-vs-wheel) on some Linux / ARM platforms (including Raspberry Pi OS), and the consequent [GDAL](https://gdal.org/en/stable/) build and configuration requirements may be problematic e.g. `WARNING:root:Failed to get options via gdal-config`. Refer to [rasterio installation](https://rasterio.readthedocs.io/en/stable/installation.html) and [GDAL installation](https://gdal.org/en/stable/) for assistance but - *be warned* - the process is **not** for the faint-hearted.
246+
1. `[Errno 13] could not open port /dev/tty**** [Errno 13] permission denied /dev/tty****` error on Linux when attempting to access serial port. Refer to [User Privileges](#userpriv).
247+
248+
1. The optional `rasterio` package is only available as an [sdist](#sdist-vs-wheel) on some Linux / ARM platforms and the consequent [GDAL](https://gdal.org/en/stable/) build and configuration requirements may be problematic e.g. `WARNING:root:Failed to get options via gdal-config`. Refer to [rasterio installation](https://rasterio.readthedocs.io/en/stable/installation.html) and [GDAL installation](https://gdal.org/en/stable/) for assistance but - *be warned* - the process is **not** for the faint-hearted.
247249
248250
In practice, `rasterio` is only required for automatic extents detection in PyGPSClient's Import Custom Map facility. As a workaround, extents can be entered manually, or you can try importing maps on a different platform and then copy-and-paste the relevant `usermaps_l` extents configuration to the target platform.
249251

250-
1. The optional `cryptography` package is only available as an [sdist](#sdist-vs-wheel) on some 32-bit Linux / ARM platforms (including Raspberry Pi OS), and the consequent OpenSSL build requirements may be problematic e.g. `Building wheel for cryptography (PEP 517): finished with status 'error'`. Refer to [cryptography installation](https://github.com/semuconsulting/pyspartn/blob/main/cryptography_installation/README.md) for assistance.
252+
1. The optional `cryptography` package is only available as an [sdist](#sdist-vs-wheel) on some 32-bit Linux / ARM platforms and the consequent OpenSSL build requirements may be problematic e.g. `Building wheel for cryptography (PEP 517): finished with status 'error'`. Refer to [cryptography installation](https://github.com/semuconsulting/pyspartn/blob/main/cryptography_installation/README.md) for assistance.
251253

252254
---
253255
## <a name="license">License</a>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ The `pygnssutils` and `pyubxutils` libraries which underpin many of the function
457457

458458
For further details, refer to the `pygnssutils` homepage at [https://github.com/semuconsulting/pygnssutils](https://github.com/semuconsulting/pygnssutils) or `pyubxutils` homepage at [https://github.com/semuconsulting/pyubxutils](https://github.com/semuconsulting/pyubxutils).
459459

460-
--
460+
---
461461
## <a name="knownissues">Known Issues</a>
462462

463463
1. Most budget USB-UART adapters (e.g. FT232, CH345, CP2102) have a bandwidth limit of around 3MB/s and may not work reliably above 115200 baud, even if the receiver supports higher baud rates. If you're using an adapter and notice significant message corruption, try reducing the baud rate to a maximum 115200.

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ classifiers = [
4949
"Topic :: Scientific/Engineering :: GIS",
5050
]
5151

52-
dependencies = ["requests>=2.28.0", "Pillow>=9.0.0", "pygnssutils>=1.1.22"]
52+
dependencies = [
53+
"requests>=2.28.0",
54+
"Pillow>=9.0.0",
55+
"pygnssutils>=1.1.22",
56+
"pyunigps>=0.1.4",
57+
]
5358

5459
[project.scripts]
5560
pygpsclient = "pygpsclient.__main__:main"

src/pygpsclient/chart_frame.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
BGCOL,
4141
ERRCOL,
4242
FGCOL,
43+
INFOCOL,
4344
PLOTCOLS,
4445
READONLY,
4546
TRACEMODE_WRITE,
@@ -48,6 +49,7 @@
4849
WIDGETU6,
4950
)
5051
from pygpsclient.helpers import time2str
52+
from pygpsclient.strings import CONTENTCOPIED
5153

5254
OL_WID = 1
5355
LBLCOL = "white"
@@ -623,6 +625,7 @@ def _on_clipboard(self, event): # pylint: disable=unused-argument
623625
self.__master.clipboard_clear()
624626
self.__master.clipboard_append(csv)
625627
self.__master.update()
628+
self.__app.status_label = (CONTENTCOPIED.format("chart"), INFOCOL)
626629

627630
def _on_resize(self, event): # pylint: disable=unused-argument
628631
"""

src/pygpsclient/console_frame.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
FORMAT_BOTH,
4444
FORMAT_HEXSTR,
4545
FORMAT_HEXTAB,
46+
INFOCOL,
4647
WIDGETU3,
4748
)
48-
from pygpsclient.strings import HALTTAGWARN
49+
from pygpsclient.strings import CONTENTCOPIED, HALTTAGWARN
4950

5051
HALT = "HALT"
5152
CONSOLELINES = 20
@@ -242,6 +243,7 @@ def _on_clipboard(self, event): # pylint: disable=unused-argument
242243
self.__master.clipboard_clear()
243244
self.__master.clipboard_append(self.txt_console.get("1.0", END))
244245
self.__master.update()
246+
self.__app.status_label = (CONTENTCOPIED.format("console"), INFOCOL)
245247

246248
def _on_resize(self, event): # pylint: disable=unused-argument
247249
"""

src/pygpsclient/globals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@
250250
TOPIC_RXM = "/pp/ubx/0236/ip"
251251
TRACK = "track"
252252
TRACEMODE_WRITE = "write"
253-
TTYOK = ("OK", "$R:", "RESPONSE: OK")
254-
TTYERR = ("ERROR", "$R?", "RESPONSE: PARSING FAILD")
253+
TTYOK = ("OK", "$R:")
254+
TTYERR = ("ERROR", "$R?", "FAIL", "CAN'T FOUND DEVICE")
255255
TTYMARKER = "TTY<<"
256256
UBXPRESETS = "ubxpresets"
257257
UBXSIMULATOR = "ubxsimulator"

src/pygpsclient/init_presets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@
100100
"Unicore UM98n Restore Factory Defaults CONFIRM; freset",
101101
"Unicore UM98n Save Current Configuration to NVM CONFIRM; saveconfig",
102102
"Unicore UM98n Force COLD reset CONFIRM; reset",
103-
"Unicore UM98n Enable NMEA on current port; gpgsa 1; gpgga 1; gpgll 1; gpgsv 4; gpvtg 1; gprmc 1",
104-
"Unicore UM98n Enable UNI on current port; PVTSLNB 1; SATSINFOB 4; BESTNAV 1; STADOP 1",
103+
"Unicore UM98n Enable basic NMEA on current port; gpgsa 1; gpgga 1; gpgll 1; gpgsv 4; gpvtg 1; gprmc 1",
104+
"Unicore UM98n Enable basic UNI on current port; PVTSLNB 1; SATSINFOB 4; BESTNAVB 1; STADOPB 1",
105+
"Unicore UM98n Disable basic NMEA on current port; unlog gpgsa; unlog gpgga; unlog gpgll; unlog gpgsv; unlog gpvtg; unlog gprmc",
106+
"Unicore UM98n Disable basic UNI on current port; unlog PVTSLNB; unlog SATSINFOB; unlog BESTNAVB; unlog STADOPB",
105107
"Unicore UM98n Query Version; version",
106108
"Unicore UM98n Query Config; config",
107109
"Unicore UM98n Stop All Output on COM1; unlog COM1",

src/pygpsclient/stream_handler.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ class to read and parse incoming data from the receiver. It places
6262
from pyrtcm import RTCMMessageError, RTCMParseError, RTCMStreamError
6363
from pysbf2 import SBFMessageError, SBFParseError, SBFStreamError
6464
from pyubx2 import ERR_LOG, UBXMessageError, UBXParseError, UBXStreamError
65-
from pyubxutils import UBXSimulator
65+
66+
try:
67+
from pyubxutils import UBXSimulator
68+
69+
HASUBXUTILS = True
70+
except (ImportError, ModuleNotFoundError):
71+
HASUBXUTILS = False
72+
6673
from serial import Serial, SerialException, SerialTimeoutException
6774

6875
from pygpsclient.globals import (
@@ -148,7 +155,7 @@ def _read_thread(
148155
conntype = settings["conntype"]
149156
inactivity_timeout = settings.get("inactivity_timeout", 0)
150157
if conntype == CONNECTED:
151-
if settings["serial_settings"].port == UBXSIMULATOR:
158+
if HASUBXUTILS and settings["serial_settings"].port == UBXSIMULATOR:
152159
conntype = CONNECTED_SIMULATOR
153160
ttydelay = (
154161
self.__app.configuration.get("ttydelay_b")
@@ -238,7 +245,7 @@ def _read_thread(
238245
inactivity_timeout,
239246
)
240247

241-
elif conntype == CONNECTED_SIMULATOR:
248+
elif HASUBXUTILS and conntype == CONNECTED_SIMULATOR:
242249
with UBXSimulator() as stream:
243250
if settings["protocol"] & TTY_PROTOCOL:
244251
self._readlooptty(

src/pygpsclient/strings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
CONFIGRXM = "{} polled, {} key(s) loaded"
4242
CONFIGTITLE = "Config File"
4343
CONFIRM = "CONFIRM"
44+
CONTENTCOPIED = "Contents of {} copied to clipboard"
4445
DGPSYES = "\u2713" # tick symbol
4546
ENDOFFILE = "End of file reached"
4647
FILEOPENERROR = "Error opening file {}"

src/pygpsclient/uni_handler.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ def process_data(self, raw_data: bytes, parsed_data: UNIMessage):
7474
if raw_data is None:
7575
return
7676
# self.logger.debug(f"data received {parsed_data.identity}")
77-
self.__app.gnss_status.utc = wnotow2date(
78-
parsed_data.wno, int(parsed_data.tow / 1000), parsed_data.leapsecond
79-
) # datetime.time
77+
self._process_utc(parsed_data)
8078
if parsed_data.identity in ("BESTNAV", "BESTNAVH"):
8179
self._process_BESTNAV(parsed_data)
82-
elif parsed_data.identity in ("PVTSLT",):
83-
self._process_PVTSLT(parsed_data)
80+
elif parsed_data.identity in ("PVTSLN",):
81+
self._process_PVTSLN(parsed_data)
8482
elif parsed_data.identity in (
8583
"ADRNAV",
8684
"ADRNAVH",
@@ -96,6 +94,17 @@ def process_data(self, raw_data: bytes, parsed_data: UNIMessage):
9694
elif parsed_data.identity in ("STADOP", "ADRDOP", "PPPDOP"):
9795
self._process_STADOP(parsed_data)
9896

97+
def _process_utc(self, data: UNIMessage):
98+
"""
99+
Process wno, tow and leapsecond from UNI message header.
100+
101+
:param UNIMessage data: parsed message
102+
"""
103+
104+
self.__app.gnss_status.utc = wnotow2date(
105+
data.wno, int(data.tow / 1000), data.leapsecond
106+
)
107+
99108
def _process_pos(self, lat: float, lon: float, hmsl: float, undulation: float):
100109
"""
101110
Process lat/lon/hmsl/hae.
@@ -119,8 +128,8 @@ def _process_fix(self, postype: int):
119128
"""
120129

121130
self.__app.gnss_status.fix = fix2desc("BESTNAV", postype)
122-
self.__app.gnss_status.diff_corr = ("RTK" in self.__app.gnss_status.fix) or (
123-
"PPP" in self.__app.gnss_status.fix
131+
self.__app.gnss_status.diff_corr = (
132+
sum(c in self.__app.gnss_status.fix for c in ("RTK", "PPP", "SBAS")) > 0
124133
)
125134

126135
def _process_BESTNAV(self, data: UNIMessage):
@@ -138,11 +147,11 @@ def _process_BESTNAV(self, data: UNIMessage):
138147
self.__app.gnss_status.track = data.trkgnd
139148
self.__app.gnss_status.diff_station = data.stationid
140149

141-
def _process_PVTSLT(self, data: UNIMessage):
150+
def _process_PVTSLN(self, data: UNIMessage):
142151
"""
143-
Process PVTSLT sentence - Navigation position velocity time solution.
152+
Process PVTSLN sentence - Navigation position velocity time solution.
144153
145-
:param UNIMessage data: PVTSLT parsed message
154+
:param UNIMessage data: PVTSLN parsed message
146155
"""
147156

148157
self._process_pos(
@@ -154,7 +163,7 @@ def _process_PVTSLT(self, data: UNIMessage):
154163
self.__app.gnss_status.track = data.headingdegree
155164
self.__app.gnss_status.pdop = data.pdop
156165
self.__app.gnss_status.hdop = data.hdop
157-
self.__app.gnss_status.diff_age = data.bestpos_diffage
166+
self.__app.gnss_status.diff_age = data.bestposdiffage
158167

159168
def _process_ADRNAV(self, data: UNIMessage):
160169
"""

0 commit comments

Comments
 (0)