From 4e8bf4c8aab6952b1e52e4fb0b10b4100bd80149 Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Thu, 4 Apr 2019 18:52:16 -0700 Subject: ubxtool: Add -g option for UBX-CFG-VALGET. Plus some stuff to encode/decoide config items. --- ubxtool | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 5 deletions(-) (limited to 'ubxtool') diff --git a/ubxtool b/ubxtool index e6c46144..508e9d9e 100755 --- a/ubxtool +++ b/ubxtool @@ -78,6 +78,8 @@ opts = { 'enable': None, # default input -f file 'input_file_name': None, + # default -g item + 'get_item': None, # default forced wait? -W 'input_forced_wait': False, # default port speed -s @@ -1395,6 +1397,24 @@ class ubx(object): "Flag to indicate if RTCM3X should be an output protocol on USB"), ) + def cfg_by_key(self, key): + """Find a config item by key""" + + for item in self.cfgs: + if item[1] == key: + return item + + return None + + def cfg_by_name(self, name): + """Find a config item by name""" + + for item in self.cfgs: + if item[0] == name: + return item + + return None + def ack_ack(self, buf): "UBX-ACK-ACK decode" m_len = len(buf) @@ -1896,13 +1916,22 @@ class ubx(object): if 4 > m_len: return "Bad Length %s" % m_len - # we are at least protver 27 - if 79 > opts['protver']: - opts['protver'] = 27 + # this is a poll options, so does not set min protver u = struct.unpack_from('> 8) & 0xff + m_data[6] = (key >> 16) & 0xff + m_data[7] = (key >> 24) & 0xff + gps_model.gps_send(0x06, 0x8b, m_data) + def send_tim_svin(self): "UBX-TIM-SVIN, get survey in data" m_data = bytearray(0) @@ -3797,6 +3837,7 @@ def usage(): ' -e E enable E\n' ' -f F open F as file/device\n' ' default: %s\n' + ' -g G get config item G\n' ' -h print help\n' ' -i I interface (port) for UBX-CFG-PRT\n' ' -m M optional mode to -p P\n' @@ -3843,7 +3884,7 @@ else: try: (options, arguments) = getopt.getopt(options, - "?c:d:e:f:hi:m:rP:p:s:w:v:R:S:V") + "?c:d:e:f:g: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" % @@ -3859,6 +3900,8 @@ for (opt, val) in options: opts['enable'] = val elif opt == '-f': opts['input_file_name'] = val + elif opt == '-g': + opts['get_item'] = val elif opt == '-h' or opt == '-?': usage() elif opt == '-i': @@ -4007,6 +4050,15 @@ try: sys.stderr.write('%s: command %s\n' % (PROG_NAME, opts['command'])) gps_model.gps_send(cmd_data[0], cmd_data[1], payload) + elif opts['get_item'] is not None: + item = gps_model.cfg_by_name(opts['get_item']) + if item: + gps_model.send_cfg_valget(item[1]) + else: + sys.stderr.write('%s: ERROR: item %s unknown\n' % + (PROG_NAME, opts['get_item'])) + exit(1) + exit_code = io_handle.read(opts) if ((VERB_RAW <= opts['verbosity']) and io_handle.out): -- cgit v1.2.1