1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00

Bsongis/crossfire refactoring (#3613)

* Crossfire refactoring

* Crossfire script now displaying fields

* Crossfire script now displaying text selection values
This commit is contained in:
Bertrand Songis 2016-06-18 22:16:50 +02:00 committed by GitHub
parent ab58151f2a
commit 53b51cac94
16 changed files with 289 additions and 178 deletions

View file

@ -10,6 +10,21 @@ import sys
lineNumber = 0
crossfireDataBuff = []
crossfire_types = [
"UINT8",
"INT8",
"UINT16",
"INT16",
"UINT32",
"INT32",
"UINT64",
"INT64",
"FLOAT",
"TEXT_SELECTION",
"STRING",
"FOLDER"
]
def dump(data, maxLen=None):
if maxLen and len(data) > maxLen:
data = data[:maxLen]
@ -43,10 +58,22 @@ def ParsePingDevices(_):
return '[Ping Devices]'
def ParseDevice(payload):
return '[Device] "%s" %d parameters' % ("".join([chr(c) for c in payload[2:-14]]), payload[-1])
return '[Device] 0x%02x "%s" %d parameters' % (payload[1], "".join([chr(c) for c in payload[2:-14]]), payload[-1])
def ParseFieldsRequest(payload):
return '[Fields request] Device=0x%02x' % payload[0]
return '[Fields request]'
def ParseFieldRequest(payload):
return '[Field request] device=0x%02x field=%d' % (payload[1], payload[2])
def ParseField(payload):
name = ""
i = 5
while payload[i] != 0:
name += chr(payload[i])
i += 1
i += 1
return '[Field] %s device=0x%02x field=%d parent=%d type=%s' % (name, payload[1], payload[2], payload[3], crossfire_types[payload[4]])
parsers = (
(0x02, ParseGPS),
@ -57,6 +84,8 @@ parsers = (
(0x28, ParsePingDevices),
(0x29, ParseDevice),
(0x2a, ParseFieldsRequest),
(0x2b, ParseField),
(0x2c, ParseFieldRequest),
)
def ParsePacket(packet):