Skip to content

No negative altitudes #1

@VictorMarinus

Description

@VictorMarinus

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions