From 94621c94819585fbdf5e67ece847865930847f68 Mon Sep 17 00:00:00 2001 From: matthewlh Date: Fri, 18 Sep 2020 15:55:28 -0600 Subject: [PATCH 1/4] WIP: Implement UBX-NAV-SAT message --- ubx/UBX/NAV.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/ubx/UBX/NAV.py b/ubx/UBX/NAV.py index b04336c..b742491 100644 --- a/ubx/UBX/NAV.py +++ b/ubx/UBX/NAV.py @@ -59,6 +59,50 @@ class Repeated: axim = I2(7) prRes = I4(8) + @addGet + class SAT: + + _id = 0x35 + + class Fields: + iTOW = U4(1) + version = U1(2) + numSvs = U1(3) + reserved0 = U2(4) + + class Repeated: + gnssId = U1(1) + svId = U1(2) + cno = U1(3) + elev = I1(4) + azim = I2(5) + prRes = I2(6) + flags = X4(7) + + @property + def TOW_str(self): + mins, millis = divmod(self.iTOW, 60000) + hours, mins = divmod(mins, 60) + days, hours = divmod(hours, 24) + return "{:1d}-{:02d}:{:02d}:{:04.1f}gps".format(days, hours, mins, millis/1000) + + def summary(self): + summary_str = "UBX.NAV.SAT: TOW: {}, version: {}, numSvs: {}".format( + self.TOW_str, self.version, self.numSvs) + + for i in range(1, self.numSvs+1): + summary_str += "\r\n gnssId: {: >2}, svId: {: >3}, cno: {: >3} dBHz, elev: {: >3}, azim: {: >3}, prRes: {: >5}, flags: 0x{:08X}".format( + self.__getattribute__(f'gnssId_{i}'), + self.__getattribute__(f'svId_{i}'), + self.__getattribute__(f'cno_{i}'), + self.__getattribute__(f'elev_{i}'), + self.__getattribute__(f'azim_{i}'), + self.__getattribute__(f'prRes_{i}'), + self.__getattribute__(f'flags_{i}') + ) + + return(summary_str) + @addGet class PVT: From 172192b1d130ce88988a79c4e0db29051ae1b118 Mon Sep 17 00:00:00 2001 From: matthewlh Date: Fri, 18 Sep 2020 16:20:00 -0600 Subject: [PATCH 2/4] Update NAV.py Add gnssId allowed definition --- ubx/UBX/NAV.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ubx/UBX/NAV.py b/ubx/UBX/NAV.py index b742491..8265510 100644 --- a/ubx/UBX/NAV.py +++ b/ubx/UBX/NAV.py @@ -71,7 +71,16 @@ class Fields: reserved0 = U2(4) class Repeated: - gnssId = U1(1) + gnssId = U1(1, + allowed={ + 0: 'GPS', + 1: 'SBAS', + 2: 'Galileo', + 3: 'BeiDou', + 4: 'IMES', + 5: 'QZSS', + 6: 'GLONASS', + }) svId = U1(2) cno = U1(3) elev = I1(4) From d4c11353bbbf6df2f3e3bf3a27b0eececc0a53b3 Mon Sep 17 00:00:00 2001 From: matthewlh Date: Fri, 18 Sep 2020 16:24:18 -0600 Subject: [PATCH 3/4] Update readme.md Fix indent and formatting for classes NAV and qES, add NAV-SAT --- readme.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 3cc514e..37efe60 100644 --- a/readme.md +++ b/readme.md @@ -147,12 +147,13 @@ MON-VER - `VER`: Receiver/Software Version - `HW`: Hardware Status - class **`NAV`** - - `PVT`: Position Velocity Time - - `RELPOSNED`: Relative position, as used for differential GPS. Version 1 (uBlox-9) is implemented, which is incompatible with Version 0 (uBlox-8). - - `DOP`: Dilution of precision - - `SVINFO`: -- class `**ESF**` - - `MEAS` + - `PVT`: Position Velocity Time + - `RELPOSNED`: Relative position, as used for differential GPS. Version 1 (uBlox-9) is implemented, which is incompatible with Version 0 (uBlox-8). + - `DOP`: Dilution of precision + - `SVINFO`: Information about satellites used or visible. Deprecated; users are recommended to use the UBX-NAV-SAT message in preference. + - `SAT`: Information about SVs that are either known to be visible or currently tracked by the receiver. +- class **`qES`** + - `MEAS` ## Usage From cbdbf695a816aeb2d5d892ab617cfdda4b5118c9 Mon Sep 17 00:00:00 2001 From: Matthew Lee Handley Date: Wed, 27 Jan 2021 18:23:47 -0700 Subject: [PATCH 4/4] Add test for UBX.NAV.SAT --- tests/tests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/tests.py b/tests/tests.py index 4ba6f9a..20196fa 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -38,6 +38,38 @@ def testMON_VER(self): self.assertEqual(ver.extension_3, "GPS;GLO;GAL;BDS") self.assertEqual(ver.extension_4, "SBAS;IMES;QZSS") + def testNAV_SAT(self): + payload = b'\xB0\x1B\x48\x14\x01\x03\x00\x00\x00\x01\x21\x01\x8A\x00\x18\xFD\x17\x09\x00\x00\x00\x00\x00\x04\x18\xA5\x00\x00\x00\x00\x04\x00\x00\x00\x00\x08\x16\xA5\x00\x00\x00\x00\x03\x00' + sat = parseUBXPayload(UBX.NAV._class, UBX.NAV.SAT._id, payload) + self.assertEqual(sat.iTOW, 0x14481BB0) + self.assertEqual(sat.version, 0x01) + self.assertEqual(sat.numSvs, 0x03) + self.assertEqual(sat.reserved0, 0x0000) + + self.assertEqual(sat.gnssId_1, 0) + self.assertEqual(sat.svId_1, 1) + self.assertEqual(sat.cno_1, 33) + self.assertEqual(sat.elev_1, 1) + self.assertEqual(sat.azim_1, 138) + self.assertEqual(sat.prRes_1, -744) + self.assertEqual(sat.flags_1, 0x00000917) + + self.assertEqual(sat.gnssId_2, 0) + self.assertEqual(sat.svId_2, 0) + self.assertEqual(sat.cno_2, 0) + self.assertEqual(sat.elev_2, 4) + self.assertEqual(sat.azim_2, -23272) + self.assertEqual(sat.prRes_2, 0) + self.assertEqual(sat.flags_2, 0x00040000) + + self.assertEqual(sat.gnssId_3, 0) + self.assertEqual(sat.svId_3, 0) + self.assertEqual(sat.cno_3, 0) + self.assertEqual(sat.elev_3, 8) + self.assertEqual(sat.azim_3, -23274) + self.assertEqual(sat.prRes_3, 0) + self.assertEqual(sat.flags_3, 0x00030000) + def testCFG_GNSS(self): payload = b'\x00\x20\x20\x07\x00\x08\x10\x00\x01\x00\x01\x01\x01\x01\x03\x00\x01\x00\x01\x01\x02\x04\x08\x00\x00\x00\x01\x01\x03\x08\x10\x00\x00\x00\x01\x01\x04\x00\x08\x00\x00\x00\x01\x03\x05\x00\x03\x00\x01\x00\x01\x05\x06\x08\x0e\x00\x01\x00\x01\x01' gnss = parseUBXPayload(UBX.CFG._class, UBX.CFG.GNSS._id, payload)