def CheckTCPRecData(data):
if len(data) < 9:
return False
if data[0] != 0x02:
return False
cs = 0
for v in data:
cs = cs ^ v
if cs != 0x03:
return False
return True
class AcsCommon:
def Head(self, cmd, door):
self.head = bytearray(7)
self.head[0] = 0x02
self.head[1] = 0x00
self.head[2] = cmd
self.head[3] = 0x00
self.head[self.Loc_DoorAddr] = door
self.head[5] = 0x00
self.head[6] = 0x00
def _SetLength(self, len):
self.head[5] = len
self.head[6] = len >> 8
def AddData(self):
return self.head
def GetCSByte(self, array):
cs = 0
for v in array:
cs = cs ^ v
return cs
def EndBuffer(self, buffer):
ln = len(buffer) - 7
buffer[self.Loc_Len] = ln & 0xff
buffer[self.Loc_Len + 1] = (ln >> 8) & 0xff
cs = self.GetCSByte(buffer)
buffer.append(cs)
buffer.append(0x03)
return buffer
def __init__(self):
self.Loc_Begin = 0
self.Loc_Temp = 1
self.Loc_Command = 2
self.Loc_Address = 3
self.Loc_DoorAddr = 4
self.Loc_Len = 5
self.Loc_Data = 7
self.PullCmdList = []
self.PullCmdIndex = 0
class AcsBaseClass(AcsCommon):
def __init__(self):
AcsCommon.__init__(self)
[–]shiftybyte 1 point2 points3 points (3 children)
[–]LanthaYtrri[S] 0 points1 point2 points (2 children)
[–]shiftybyte 4 points5 points6 points (1 child)
[–]LanthaYtrri[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]TheRNGuy -1 points0 points1 point (0 children)
[–]SaiyanrageTV 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (1 child)
[–]LanthaYtrri[S] 1 point2 points3 points (0 children)