I´m looking for some help converting CAN packets from a PCAN-GPS unit to long/lat GPS coordinates.
For example i receive Data=90F98E400A0045 for longitude and the package is in the following format:
imgur link
So I get the Degree and Indicator part which match my location from Google Maps but when I try to convert the hex value to a floating point I either get enormous or tiny float values that are not longitude values.
I wrote this code (and some other variations) in Python. My location is somewhere in germany ;)
s = ['E8', '5F', '8F', '40', '0A', '00', '45']
con = []
x = ""
def tohex(hex_string):
return ''.join('{0:04b}'.format(int(c, 16)) for c in hex_string)
def long(str):
min = str[:32]
vorz = min[:1]
mat = int(min[1:24], 2)
exp = int(min[24:32], 2)
l = (2**exp) * float("0."+mat.__str__())
deg = str[32:48]
print(int(deg,2))
return l
for e in s:
con.append(tohex(e))
x += tohex(e)
print("%.100f" % long(x))