1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-13 19:40:20 +03:00

Align python crossfire parser to c equivalent (#5595)

Align python Crossfire parser to C equivalent
This commit is contained in:
3djc 2018-01-26 18:57:34 +01:00 committed by Bertrand Songis
parent 8be6818a6d
commit 95df593c2f

View file

@ -5,7 +5,7 @@
from __future__ import division, print_function from __future__ import division, print_function
import sys import sys, struct
lineNumber = 0 lineNumber = 0
crossfireDataBuff = [] crossfireDataBuff = []
@ -77,7 +77,8 @@ def crc8(buffer):
return crc return crc
def ParseGPS(payload): def ParseGPS(payload):
pass lat, long, speed, head, alt, numsat = struct.unpack('>iiHHHB', bytes(bytearray(payload))) # bytes(bytearray) casting is required for python 2.7.3 compatibility
return "[GPS] lat:%f long:%f speed:%d heading:%d alt:%d numsat:%d" % (lat / 1e7, long / 1e7, speed / 100, head / 100, alt - 1000, numsat)
def ParseBattery(payload): def ParseBattery(payload):
voltage = float((payload[0] << 8) + payload[1]) / 10 voltage = float((payload[0] << 8) + payload[1]) / 10