From 9f80e0303cdd96be49cb242e207fc5d9176ea987 Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Sat, 23 Mar 2019 16:16:28 -0700 Subject: 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 --- ubxtool | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file 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('> 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" -- cgit v1.2.1