diff options
author | Chris Liechti <cliechti@gmx.net> | 2016-06-18 22:57:24 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2016-06-18 22:57:24 +0200 |
commit | 2c5a31b09e6abb4143df739c22c3827884904be3 (patch) | |
tree | f2c952f2467cabd117309fc3b4805df7816a48b8 | |
parent | cd88ecb80acf2e5e966edaf5de57cedc058b7090 (diff) | |
download | pyserial-git-2c5a31b09e6abb4143df739c22c3827884904be3.tar.gz |
doc: asyncio is now in a separate package
-rw-r--r-- | documentation/pyserial_api.rst | 47 |
1 files 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 |