summaryrefslogtreecommitdiff
path: root/ubxtool
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2019-05-21 13:08:49 -0700
committerGary E. Miller <gem@rellim.com>2019-05-21 13:08:49 -0700
commit541bb5e6862a26138849e66175104e8b4b319dcc (patch)
tree0471f8a5cecabfda10d4728b5cfc007fdc4288d8 /ubxtool
parenteb3e8ca856524200264c651d7cf9e35ec71e57d8 (diff)
downloadgpsd-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-xubxtool24
1 files changed, 12 insertions, 12 deletions
diff --git a/ubxtool b/ubxtool
index a1f7548b..a04f0549 100755
--- a/ubxtool
+++ b/ubxtool
@@ -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