本文整理汇总了Python中interface.Interface.send方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.send方法的具体用法?Python Interface.send怎么用?Python Interface.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.Interface
的用法示例。
在下文中一共展示了Interface.send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import send [as 别名]
def main(name):
sm = generate_map(name)
opcd = OPCD_Interface(sm['opcd_ctrl'])
platform = opcd.get('platform')
device = opcd.get(platform + '.nrf_serial')
global THIS_SYS_ID
THIS_SYS_ID = opcd.get('aircomm.id')
key = opcd.get('aircomm.psk')
crypt.init(key)
mhist = MessageHistory(60)
out_socket = sm['aircomm_out']
in_socket = sm['aircomm_in']
aci = Interface(device)
acr = ACIReader(aci, out_socket, mhist)
acr.start()
# read from SCL in socket and send data via NRF
while True:
data = loads(in_socket.recv())
if len(data) == 2:
msg = [data[0], THIS_SYS_ID, data[1]]
elif len(data) > 2:
msg = [data[0], THIS_SYS_ID] + data[1:]
else:
continue
crypt_data = crypt.encrypt(dumps(msg))
mhist.append(crypt_data)
aci.send(crypt_data)
示例2: Interface
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import send [as 别名]
import msgpack
from interface import Interface
from time import sleep
import serial
i = Interface('/dev/ttyACM0')
c = 0
while True:
mFlag = 0
mType = 'b'
senderID = 5
speed = 4.2
heading = 360
myMessage = msgpack.packb([mFlag,mType,senderID,speed,heading,c])
c += 1
i.send(myMessage)
sleep(0.1)