Beispiel #1
0
 def decode_displayport_cmd(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
         ("payload", bytes_to_list(payload[1])),
     )
Beispiel #2
0
 def decode_unknown_0x38(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
         ("payload", bytes_to_list(payload[2:])),
         ("(test) param1", bytes_to_list(payload[2])),
         ("(test) param2", bin(bytes_to_uint(payload[3]))),
         # ("(test) param3", bytes_to_list(payload[4])),  # list index out of range then payload[2] == 4
         ("(test) SEQ NUM", bytes_to_list(payload[5:12])))
Beispiel #3
0
 def decode_command(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
         ("command id", CrsfCommandID(ord(payload[2]))),
         ("command payload", bytes_to_list(payload[3:-1])),
         ("command crc", ord(payload[-1])),
         ("calculated crc",
          calc_crc(list_to_bytes([0x32] + bytes_to_list(payload[0:-1])),
                   'cmd'))  # FIXME
     )
Beispiel #4
0
 def decode_parameter_settings_entry(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
         ("parameter number", ord(payload[2])),
         ("parameter chunks", ord(payload[3])),
         ("parent folder", ord(payload[4])),
         ("hidden", bytes_to_uint(payload[5]) >> 7),
         ("data type", CrsfDataType(ord(payload[5]) % int("10000000", 2))),
         ("payload", unpack_sting(payload[6:]))  # TODO: Unpack more data
     )
Beispiel #5
0
 def decode_msp_write(payload):
     return (("raw",
              bytes_to_list(payload)), ("dst address",
                                        CrsfFrameAddress(ord(payload[0]))),
             ("src address", CrsfFrameAddress(ord(payload[1]))),
             ("MSP data raw", bytes_to_list(payload[2:])),
             ("MSP seq num",
              int(bytes_to_uint(payload[2]))), ("MSP payload length",
                                                int(ord(payload[3]))),
             ("MSP code", MspCodes(ord(payload[4]))),
             ("MSP payload",
              bytes_to_list(payload[5:-1])), ("MSP checksum",
                                              bytes_to_list(payload[-1])))
Beispiel #6
0
 def decode_device_info(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
         ("name", "".join(payload[2:-15])),
         # Zero byte
         ("serial number", bytes_to_uint(payload[-14:-10])),
         ("hardware id",
          hex(bytes_to_uint(payload[-10:-6]))),  # CrsfHardwareID
         ("hardware id (decoded)",
          CrsfHardwareID(bytes_to_uint(payload[-10:-6]) >> 3 << 3)),
         ("firmware id", bytes_to_uint(payload[-6:-2])),
         ("parameter count", ord(payload[-2])),
         ("device info version", ord(payload[-1])))
Beispiel #7
0
 def decode_vtx(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("src address", CrsfFrameAddress(ord(payload[0]))),
         ("comm mode", CrsfVtxInterface(ord(payload[0]) >> 5)),
         ("is VTX available", ord(payload[0]) >> 4 & 1),
         ("is manual freq", ord(payload[0]) >> 1 & 1),  # TODO: test
         ("is PitMode", ord(payload[0]) & 1),
         ("band", ord(payload[2])),
         ("manual frequency", bytes_to_uint(payload[3:4])),
         ("PitMode", CrsfVtxPitmode(ord(payload[5]) >> 4)),
         ("power", CrsfVtxXPower(ord(payload[5]) & int('111', 2))))
Beispiel #8
0
 def decode(self):
     self.address = CrsfFrameAddress(self.address)
     self.data_size = ord(self.raw[1])
     self.frame_type = CrsfFrameType(self.frame_type)
     self.payload = CrsfPayload(self.frame_type, self.payload)
Beispiel #9
0
 def decode_parameter_write(payload):
     return (("raw", bytes_to_list(payload)),
             ("dst address", CrsfFrameAddress(ord(payload[0]))),
             ("src address", CrsfFrameAddress(ord(payload[1]))),
             ("parameter number",
              ord(payload[2])), ("data", bytes_to_list(payload[3:])))
Beispiel #10
0
 def decode_device_ping(payload):
     return (
         ("raw", bytes_to_list(payload)),
         ("dst address", CrsfFrameAddress(ord(payload[0]))),
         ("src address", CrsfFrameAddress(ord(payload[1]))),
     )
Beispiel #11
0
 def decode_unknown_0x36(payload):
     return (("raw", bytes_to_list(payload)),
             ("dst address", CrsfFrameAddress(ord(payload[0]))),
             ("src address", CrsfFrameAddress(ord(payload[1]))),
             ("payload", bytes_to_list(payload[2:])))