本文整理汇总了Python中Packet.Packet.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.getBytes方法的具体用法?Python Packet.getBytes怎么用?Python Packet.getBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet.Packet
的用法示例。
在下文中一共展示了Packet.getBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createAndSendPacket
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getBytes [as 别名]
def createAndSendPacket(destinationId,ttl,msgType,timestamp,payload):
p = Packet()
p.initialise(0,destinationId,ttl,msgType,timestamp,payload)
print "Creating and Sending: "
print p
global sendingSocket
sendingSocket.sendData(p.getBytes())
示例2: create_and_send_packet
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getBytes [as 别名]
def create_and_send_packet(destinationId,ttl,msgType,timestamp,payload):
global mesh_sending_socket
p = Packet()
p.initialise(0,destinationId,ttl,msgType,timestamp,payload)
print "Creating and Sending: " + str(p)
try:
mesh_sending_socket.sendData(p.getBytes())
print "sent"
except:
print "A connection error happened. Are you simulating the mesh?"
示例3: getInput
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getBytes [as 别名]
def getInput():
while True:
print "Enter old ID: "
oldId = sys.stdin.readline()
print "Enter new ID: "
newId = sys.stdin.readline()
'''if(data == 'quit'):
break
if(data == ''):
continue
'''
payload = PayloadIdentification()
payload.initialise(int(oldId),int(newId))
p = Packet()
p.initialise(0,0xFF,1,0,0,payload)
print p
global socketConnection
socketConnection.sendData(p.getBytes())
示例4: Packet
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getBytes [as 别名]
from Packet import Packet
from payload import *
p = Packet("\xff\x00\x01\x00\xff\xff\xde\xe9\x91\x4f\x01\xb5\x8a\x20\xff\x00\xff\x00\x70\x27\x00\x00\xde\xe9\x07\x27\x00\x00\x8a\x20\xff\x00")
print p
print p.getBytes().encode('hex_codec')