You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently the code can not handle negative altitudes. Those living in the low-lands will get weird results. going from 0 m to 65535m between two measurements.
The altitude hex code from the LOCUS dump is "two's complement" so it has to be treated like that.
I added the twos_complement function and changed the parseInt function and now the results match the NMEA parsed results.
`def parseInt(bytes):
if len(bytes) != 2:
print >> sys.stderr, "WARNING: expecting 2 bytes got %s" % bytes
number = ((0xFF & bytes[1]) << 8) | (0xFF & bytes[0])
number = twos_complement(number, 16)
return number
def twos_complement(n, w):
if n & (1 << (w - 1)): n = n - (1 << w)
return n`
The text was updated successfully, but these errors were encountered:
Apparently the code can not handle negative altitudes. Those living in the low-lands will get weird results. going from 0 m to 65535m between two measurements.
The altitude hex code from the LOCUS dump is "two's complement" so it has to be treated like that.
I added the twos_complement function and changed the parseInt function and now the results match the NMEA parsed results.
`def parseInt(bytes):
if len(bytes) != 2:
print >> sys.stderr, "WARNING: expecting 2 bytes got %s" % bytes
number = ((0xFF & bytes[1]) << 8) | (0xFF & bytes[0])
number = twos_complement(number, 16)
return number
def twos_complement(n, w):
if n & (1 << (w - 1)): n = n - (1 << w)
return n`
The text was updated successfully, but these errors were encountered: