Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UBX-NAV-SAT message #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 32 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
53 changes: 53 additions & 0 deletions ubx/UBX/NAV.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,59 @@ 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,
allowed={
0: 'GPS',
1: 'SBAS',
2: 'Galileo',
3: 'BeiDou',
4: 'IMES',
5: 'QZSS',
6: 'GLONASS',
})
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:

Expand Down