Skip to content

Commit

Permalink
Merge branch 'ubx_simulation' into RC-1.4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
semuadmin committed Feb 21, 2024
2 parents ab561b7 + af66765 commit 42e2ae0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This is an independent project and we have no affiliation whatsoever with u-blox
## <a name="instructions">Instructions</a>

1. To connect to a GNSS receiver via USB or UART port, select the device from the listbox, set the appropriate serial connection parameters and click
![connect icon](https://github.com/semuconsulting/PyGPSClient/blob/master/src/pygpsclient/resources/usbport-1-24.png?raw=true). The application will endeavour to pre-select a recognised GNSS/GPS device but this is platform and device dependent. Press the ![refresh](https://github.com/semuconsulting/PyGPSClient/blob/master/src/pygpsclient/resources/iconmonstr-refresh-6-16.png?raw=true) button to refresh the list of connected devices at any point. `Rate bps` (baud rate) is typically the only setting that might need adjusting, but tweaking the `timeout` setting may improve performance on certain platforms. The `Msg Mode` parameter defaults to `GET` i.e., periodic or poll response messages *from* a receiver. If you wish to parse streams of command or poll messages being sent *to* a receiver, set the `Msg Mode` to `SET` or `POLL`. A default user-defined serial port can also be passed via the json configuration file setting `"userport_s":`, via environment variable `PYGPSCLIENT_USERPORT` or as a command line argument `--userport`. An optional serial or socket stream inactivity timeout can also be set (in seconds; 0 = no timeout).
![connect icon](https://github.com/semuconsulting/PyGPSClient/blob/master/src/pygpsclient/resources/usbport-1-24.png?raw=true). The application will endeavour to pre-select a recognised GNSS/GPS device but this is platform and device dependent. Press the ![refresh](https://github.com/semuconsulting/PyGPSClient/blob/master/src/pygpsclient/resources/iconmonstr-refresh-6-16.png?raw=true) button to refresh the list of connected devices at any point. `Rate bps` (baud rate) is typically the only setting that might need adjusting, but tweaking the `timeout` setting may improve performance on certain platforms. The `Msg Mode` parameter defaults to `GET` i.e., periodic or poll response messages *from* a receiver. If you wish to parse streams of command or poll messages being sent *to* a receiver, set the `Msg Mode` to `SET` or `POLL`. A default user-defined serial port can also be passed via the json configuration file setting `"userport_s":`, via environment variable `PYGPSCLIENT_USERPORT` or as a command line argument `--userport`. A special userport value of "ubxsimulator" invokes the `pygnssutils.UBXSimulator` utility to emulate a GNSS NMEA/UBX serial stream. An optional serial or socket stream inactivity timeout can also be set (in seconds; 0 = no timeout).
1. To connect to a TCP or UDP socket, enter the server URL and port, select the protocol (defaults to TCP) and click
![connect socket icon](https://github.com/semuconsulting/PyGPSClient/blob/master/src/pygpsclient/resources/ethernet-1-24.png?raw=true).
1. To stream from a previously-saved <a name="filestream">binary datalog file</a>, click
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ classifiers = [
dependencies = [
"requests>=2.28.0",
"Pillow>=9.0.0",
"pygnssutils>=1.0.18",
"pygnssutils>=1.0.19",
"pyserial>=3.5",
]

Expand Down
3 changes: 3 additions & 0 deletions src/pygpsclient/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def __init__(self, master, *args, **kwargs): # pylint: disable=too-many-stateme
ntripcaster_password = kwargs.pop(
"ntripcasterpassword", getenv("NTRIPCASTER_PASSWORD", DEFAULT_PASSWORD)
)
self.ubxsimulator = (
kwargs.pop("ubxsimulator", getenv("UBXSIMULATOR", "0")) == "1"
)

Frame.__init__(self, self.__master, *args, **kwargs)

Expand Down
2 changes: 2 additions & 0 deletions src/pygpsclient/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
CONNECTED = 1
CONNECTED_FILE = 4
CONNECTED_NTRIP = 8
CONNECTED_SIMULATOR = 32
CONNECTED_SOCKET = 2
CONNECTED_SPARTNIP = 16
CONNECTED_SPARTNLB = CONNECTED
Expand Down Expand Up @@ -251,6 +252,7 @@
TOPIC_MGA = "/pp/ubx/mga"
TOPIC_RXM = "/pp/ubx/0236/ip"
UBXPRESETS = "ubxpresets"
UBXSIMULATOR = "ubxsimulator"
UI = "Imperial mph"
UIK = "Imperial knots"
UMK = "Metric kmph"
Expand Down
19 changes: 18 additions & 1 deletion src/pygpsclient/stream_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class to read and parse incoming data from the receiver. It places
from queue import Empty
from threading import Event, Thread

from pygnssutils import UBXSimulator
from pynmeagps import NMEAMessageError, NMEAParseError
from pyrtcm import RTCMMessageError, RTCMParseError
from pyubx2 import (
Expand All @@ -48,9 +49,11 @@ class to read and parse incoming data from the receiver. It places
from pygpsclient.globals import (
CONNECTED,
CONNECTED_FILE,
CONNECTED_SIMULATOR,
CONNECTED_SOCKET,
DEFAULT_BUFSIZE,
FILEREAD_INTERVAL,
UBXSIMULATOR,
)


Expand Down Expand Up @@ -118,9 +121,14 @@ def _read_thread(

conntype = settings["conntype"]
inactivity_timeout = settings["inactivity_timeout"]
ser = settings["serial_settings"]

This comment has been minimized.

Copy link
@divenal

divenal Feb 28, 2024

Not sure you can do this without first testing conntype ?


if conntype == CONNECTED and ser.port == UBXSIMULATOR:
conntype = CONNECTED_SIMULATOR

try:
if conntype == CONNECTED:
ser = settings["serial_settings"]
# ser = settings["serial_settings"]
with Serial(
ser.port,
ser.bpsrate,
Expand Down Expand Up @@ -173,6 +181,15 @@ def _read_thread(
inactivity_timeout,
)

elif conntype == CONNECTED_SIMULATOR:
with UBXSimulator() as stream:
self._readloop(
stopevent,
stream,
settings,
inactivity_timeout,
)

except EOFError:
stopevent.set()
self.__master.event_generate(settings["eof_event"])
Expand Down
7 changes: 6 additions & 1 deletion src/pygpsclient/ubx_config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from pygpsclient.globals import (
CONNECTED,
CONNECTED_SIMULATOR,
CONNECTED_SOCKET,
DLGTUBX,
ENABLE_CFG_OTHER,
Expand Down Expand Up @@ -237,7 +238,11 @@ def _reset(self):
self._frm_config_port.reset()
self._frm_config_dynamic.reset()
self._frm_device_info.reset()
if self.__app.conn_status not in (CONNECTED, CONNECTED_SOCKET):
if self.__app.conn_status not in (
CONNECTED,
CONNECTED_SOCKET,
CONNECTED_SIMULATOR,
):
self.set_status("Device not connected", "red")

def set_pending(self, msgid: int, ubxfrm: int):
Expand Down
3 changes: 2 additions & 1 deletion src/pygpsclient/ubx_info_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from pygpsclient.globals import (
CONNECTED,
CONNECTED_SIMULATOR,
ICON_CONFIRMED,
ICON_PENDING,
ICON_SEND,
Expand Down Expand Up @@ -119,7 +120,7 @@ def reset(self):
Reset panel to initial settings
"""

if self.__app.conn_status == CONNECTED:
if self.__app.conn_status in (CONNECTED, CONNECTED_SIMULATOR):
self._do_poll_ver()

def update_status(self, msg: UBXMessage):
Expand Down

0 comments on commit 42e2ae0

Please sign in to comment.