summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2019-03-23 18:22:53 -0700
committerFred Wright <fw@fwright.net>2019-03-27 20:26:22 -0700
commitcb43959238b70957f25caa99ef3410fa757d07c5 (patch)
treeea9ce9cc856713eb5b7f2eae4de03bc94d4ab057
parent9f80e0303cdd96be49cb242e207fc5d9176ea987 (diff)
downloadgpsd-cb43959238b70957f25caa99ef3410fa757d07c5.tar.gz
ubxtool: Adds interface option for UBX-CFG-PRT.
The UBX-CFG-PRT command can specify any port, though it defaults to the current port. This option allows the port ID to be specified, either as a name or as an integer. At present, it only affects the PRT preset, though it could be used for other port-related commands in the future. Note that the baud rate is only applicable to the UART port, so there's no point in applying this to the -S option. TESTED: Tested on LEA-6S, LEA-M8F, LEA-M8T, and LEA-M8N
-rw-r--r--man/ubxtool.xml8
-rwxr-xr-xubxtool25
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.
diff --git a/ubxtool b/ubxtool
index cbcc3b31..ffb22f52 100755
--- a/ubxtool
+++ b/ubxtool
@@ -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':