semuconsulting / PyGPSClient

Python Graphical GPS Client Application supporting NMEA, UBX, RTCM3, NTRIP & SPARTN Protocols

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled UBX messages stall parsing when read via TCP

ArrEssJay opened this issue · comments

Describe the bug

Parsing from a TCP socket stalls when reading a UBX stream containing unhandled messages that raise a parser exception.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxmessage.py", line 884, in identity
    umsg_name = ubt.UBX_MSGIDS[self._ubxClass + self._ubxID]
KeyError: b'\x01b'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
    return self.func(*args)
  File "/usr/local/lib/python3.9/site-packages/pygpsclient/serial_handler.py", line 313, in on_readfile
    self._parse_data(self._serial_buffer)
  File "/usr/local/lib/python3.9/site-packages/pygpsclient/serial_handler.py", line 366, in _parse_data
    parsed_data = UBXReader.parse(raw_data)
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxreader.py", line 372, in parse
    return UBXMessage(
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxmessage.py", line 81, in __init__
    self._do_attributes(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxmessage.py", line 104, in _do_attributes
    pdict = self._get_dict(**kwargs)  # get appropriate payload dict
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxmessage.py", line 523, in _get_dict
    pdict = ubg.UBX_PAYLOADS_GET[self.identity]
  File "/usr/local/lib/python3.9/site-packages/pyubx2/ubxmessage.py", line 886, in identity
    raise ube.UBXMessageError(
pyubx2.exceptions.UBXMessageError: Unknown UBX message type class b'\x01' id b'b'

This causes display of the stream PyGPSClient to stall. This can be replicated by removing support for any message type from pyubx2.

If the stream is written to a file with netcat and parsed as a file in PtyGPSClient this behaviour is not seen.

A workaround/fix for the unhandled message type exposing the problem (UBX-NAV-PL) is in a PR

A sample ubx log file is linked in the PR.