Commit 862d7c0f authored by Martin's avatar Martin

import upstream version 0.4

parents
# (C) 2016 Chris Liechti <cliechti@gmx.net>
# SPDX-License-Identifier: BSD-3-Clause
language: python
python:
- 3.4
- 3.5
- 3.6
install:
- pip install -r requirements-travis.txt
- pip install -e .
script:
- python test/test_asyncio.py
=========
Credits
=========
Main authors of pySerial-asyncio
================================
- Chris Liechti (zsquareplusc)
- Robert Smallshire (rob-smallshire)
Contributors
============
- David Ko
- Nicolas Di Pietro
- jabdoa2
- Chris Seymour
- ... not all names may be listed here, see also ``git log`` or online history_
.. _history: https://github.com/pyserial/pyserial-asyncio/commits/master
Copyright (c) 2015-2017 pySerial-team (see CREDITS.rst)
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
Note:
Individual files contain the following tag instead of the full license text.
SPDX-License-Identifier: BSD-3-Clause
This enables machine processing of license information based on the SPDX
License Identifiers that are here available: http://spdx.org/licenses/
include CREDITS.rst
include LICENSE.txt
include README.rst
include MANIFEST.in
include requirements.txt
include setup.cfg
include documentation/*.rst
include documentation/conf.py
include documentation/Makefile
include documentation/pyserial-asyncio.png
include test/__init__.py
include test/test_asyncio.py
Metadata-Version: 1.1
Name: pyserial-asyncio
Version: 0.4
Summary: Python Serial Port Extension - Asynchronous I/O support
Home-page: https://github.com/pyserial/pyserial-asyncio
Author: pySerial-team
Author-email: UNKNOWN
License: BSD
Description: Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
- Documentation: http://pyserial-asyncio.readthedocs.io
- Project Homepage: https://github.com/pyserial/pyserial-asyncio
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Communications
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Terminals :: Serial
========================================
pyserial-asyncio |build-status| |docs|
========================================
Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
It depends on pySerial and is compatible with Python 3.4 and later.
Documentation
=============
- Documentation: http://pyserial-asyncio.readthedocs.io/en/latest/
- Download Page: https://pypi.python.org/pypi/pyserial-asyncio
- Project Homepage: https://github.com/pyserial/pyserial-asyncio
.. |build-status| image:: https://travis-ci.org/pyserial/pyserial-asyncio.svg?branch=master
:target: https://travis-ci.org/pyserial/pyserial-asyncio
:alt: Build status
.. |docs| image:: https://readthedocs.org/projects/pyserial-asyncio/badge/?version=latest
:target: http://pyserial-asyncio.readthedocs.io/
:alt: Documentation
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf _build/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@echo
@echo "Build finished. The HTML pages are in _build/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
@echo
@echo "Build finished. The HTML pages are in _build/dirhtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in _build/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in _build/qthelp, like this:"
@echo "# qcollectiongenerator _build/qthelp/pySerial.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile _build/qthelp/pySerial.qhc"
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
@echo
@echo "Build finished; the LaTeX files are in _build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
@echo
@echo "The overview file is in _build/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in _build/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in _build/doctest/output.txt."
======================
pySerial-asyncio API
======================
asyncio
=======
.. module:: serial.aio
.. 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
Get a connection making coroutine.
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()
==========
Appendix
==========
License
=======
Copyright (c) 2015-2016 pySerial-team (see CREDITS.rst)
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -*- coding: utf-8 -*-
#
# pySerial-asyncio documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 21 00:27:45 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'pySerial-asyncio'
copyright = u'2015-2016, pySerial-team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.3'
# The full version, including alpha/beta/rc tags.
release = '0.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
#html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'pyserial-asyncio.png'
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
#htmlhelp_basename = 'pySerial-asyncio-doc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'pySerial-asyncio.tex', u'pySerial-asyncio Documentation',
u'pySerial-team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = 'pyserial-asyncio.png'
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
# for external links to standard library
intersphinx_mapping = {
#~ 'python': ('http://docs.python.org', None),
'py': ('http://docs.python.org', None),
}
.. pySerial-asyncio documentation master file
Welcome to pySerial-asyncio's documentation
===========================================
`Async I/O`_ extension for the `Python Serial Port`_ package for OSX, Linux, BSD
It depends on pySerial and is compatible with Python 3.4 and later.
.. _`Async I/O`: https://www.python.org/dev/peps/pep-3156/
.. _`Python Serial Port`: https://pypi.python.org/pypi/pyserial
Other pages (online)
- `project page on GitHub`_
- `Download Page`_ with releases
- This page, when viewed online is at https://pyserial-asyncio.readthedocs.io/en/latest/ or
http://pythonhosted.org/pyserial-asyncio/ .
.. _Python: http://python.org/
.. _`project page on GitHub`: https://github.com/pyserial/pyserial-asyncio/
.. _`Download Page`: http://pypi.python.org/pypi/pyserial-asyncio
Contents:
.. toctree::
:maxdepth: 2
shortintro
api
appendix
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
==================
Short introduction
==================
Example::
class Output(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
print('port opened', transport)
transport.serial.rts = False # You can manipulate Serial object via transport
transport.write(b'Hello, World!\n') # Write serial data via transport
def data_received(self, data):
print('data received', repr(data))
if b'\n' in data:
self.transport.close()
def connection_lost(self, exc):
print('port closed')
self.transport.loop.stop()
def pause_writing(self):
print('pause writing')
print(self.transport.get_write_buffer_size())
def resume_writing(self):
print(self.transport.get_write_buffer_size())
print('resume writing')
loop = asyncio.get_event_loop()
coro = create_serial_connection(loop, Output, '/dev/ttyUSB0', baudrate=115200)
loop.run_until_complete(coro)
loop.run_forever()
loop.close()
Metadata-Version: 1.1
Name: pyserial-asyncio
Version: 0.4
Summary: Python Serial Port Extension - Asynchronous I/O support
Home-page: https://github.com/pyserial/pyserial-asyncio
Author: pySerial-team
Author-email: UNKNOWN
License: BSD
Description: Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
- Documentation: http://pyserial-asyncio.readthedocs.io
- Project Homepage: https://github.com/pyserial/pyserial-asyncio
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Communications
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Terminals :: Serial
.travis.yml
CREDITS.rst
LICENSE.txt
MANIFEST.in
README.rst
requirements.txt
setup.cfg
setup.py
documentation/Makefile
documentation/api.rst
documentation/appendix.rst
documentation/conf.py
documentation/index.rst
documentation/pyserial-asyncio.png
documentation/shortintro.rst
pyserial_asyncio.egg-info/PKG-INFO
pyserial_asyncio.egg-info/SOURCES.txt
pyserial_asyncio.egg-info/dependency_links.txt
pyserial_asyncio.egg-info/requires.txt
pyserial_asyncio.egg-info/top_level.txt
serial_asyncio/__init__.py
test/__init__.py
test/test_asyncio.py
\ No newline at end of file
This diff is collapsed.
[flake8]
max-line-length = 120
ignore = E265, E126, E241
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
# setup.py for pySerial-asyncio
#
# For Python 3.x use the corresponding Python executable,
# e.g. "python3 setup.py ..."
#
# (C) 2015-2016 Chris Liechti <cliechti@gmx.net>
#
# SPDX-License-Identifier: BSD-3-Clause
import io
import os
import re
import sys
if sys.version_info < (3, 4):
raise RuntimeError("pyserial-asyncio requires at least Python 3.4")
from setuptools import setup
def read(*names, **kwargs):
"""Python 2 and Python 3 compatible text file reading.
Required for single-sourcing the version string.
"""
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")
) as fp:
return fp.read()
def find_version(*file_paths):
"""
Search the file for a version string.
file_path contain string path components.
Reads the supplied Python module as text without importing it.
"""
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
version = find_version('serial_asyncio', '__init__.py')
setup(
name="pyserial-asyncio",
description="Python Serial Port Extension - Asynchronous I/O support",
version=version,
author="pySerial-team",
url="https://github.com/pyserial/pyserial-asyncio",
packages=['serial_asyncio'],
install_requires=[
'pyserial',
],
license="BSD",
long_description="""\
Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
- Documentation: http://pyserial-asyncio.readthedocs.io
- Project Homepage: https://github.com/pyserial/pyserial-asyncio
""",
classifiers=[
#~ 'Development Status :: 5 - Production/Stable',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: POSIX',
'Operating System :: MacOS :: MacOS X',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Communications',