async def connect_serial(address) -> Connection: LOGGER.info(f'Connecting over Serial to {address}') protocol = FileSenderProtocol() ser = serial.serial_for_url(address, baudrate=YMODEM_TRANSFER_BAUD_RATE) transport = SerialTransport(asyncio.get_event_loop(), protocol, ser) transport.serial.rts = False transport.set_write_buffer_limits( high=255) # receiver RX buffer is 256, so limit send buffer to 255 conn = Connection(address, transport, protocol) await conn.protocol.connected return conn
async def connect_serial(app: web.Application, factory: ProtocolFactory_ ) -> Awaitable[ConnectionResult_]: config = app['config'] port = config['device_serial'] id = config['device_id'] address = detect_device(port, id) protocol = factory() ser = serial.serial_for_url(address, baudrate=DEFAULT_BAUD_RATE) loop = asyncio.get_event_loop() transport = SerialTransport(loop, protocol, ser) transport.serial.rts = False transport.set_write_buffer_limits(high=255) # receiver RX buffer is 256, so limit send buffer to 255 return address, transport, protocol