diff options
-rw-r--r-- | man/ubxtool.xml | 8 | ||||
-rwxr-xr-x | ubxtool | 25 |
2 files changed, 28 insertions, 5 deletions
diff --git a/man/ubxtool.xml b/man/ubxtool.xml index 97a897bd..a23e6c08 100644 --- a/man/ubxtool.xml +++ b/man/ubxtool.xml @@ -33,6 +33,7 @@ BSD terms apply: see the file COPYING in the distribution root for details. <arg choice='opt'>-f <replaceable>file/device</replaceable> </arg> <arg choice='opt'>-h </arg> + <arg choice='opt'>-i <replaceable>interface</replaceable></arg> <arg choice='opt'>-m <replaceable>mode</replaceable></arg> <arg choice='opt'>-P <replaceable>protver</replaceable></arg> <arg choice='opt'>-p <replaceable>preset</replaceable></arg> @@ -180,6 +181,13 @@ a usage message and exit.</para> </listitem> </varlistentry> <varlistentry> + <term>-i interface</term> + <listitem> + <para>Specifies interface (port) for port-related commands. +</para> + </listitem> + </varlistentry> + <varlistentry> <term>-m mode</term> <listitem> <para>Sets optional mode parameter to a -p PRESET command. @@ -84,6 +84,8 @@ opts = { 'input_speed': 9600, # default input wait time -w in seconds 'input_wait': 2.0, + # interface for port-related commands + 'interface': None, # optional mode to -p P 'mode': None, # the name of an OAF file, extension .jpo @@ -143,6 +145,7 @@ class ubx(object): 4: 'SPI', 0: 'DDC', # The inappropriate name for i2c used in the spec } + port_id_map = dict([x[::-1] for x in port_ids.items()]) def ack_ack(self, buf): "UBX-ACK-ACK decode" @@ -1946,17 +1949,25 @@ class ubx(object): gps_model.gps_send(6, 0x86, m_data) def send_cfg_prt(self): - "UBX-CFG-PRT, get I/O Port" - m_data = bytearray(0) + "UBX-CFG-PRT, get I/O Port settings" + port = opts['interface'] + if port is None: + m_data = bytearray() + else: + m_data = bytearray([port]) gps_model.gps_send(6, 0x0, m_data) def send_set_speed(self, speed): "UBX-CFG-PRT, set port" + # Note that this is only applicable to the UART port (1), + # so there's no need to pay attention to 'interface'. + # If there's any possibility for a receiver to have multiple + # UART ports, it's not mentioned in the doc. + # FIXME! Poll current masks, then adjust speed m_data = bytearray(20) - m_data[0] = 1 # port 1, UART 1 - # m_data[0] = 3 # port 3, USB + m_data[0] = 1 # port 1, UART m_data[4] = 0xc0 # 8N1 m_data[5] = 0x8 # 8N1 @@ -2390,6 +2401,7 @@ def usage(): ' -f F open F as file/device\n' ' default: %s\n' ' -h print help\n' + ' -i I interface (port) for UBX-CFG-PRT\n' ' -m M optional mode to -p P\n' ' -P P Protocol version for sending commands\n' ' default: %s\n' @@ -2434,7 +2446,7 @@ else: try: (options, arguments) = getopt.getopt(options, - "?c:d:e:f:hm:rP:p:s:w:v:R:S:V") + "?c:d:e:f:hi:m:rP:p:s:w:v:R:S:V") except getopt.GetoptError as err: sys.stderr.write("%s: %s\n" "Try '%s -h' for more information.\n" % @@ -2452,6 +2464,9 @@ for (opt, val) in options: opts['input_file_name'] = val elif opt == '-h' or opt == '-?': usage() + elif opt == '-i': + valnum = gps_model.port_id_map.get(val.upper()) + opts['interface'] = valnum if valnum is not None else int(val) elif opt == '-m': opts['mode'] = int(val) elif opt == '-P': |