Closed GoogleCodeExporter closed 8 years ago
Adding the following to Utilities class
@classmethod
def hex2signed16bit(self, s):
value = long(s, 16)
if value > 32767:
value = value - 2L*32767 - 2
assert -32767-1 <= value <= 32767
return int(value)
And using it for the altitude reading seem to help in my case
e.g.
def fromHex(self, hex):
if len(hex) == 30:
self.latitude = Coordinate().fromHex(hex[0:8])
self.longitude = Coordinate().fromHex(hex[8:16])
self.altitude = Utilities.hex2signed16bit(hex[16:20])
self.speed = Utilities.hex2dec(hex[20:24])/100
self.heartrate = Utilities.hex2dec(hex[24:26])
self.interval =
datetime.timedelta(seconds=Utilities.hex2dec(hex[26:30])/10.0)
return self
else:
raise GH600ParseException(self.__class__.__name__, len(hex), 30)
I found a code sniped with the help of goggle here:
http://mail.python.org/pipermail/python-list/2003-July/215016.html
That I stole...
Original comment by ZingoAnd...@gmail.com
on 15 Sep 2008 at 7:04
Original comment by spei...@gmail.com
on 15 Sep 2008 at 10:00
fixed in revision 206
Thanks for reporting
Original comment by spei...@gmail.com
on 6 Aug 2009 at 8:47
There seem to still be something fish here, just got this:
<pt tm="27195" lat="55.387123" lon="14.2023" ele="0" hr="0" />
<pt tm="27201" lat="55.387042" lon="14.202207" ele="0" hr="0" />
<pt tm="27206" lat="55.386985" lon="14.202088" ele="32766" hr="0" />
<pt tm="27212" lat="55.386875" lon="14.201918" ele="32765" hr="0" />
<pt tm="27217" lat="55.386825" lon="14.201823" ele="32765" hr="0" />
<pt tm="27223" lat="55.386767" lon="14.201747" ele="32766" hr="0" />
<pt tm="27228" lat="55.386738" lon="14.201708" ele="32766" hr="0" />
<pt tm="27234" lat="55.386665" lon="14.201647" ele="32766" hr="0" />
<pt tm="27239" lat="55.386612" lon="14.20162" ele="0" hr="0" />
<pt tm="27245" lat="55.386558" lon="14.20153" ele="0" hr="0" />
Original comment by ZingoAnd...@gmail.com
on 17 Aug 2009 at 8:41
This solves the problem:
@classmethod
def hex2signedDec(self, hex):
value = self.hex2dec(hex)
if value > 32767:
value = value - 2L*32767 - 2
return int(value)
Original comment by ZingoAnd...@gmail.com
on 24 Aug 2009 at 7:57
Original issue reported on code.google.com by
ZingoAnd...@gmail.com
on 14 Sep 2008 at 10:28