Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# pygnssutils

### RELEASE 1.1.20

FIXES:

1. Fix to gnssreader to return `GNSSStreamError` rather than `ValueError` for unrecognised protocol.
1. Fix typo in gnssntripclient CLI args.

### RELEASE 1.1.19

ENHANCEMENTS:
Expand Down
2 changes: 1 addition & 1 deletion src/pygnssutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pyubxutils.ubxsimulator import UBXSimulator

from pygnssutils._version import __version__
from pygnssutils.exceptions import GNSSStreamError, ParameterError
from pygnssutils.exceptions import GNSSError, GNSSStreamError, ParameterError
from pygnssutils.globals import *
from pygnssutils.gnssmqttclient import GNSSMQTTClient
from pygnssutils.gnssntripclient import GNSSNTRIPClient
Expand Down
2 changes: 1 addition & 1 deletion src/pygnssutils/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:license: BSD 3-Clause
"""

__version__ = "1.1.19"
__version__ = "1.1.20"
12 changes: 10 additions & 2 deletions src/pygnssutils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ class ParameterError(Exception):
"""Parameter Error Class."""


class GNSSStreamError(Exception):
"""Generic Stream Error Class."""
class GNSSError(Exception):
"""
Master GNSS Error Class.

Any other GNSS exceptions defined here should inherit from this.
"""


class GNSSStreamError(GNSSError):
"""Generic GNSS Stream Error Class."""
2 changes: 1 addition & 1 deletion src/pygnssutils/gnssntripclient_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def main():
type=int,
choices=[0, 1],
default=0,
),
)
ap.add_argument(
"-I",
"--ipprot",
Expand Down
14 changes: 6 additions & 8 deletions src/pygnssutils/gnssreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
UBXTypeError,
)

from pygnssutils.exceptions import GNSSStreamError

NMEA_PROTOCOL = 1
"""NMEA Protocol"""
UBX_PROTOCOL = 2
Expand All @@ -88,10 +90,6 @@
"""RTCM3 Protocol"""


class StreamError(Exception):
"""Stream Error Class."""


class GNSSReader:
"""
GNSSReader class.
Expand Down Expand Up @@ -246,7 +244,7 @@ def read(self) -> tuple:
continue
# unrecognised protocol header
else:
raise ValueError(f"Unknown protocol header {bytehdr}.")
raise GNSSStreamError(f"Unknown protocol header {bytehdr}.")

except EOFError:
return (None, None)
Expand All @@ -271,7 +269,7 @@ def read(self) -> tuple:
QGCParseError,
QGCStreamError,
QGCTypeError,
StreamError,
GNSSStreamError,
) as err:
if self._quitonerror:
self._do_error(err)
Expand Down Expand Up @@ -434,7 +432,7 @@ def _read_bytes(self, size: int) -> bytes:
if len(data) == 0: # EOF
raise EOFError()
if 0 < len(data) < size: # truncated stream
raise StreamError(
raise GNSSStreamError(
"Serial stream terminated unexpectedly. "
f"{size} bytes requested, {len(data)} bytes returned."
)
Expand All @@ -453,7 +451,7 @@ def _read_line(self) -> bytes:
if len(data) == 0:
raise EOFError() # pragma: no cover
if data[-1:] != b"\x0a": # truncated stream
raise StreamError(
raise GNSSStreamError(
"Serial stream terminated unexpectedly. "
f"Line requested, {len(data)} bytes returned."
)
Expand Down