From 2dab8f59045365463a33013cd1f95140943193fd Mon Sep 17 00:00:00 2001 From: Tom Flanagan Date: Sun, 21 Mar 2021 22:38:07 -0700 Subject: [PATCH] Fix #121 UBX rendering --- pynmea2/_version.py | 2 +- pynmea2/types/proprietary/ubx.py | 11 ++++++----- test/test_proprietary.py | 10 +++++++++- test/test_pynmea.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pynmea2/_version.py b/pynmea2/_version.py index ce51117..5fe69a4 100644 --- a/pynmea2/_version.py +++ b/pynmea2/_version.py @@ -1 +1 @@ -__version__ = '1.16.0' +__version__ = '1.17.0' diff --git a/pynmea2/types/proprietary/ubx.py b/pynmea2/types/proprietary/ubx.py index f9743af..7df0e26 100644 --- a/pynmea2/types/proprietary/ubx.py +++ b/pynmea2/types/proprietary/ubx.py @@ -14,15 +14,13 @@ def __new__(_cls, manufacturer, data): cls = _cls.sentence_types.get(name, _cls) return super(UBX, cls).__new__(cls) - def __init__(self, manufacturer, data): - self.sentence_type = manufacturer + data[1] - super(UBX, self).__init__(manufacturer, data[2:]) - class UBX00(UBX, LatLonFix): """ Lat/Long Position Data """ fields = ( + ("Blank", "_blank"), + ("UBX Type", "ubx_type"), ("Timestamp (UTC)", "timestamp", timestamp), ("Latitude", "lat"), ("Latitude Direction", "lat_dir"), @@ -41,7 +39,6 @@ class UBX00(UBX, LatLonFix): ("Time Dilution of Precision", "tdop"), ("Number of Satellites Used", "num_svs"), ("Reserved", "reserved") - ) @@ -49,6 +46,8 @@ class UBX03(UBX): """ Satellite Status """ fields = ( + ("Blank", "_blank"), + ("UBX Type", "ubx_type"), ("Number of GNSS Satellites Tracked", "num_sv", int), ) @@ -61,6 +60,8 @@ class UBX04(UBX): """ Time and Day Clock Information """ fields = ( + ("Blank", "_blank"), + ("UBX Type", "ubx_type"), ("UTC Time", "time", timestamp), ("UTC Date", "date", datestamp), ("UTC Time of Week", "utc_tow"), diff --git a/test/test_proprietary.py b/test/test_proprietary.py index f99972d..3e6a526 100644 --- a/test/test_proprietary.py +++ b/test/test_proprietary.py @@ -105,10 +105,11 @@ def test_srf(): data = '$PSRF999,0,1200,8,1,1' msg = pynmea2.parse(data) assert type(msg) == pynmea2.srf.SRF + assert msg.render(checksum=False) == data def test_grm(): - data = ' $PGRME,15.0,M,45.0,M,25.0,M*1C' + data = '$PGRME,15.0,M,45.0,M,25.0,M*1C' msg = pynmea2.parse(data) assert type(msg) == pynmea2.grm.GRME assert msg.sentence_type == 'GRME' @@ -118,6 +119,7 @@ def test_grm(): assert msg.vpe_unit == 'M' assert msg.osepe == 25.0 assert msg.osepe_unit == 'M' + assert msg.render() == data def test_tnl(): @@ -127,15 +129,19 @@ def test_tnl(): assert msg.datestamp == datetime.date(2007,12,2) assert msg.latitude == 37.384897319 assert msg.longitude == -122.00543668866666 + assert msg.render() == data def test_ubx00(): data = '$PUBX,00,074440.00,4703.74203,N,00736.82976,E,576.991,D3,2.0,2.0,0.091,0.00,-0.032,,0.76,1.05,0.65,14,0,0*70' msg = pynmea2.parse(data) assert type(msg) == pynmea2.ubx.UBX00 + assert msg.identifier() == 'PUBX' + assert msg.ubx_type == '00' assert msg.timestamp == datetime.time(7, 44, 40) assert msg.latitude == 47.06236716666667 assert msg.lat_dir == 'N' + assert msg.render() == data def test_ubx03(): @@ -143,6 +149,7 @@ def test_ubx03(): msg = pynmea2.parse(data) assert type(msg) == pynmea2.ubx.UBX03 assert msg.num_sv == 20 + assert msg.render() == data def test_ubx04(): @@ -152,6 +159,7 @@ def test_ubx04(): assert msg.date == datetime.date(2014, 10, 13) assert msg.time == datetime.time(7, 38, 24) assert msg.clk_bias == 495176 + assert msg.render() == data def test_create(): diff --git a/test/test_pynmea.py b/test/test_pynmea.py index 2723b0c..5379e20 100644 --- a/test/test_pynmea.py +++ b/test/test_pynmea.py @@ -5,7 +5,7 @@ def test_version(): - version = '1.16.0' + version = '1.17.0' assert pynmea2.version == version assert pynmea2.__version__ == version