def connect(port, baudrate, application, loop=None):
if loop is None:
loop = asyncio.get_event_loop()
connection_future = asyncio.Future()
protocol = Gateway(application, connection_future)
transport, protocol = yield from serial_asyncio.create_serial_connection(
loop,
lambda: protocol,
url=port,
baudrate=baudrate,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
xonxoff=True,
)
yield from connection_future
return protocol
评论列表
文章目录