summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2019-03-23 16:16:28 -0700
committerFred Wright <fw@fwright.net>2019-03-27 20:26:10 -0700
commit9f80e0303cdd96be49cb242e207fc5d9176ea987 (patch)
treefd237dd28ae984ab1233bffa54efdefd04d496ff
parentaa471d61c13829b950d7d978635bc6a33ac8efb0 (diff)
downloadgpsd-9f80e0303cdd96be49cb242e207fc5d9176ea987.tar.gz
ubxtool: Improves CFG-PRT decoding.
1) Provides a decode of the port type. 2) Makes the type-dependent portions of the decode appropriately conditional. 3) Includes the final always-reserved word. 4) Formats the slaveAddr in the DDC case. As a side effect, txReady is moved to the earlier line to group it with other type-independent decodes. TESTED: Tested on LEA-6S, LEA-M8F, LEA-M8T, and LEA-M8N
-rwxr-xr-xubxtool52
1 files changed, 40 insertions, 12 deletions
diff --git a/ubxtool b/ubxtool
index 959d7afc..cbcc3b31 100755
--- a/ubxtool
+++ b/ubxtool
@@ -137,6 +137,13 @@ class ubx(object):
5: 'QZSS',
6: 'GLONASS'}
+ # Names for portID values in UBX-CFG-PRT
+ port_ids = {1: 'UART',
+ 3: 'USB',
+ 4: 'SPI',
+ 0: 'DDC', # The inappropriate name for i2c used in the spec
+ }
+
def ack_ack(self, buf):
"UBX-ACK-ACK decode"
m_len = len(buf)
@@ -382,16 +389,34 @@ class ubx(object):
if 0 == m_len:
return " Poll request"
+ portid = buf[0]
+ idstr = '%u (%s)' % (portid, self.port_ids.get(portid, '?'))
+
if 1 == m_len:
- return " Poll request PortID %d" % buf[0]
+ return " Poll request PortID %s" % idstr
+ # Note that this message can contain multiple 20-byte submessages, but
+ # only in the send direction, which we don't currently do.
if 20 > m_len:
return "Bad Length %s" % m_len
- u = struct.unpack_from('<BBHLLHHH', buf, 0)
- s = (' PortID: %u reserved1 %u\n'
- ' txReady: %#x mode: %#x baudRate: %u\n'
- ' inProtoMask: %#x outProtoMask: %#x flags: %#x\n' % u)
+ u = struct.unpack_from('<BBHLLHHHH', buf, 0)
+
+ s = [' PortID: %s reserved1: %u txReady: %#x' % (idstr, u[1], u[2])]
+ s.append({1: ' mode: %#x baudRate: %u',
+ 3: ' reserved2: [%u %u]',
+ 4: ' mode: %#x reserved2: %u',
+ 0: ' mode: %#x reserved2: %u',
+ }.get(portid, ' ???: %u,%u') % tuple(u[3:5]))
+ s.append(' inProtoMask: %#x outProtoMask: %#x' % tuple(u[5:7]))
+ s.append({1: ' flags: %#x reserved2: %u',
+ 3: ' reserved3: %u reserved4: %u',
+ 4: ' flags: %#x reserved3: %u',
+ 0: ' flags: %#x reserved3: %u',
+ }.get(portid, ' ???: %u,%u') % tuple(u[7:]))
+
+ if portid == 0:
+ s.append(' slaveAddr: %#x' % (u[3] >> 1 & 0x7F))
dec = []
if u[5] & 0x1:
@@ -402,7 +427,7 @@ class ubx(object):
dec.append('RTCM2')
if u[5] & 0x20:
dec.append('RTCM3')
- s += (' inProtoMask: %s\n' % ' '.join(dec))
+ s.append(' inProtoMask: %s' % ' '.join(dec))
dec = []
if u[6] & 0x1:
@@ -411,12 +436,15 @@ class ubx(object):
dec.append('NMEA')
if u[6] & 0x20:
dec.append('RTCM3')
- s += (' outProtoMask: %s\n' % ' '.join(dec))
- dec = []
- if u[7] & 0x2:
- dec.append('extendedTxTimeout')
- s += (' flags: %s' % ' '.join(dec))
- return s
+ s.append(' outProtoMask: %s' % ' '.join(dec))
+
+ if portid in set([1, 4, 0]):
+ dec = []
+ if u[7] & 0x2:
+ dec.append('extendedTxTimeout')
+ s.append(' flags: %s' % ' '.join(dec))
+
+ return '\n'.join(s)
def cfg_sbas(self, buf):
"UBX-CFG-SBAS decode"