当前位置: 首页>>代码示例>>Python>>正文


Python Packet.__init__方法代码示例

本文整理汇总了Python中Packet.Packet.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.__init__方法的具体用法?Python Packet.__init__怎么用?Python Packet.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet.Packet的用法示例。


在下文中一共展示了Packet.__init__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import __init__ [as 别名]
    def __init__(self, byteCodeId=None, comResp=None, parameter=None):
        
        if comResp != None:
            #super().__init__(b"\x55", b"\xAA", byteCodeId)
            Packet.__init__(self, b"\x55", b"\xAA", byteCodeId)
            self.__parameter = parameter
            self.__comResp = comResp
        else:

            length = len(byteCodeId)
            if length == 12:
                if byteCodeId[0]== b"\x55" and byteCodeId[1]== b"\xAA":
                    Packet.__init__(self, byteCodeId[0], byteCodeId[1], byteCodeId[2:4])
                    self.__parameter = byteCodeId[4:8]
                    self.__comResp = byteCodeId[8:10]
                    
                    #print("com1:", self.__commandCode0)
                    #print("com2:", self.__commandCode1)
                    #print("deviceId:", self.__deviceId)
                    #print("parameter:", self.__parameter)
                    #print("comResp:", self.__comResp)
                    #print("check:", receivedByteArray[10:12])
                    #print("checkCalc:",self.getCheckSum())

                    if self.getCheckSum(byteCodeId[0:length-2]) != byteCodeId[length-2:length]:
                        raise SensorException(CHECKSUM_ERROR, COMMAND_PACK_ERROR)
                else:
                    raise SensorException(PACKET_HEADER_ERROR, COMMAND_PACK_ERROR)
            else:
                raise SensorException(LENGTH_ERROR, COMMAND_PACK_ERROR) 
开发者ID:cypher9,项目名称:FingerprintManagement,代码行数:32,代码来源:CommandPacket.py

示例2: __init__

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import __init__ [as 别名]
 def __init__(self, byteCodeId=None, data=None):
     if data != None:
         Packet.__init__(self, b"\x5A", b"\xA5", byteCodeId)
         self.__data = data
     else:
         length = len(byteCodeId)
         if length >= 8:
             if byteCodeId[0]== b"\x5A" and byteCodeId[1]== b"\xA5":
                 Packet.__init__(self, byteCodeId[0], byteCodeId[1], byteCodeId[2:4])
                 self.__data = byteCodeId[4:length-2]
             
                 #print("com1:", self.__commandCode0)
                 #print("com2:", self.__commandCode1)
                 #print("Id:", self.__deviceId)
                 #print("rawData:", self.__data)
                 
                 #checkRec = bytearray(byteCode)[length-2] + bytearray(byteCode)[length-1]
                 #print("checkRec:", checkRec)
                 #print("checkRec:", receivedByteArray[length-2:length])
                 
                 #checkCalc = bytearray(super.getCheckSum())[0]+ bytearray(super.getCheckSum())[1]
                 #print("checkCalc:", checkCalc)
                 #print("checkCalc:", self.getCheckSum())
                 
                 #if self.getCheckSum() != receivedByteArray[length-1:length]:
                 #if checkRec != checkCalc:
                 if self.getCheckSum(byteCodeId[0:length-2]) != byteCodeId[length-2:length]:
                     raise SensorException(CHECKSUM_ERROR, DATA_PACK_ERROR)
             else:
                 raise SensorException(PACKET_HEADER_ERROR,DATA_PACK_ERROR)
         else:
             raise SensorException(LENGTH_ERROR, DATA_PACK_ERROR)
开发者ID:cypher9,项目名称:FingerprintManagement,代码行数:34,代码来源:DataPacket.py

示例3: __init__

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import __init__ [as 别名]
	def __init__(self,main, data):
		Packet.__init__(self, 06,data)
		self.main = main
开发者ID:Joby890,项目名称:LSV2,代码行数:5,代码来源:Packet06GetStripData.py

示例4: __init__

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import __init__ [as 别名]
 def __init__(self, *arguments, **kw):
     if len(arguments) == 0:
         Packet.__init__(self)
     else:
         Packet.__init__(self, self.VERSION, arguments[0], self.__class__._id, 0, *arguments[1:], **kw)
开发者ID:thousandparsec,项目名称:libtpproto2-py,代码行数:7,代码来源:Header.py

示例5: __init__

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import __init__ [as 别名]
	def __init__(self, main, data):
			Packet.__init__(self, 11, data)
			self.main = main
			self.data = data
开发者ID:Joby890,项目名称:LSV2,代码行数:6,代码来源:Packet11ChangeOptions.py


注:本文中的Packet.Packet.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。