Module ddCommunication.protocols.LCPWirelessProtocol.WLCPWrapper.WLCPPowerUpHandshake

Expand source code
from enum import IntEnum
from math import floor
import struct


class OEM_LCP_ID(IntEnum):
    LCP_BASIC_INTELLIFLO = 1
    LCP_TEK = 0xFF

class WLCPPowerUpHandshake:

    def __init__(self, LCP_ID, LCP_SW_Version, ProtocolVersion=0x01):
        self.ID = LCP_ID
        self.LCPVersion = LCP_SW_Version
        self.ProtocolVersion = ProtocolVersion

    def GetBytes(self):
        padding = 0x00
        b = self.ID.to_bytes(1, byteorder="little")
        LCPVersionMajor = int(floor(self.LCPVersion))
        b += LCPVersionMajor.to_bytes(2, byteorder="little")
        b += int((self.LCPVersion - LCPVersionMajor)
                 * 10_000).to_bytes(2, byteorder="big")
        b += padding.to_bytes(1, byteorder="little")
        b += padding.to_bytes(1, byteorder="little")
        b += self.ProtocolVersion.to_bytes(1, byteorder="little")

        return b

    @staticmethod
    def FromBytes(data):
        lcp_id = data[0]
        lcpSWVersion = float(data[1::4])
        return WLCPPowerUpHandshake(lcp_id, lcpSWVersion)

Classes

class OEM_LCP_ID (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
class OEM_LCP_ID(IntEnum):
    LCP_BASIC_INTELLIFLO = 1
    LCP_TEK = 0xFF

Ancestors

  • enum.IntEnum
  • builtins.int
  • enum.Enum

Class variables

var LCP_BASIC_INTELLIFLO
var LCP_TEK
class WLCPPowerUpHandshake (LCP_ID, LCP_SW_Version, ProtocolVersion=1)
Expand source code
class WLCPPowerUpHandshake:

    def __init__(self, LCP_ID, LCP_SW_Version, ProtocolVersion=0x01):
        self.ID = LCP_ID
        self.LCPVersion = LCP_SW_Version
        self.ProtocolVersion = ProtocolVersion

    def GetBytes(self):
        padding = 0x00
        b = self.ID.to_bytes(1, byteorder="little")
        LCPVersionMajor = int(floor(self.LCPVersion))
        b += LCPVersionMajor.to_bytes(2, byteorder="little")
        b += int((self.LCPVersion - LCPVersionMajor)
                 * 10_000).to_bytes(2, byteorder="big")
        b += padding.to_bytes(1, byteorder="little")
        b += padding.to_bytes(1, byteorder="little")
        b += self.ProtocolVersion.to_bytes(1, byteorder="little")

        return b

    @staticmethod
    def FromBytes(data):
        lcp_id = data[0]
        lcpSWVersion = float(data[1::4])
        return WLCPPowerUpHandshake(lcp_id, lcpSWVersion)

Static methods

def FromBytes(data)
Expand source code
@staticmethod
def FromBytes(data):
    lcp_id = data[0]
    lcpSWVersion = float(data[1::4])
    return WLCPPowerUpHandshake(lcp_id, lcpSWVersion)

Methods

def GetBytes(self)
Expand source code
def GetBytes(self):
    padding = 0x00
    b = self.ID.to_bytes(1, byteorder="little")
    LCPVersionMajor = int(floor(self.LCPVersion))
    b += LCPVersionMajor.to_bytes(2, byteorder="little")
    b += int((self.LCPVersion - LCPVersionMajor)
             * 10_000).to_bytes(2, byteorder="big")
    b += padding.to_bytes(1, byteorder="little")
    b += padding.to_bytes(1, byteorder="little")
    b += self.ProtocolVersion.to_bytes(1, byteorder="little")

    return b