diff options
author | Gary E. Miller <gem@rellim.com> | 2019-05-21 13:08:49 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2019-05-21 13:08:49 -0700 |
commit | 541bb5e6862a26138849e66175104e8b4b319dcc (patch) | |
tree | 0471f8a5cecabfda10d4728b5cfc007fdc4288d8 /ubxtool | |
parent | eb3e8ca856524200264c651d7cf9e35ec71e57d8 (diff) | |
download | gpsd-541bb5e6862a26138849e66175104e8b4b319dcc.tar.gz |
ubxtool: Convert mon_comms() to use index_s().
Of course u-blox uses different port mappings in different
messages...
Diffstat (limited to 'ubxtool')
-rwxr-xr-x | ubxtool | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -2286,12 +2286,13 @@ class ubx(object): # UBX-LOG- ??? # UBX-MGA- ??? - def _protId(self, id): - """Convert protId to string""" - protId = {0: "UBX", 1: "NMEA", 2: "RTCM2", 5: "RTCM3", 255: "None"} - if id in protId: - return protId[id] - return "Unk" + mon_comms_prot = { + 0: "UBX", + 1: "NMEA", + 2: "RTCM2", + 5: "RTCM3", + 255: "None", + } def mon_comms(self, buf): """UBX-MON-COMMS decode""" @@ -2306,16 +2307,15 @@ class ubx(object): s = ('version %u nPorts %u txErrors %#x reserved1 %u\n' 'protIds %#x/%x/%x/%x' % u) s += (' (%s/%s/%s/%s)\n' % - (self._protId(u[4]), self._protId(u[5]), - self._protId(u[6]), self._protId(u[7]))) + (index_s(u[4], self.mon_comms_prot), + index_s(u[5], self.mon_comms_prot), + index_s(u[6], self.mon_comms_prot), + index_s(u[7], self.mon_comms_prot))) i = 0 while m_len > (8 + (i * 40)): u = struct.unpack_from('<HHLBBHLBBHHHHHLLL', buf, (8 + (i * 40))) - if u[0] in self.port_ids1: - name = "%#x (%s)" % (u[0], self.port_ids1[u[0]]) - else: - name = "%#x (UNK)" % u[0] + name = "%#x (%s)" % (u[0], index_s(u[0], self.port_ids1)) if 0 < i: s += "\n" s += ' Port: %s\n' % name |