From 2c5a31b09e6abb4143df739c22c3827884904be3 Mon Sep 17 00:00:00 2001 From: Chris Liechti Date: Sat, 18 Jun 2016 22:57:24 +0200 Subject: doc: asyncio is now in a separate package --- documentation/pyserial_api.rst | 47 ++++++------------------------------------ 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst index 75e19e7..2aa8d21 100644 --- a/documentation/pyserial_api.rst +++ b/documentation/pyserial_api.rst @@ -1202,48 +1202,13 @@ Example:: asyncio ======= -.. module:: serial.aio +``asyncio`` was introduced with Python 3.4. Experimental support for pySerial +is provided via a separate distribution `pyserial-asyncio`_. -.. warning:: This implementation is currently in an experimental state. Use - at your own risk. - -Experimental asyncio support is available for Python 3.4 and newer. The module -:mod:`serial.aio` provides a :class:`asyncio.Transport`: -``SerialTransport``. - - -A factory function (`asyncio.coroutine`) is provided: - -.. function:: create_serial_connection(loop, protocol_factory, \*args, \*\*kwargs) - - :param loop: The event handler - :param protocol_factory: Factory function for a :class:`asyncio.Protocol` - :param args: Passed to the :class:`serial.Serial` init function - :param kwargs: Passed to the :class:`serial.Serial` init function - :platform: Posix +It is currently under developement, see: - Get a connection making coroutine. +- http://pyserial-asyncio.readthedocs.io/ +- https://github.com/pyserial/pyserial-asyncio -Example:: - - class Output(asyncio.Protocol): - def connection_made(self, transport): - self.transport = transport - print('port opened', transport) - transport.serial.rts = False - transport.write(b'hello world\n') - - def data_received(self, data): - print('data received', repr(data)) - self.transport.close() - - def connection_lost(self, exc): - print('port closed') - asyncio.get_event_loop().stop() - - loop = asyncio.get_event_loop() - coro = serial.aio.create_serial_connection(loop, Output, '/dev/ttyUSB0', baudrate=115200) - loop.run_until_complete(coro) - loop.run_forever() - loop.close() +.. _`pyserial-asyncio`: https://pypi.python.org/pypi/pyserial-asyncio -- cgit v1.2.1