From dd803aa2f14e095135a57385922921c2234ae2d4 Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Fri, 24 May 2019 19:37:06 -0700 Subject: ubxtool: Better decode of GPS subframe 5. Some of it is correct, some not, not sure what is going on. --- ubxtool | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 8 deletions(-) (limited to 'ubxtool') diff --git a/ubxtool b/ubxtool index 51cd8f33..e604b1b9 100755 --- a/ubxtool +++ b/ubxtool @@ -25,6 +25,9 @@ usage: ubxtool [OPTIONS] [server[:port[:device]]] # # To read GPS messages a log file: # ubxtool -v 2 -f test/daemon/ublox-neo-m8n.log +# +# References: +# [1] IS-GPS-200J from __future__ import absolute_import, print_function, division @@ -126,6 +129,28 @@ opts = { # I'd like to use pypy module bitstring or bitarray, but # people complain when non stock python modules are used here. +def unpack_s11(word, pos): + """Grab a signed 11 bits from offset pos of word""" + + bytes = bytearray(2) + bytes[0] = (word >> pos) & 0xff + bytes[1] = (word >> (pos + 8)) & 0x07 + if 0x04 & bytes[1]: + # extend the sign + bytes[1] |= 0xf8 + u = struct.unpack_from('> 22) & 0xff + newword <<= 3 + newword |= (word >> 8) & 0x07 + return unpack_s11(newword, 0) + + def unpack_s16(word, pos): """Grab a signed two bytes from offset pos of word""" @@ -163,6 +188,35 @@ def unpack_s22(word, pos): return u[0] +def unpack_s24(word, pos): + """Grab a signed 24 bits from offset pos of word""" + + bytes = bytearray(4) + bytes[0] = (word >> pos) & 0xff + bytes[1] = (word >> (pos + 8)) & 0xff + bytes[2] = (word >> (pos + 16)) & 0xff + bytes[3] = 0 + if 0x80 & bytes[2]: + # extend the sign + bytes[3] = 0xff + + u = struct.unpack_from('> pos) & 0xff + bytes[1] = (word >> (pos + 8)) & 0xff + bytes[2] = (word >> (pos + 16)) & 0xff + bytes[3] = 0 + + u = struct.unpack_from('> 22) & 0x3f - page = index_s(svid, self.sbfr4_svid_page) + if 0 < svid: + page = index_s(svid, self.sbfr4_svid_page) + else: + # page of zero means the svId that sent it. + page = "%d/Self" % svId + s += ("\n dataid %u svid %u (page %s)\n" % (words[2] >> 28, svid, page)) @@ -3554,6 +3625,7 @@ class ubx(object): elif 5 == subframe: svid = (words[2] >> 22) & 0x3f page = index_s(svid, self.sbfr5_svid_page) + s += ("\n dataid %u svid %u (page %s)\n" % (words[2] >> 28, svid, page)) -- cgit v1.2.1