Ben Bass avatar Ben Bass committed 0b31119

re-arrange tests & docs; bump to 0.10pre

Comments (0)

Files changed (42)

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+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 "  singlehtml to make a single large HTML file"
+	@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 "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@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 $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pylibftdi.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pylibftdi.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/pylibftdi"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pylibftdi"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."

doc/bit_server.rst

+bit_server Module
+=================
+
+.. automodule:: bit_server
+    :members:
+    :undoc-members:
+    :show-inheritance:
+# -*- coding: utf-8 -*-
+#
+# pylibftdi documentation build configuration file, created by
+# sphinx-quickstart on Mon Oct 31 22:36:38 2011.
+#
+# 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
+import 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.insert(0, os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath('..'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# 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.autodoc', 'sphinx.ext.viewcode']
+
+# 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-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'pylibftdi'
+copyright = u'2010-2012, Ben Bass'
+
+# 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.9'
+# The full version, including alpha/beta/rc tags.
+release = '0.9'
+
+# 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 patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_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.  See the documentation for
+# a list of builtin themes.
+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 = None
+
+# 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_domain_indices = 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, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = 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 = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'pylibftdidoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'pylibftdi.tex', u'pylibftdi Documentation',
+   u'Ben Bass', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'pylibftdi', u'pylibftdi Documentation',
+     [u'Ben Bass'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'pylibftdi', u'pylibftdi Documentation', u'Ben Bass',
+   'pylibftdi', 'One line description of project.', 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+.. pylibftdi documentation master file, created by
+   sphinx-quickstart on Mon Oct 31 22:36:38 2011.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to pylibftdi's documentation!
+=====================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   introduction
+   tutorial
+   pylibftdi
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

doc/installation.rst

+Installation
+============
+
+
+
+Windows
+------
+
+libftdi
+
+Mac OS X
+--------
+
+See codedstructure.net/pylibftdi/...
+
+Linux
+-----
+
+Debian - 0.19-3 libftdi1
+

doc/introduction.rst

+Introduction
+============
+
+pylibftdi is a minimal Pythonic interface to FTDI devices using libftdi_.
+
+.. _libftdi: http://www.intra2net.com/en/developer/libftdi/
+
+:Features:
+
+ - Supports Python 2 and Python 3
+ - Supports parallel and serial devices
+ - Support for multiple devices
+ - File-like interface wherever appropriate
+ - Cross-platform
+
+:Limitations:
+
+ - Currently only one port per device is used; I've not tested with dual
+   port devices yet.
+ - The API might change prior to reaching a 1.0 release.
+
+Usage
+-----
+
+The primary interface is the ``Device`` class in the pylibftdi package; this
+gives serial access on relevant FTDI devices (e.g. the UM232R), providing a
+file-like interface (read, write).  Baudrate is controlled with the ``baudrate``
+property.
+
+If a Device instance is created with ``mode='t'`` (text mode) then read() and
+write() can use the given ``encoding`` (defaulting to latin-1). This doesn't
+make a lot of difference on Python 2 (and can be omitted), but allows easier
+integration with passing unicode strings between devices in Python 3.
+
+Multiple devices are supported by passing the desired device serial number (as
+a string) in the ``device_id`` parameter - this is the first parameter in both
+Device() and BitBangDevice() constructors. Alternatively the device 'description'
+can be given, and an attempt will be made to match this if matching by serial
+number fails.
+
+History & Motivation
+--------------------
+This package is the result of various bits of work using FTDI's
+devices, primarily for controlling external devices.  Some of this
+is documented on the codedstructure blog, codedstructure.blogspot.com
+
+At least two other open-source Python FTDI wrappers exist, and each
+of these may be best for some projects.
+
+ * ftd2xx_ - ctypes binding to FTDI's own D2XX driver
+ * pyftdi_ - a C extension libftdi binding
+
+.. _ftd2xx: http://pypi.python.org/pypi/ftd2xx
+.. _pyftdi: http://git.marcansoft.com/?p=pyftdi.git
+
+pylibftdi exists in the gap between these two projects; ftd2xx uses
+the (closed-source) D2XX driver, but provides a high-level Python
+interface, while pyftdi works with libftdi but is very low-level.
+The aim for pylibftdi is to work with the libftdi, but to provide
+a high-level Pythonic interface.  Various wrappers and utility
+functions are also part of the distribution; following Python's
+batteries included approach, there are various interesting devices
+supported out-of-the-box - or at least there will be soon!
+
+Plans
+-----
+ * Add more examples: SPI devices, knight-rider effects, input devices, MIDI...
+ * Perhaps add support for D2XX driver, though the name then becomes a
+   slight liability ;)
+    * - support multiple backends; D2XX, libftdi, python-ftdi (if you really wanted?)...
+ * General code quality improvements: solid unit tests, decent documentation.
+
+License
+-------
+
+Copyright (c) 2010-2012 Ben Bass <benbass@codedstructure.net>
+
+pylibftdi is released under the MIT licence; see the file "LICENSE.txt"
+for information.
+
+All trademarks referenced herein are property of their respective
+holders.
+libFTDI itself is developed by Intra2net AG.  No association with
+Intra2net is claimed or implied, but I have found their library
+helpful and had fun with it...
+
+lcd Module
+==========
+
+.. automodule:: lcd
+    :members:
+    :undoc-members:
+    :show-inheritance:

doc/led_flash.rst

+led_flash Module
+================
+
+.. automodule:: led_flash
+    :members:
+    :undoc-members:
+    :show-inheritance:

doc/list_devices.rst

+list_devices Module
+===================
+
+.. automodule:: list_devices
+    :members:
+    :undoc-members:
+    :show-inheritance:
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	: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.  singlehtml to make a single large HTML file
+	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.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over 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
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pylibftdi.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pylibftdi.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end
+pylibftdi
+=========
+
+.. toctree::
+   :maxdepth: 4
+
+   pylibftdi

doc/pylibftdi.examples.rst

+examples Package
+================
+
+:mod:`examples` Package
+-----------------------
+
+.. automodule:: pylibftdi.examples
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`bit_server` Module
+------------------------
+
+.. automodule:: pylibftdi.examples.bit_server
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`lcd` Module
+-----------------
+
+.. automodule:: pylibftdi.examples.lcd
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`led_flash` Module
+-----------------------
+
+.. automodule:: pylibftdi.examples.led_flash
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`list_devices` Module
+--------------------------
+
+.. automodule:: pylibftdi.examples.list_devices
+    :members:
+    :undoc-members:
+    :show-inheritance:
+

doc/pylibftdi.rst

+pylibftdi Package
+=================
+
+:mod:`pylibftdi` Package
+------------------------
+
+.. automodule:: pylibftdi.__init__
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`_base` Module
+-------------------
+
+.. automodule:: pylibftdi._base
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`bitbang` Module
+---------------------
+
+.. automodule:: pylibftdi.bitbang
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`driver` Module
+--------------------
+
+.. automodule:: pylibftdi.driver
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`test_bitbang` Module
+--------------------------
+
+.. automodule:: pylibftdi.test_bitbang
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`test_common` Module
+-------------------------
+
+.. automodule:: pylibftdi.test_common
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`test_driver` Module
+-------------------------
+
+.. automodule:: pylibftdi.test_driver
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+:mod:`util` Module
+------------------
+
+.. automodule:: pylibftdi.util
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+    pylibftdi.examples
+
+Tutorial
+========
+
+pylibftdi is a minimal Pythonic interface to FTDI devices using libftdi_.
+
+.. _libftdi: http://www.intra2net.com/en/developer/libftdi/
+
+Usage
+-----
+
+The primary interface is the ``Device`` class in the pylibftdi package; this
+gives serial access on relevant FTDI devices (e.g. the UM232R), providing a
+file-like interface (read, write).  Baudrate is controlled with the ``baudrate``
+property.
+
+If a Device instance is created with ``mode='t'`` (text mode) then read() and
+write() can use the given ``encoding`` (defaulting to latin-1). This doesn't
+make a lot of difference on Python 2 (and can be omitted), but allows easier
+integration with passing unicode strings between devices in Python 3.
+
+Multiple devices are supported by passing the desired device serial number (as
+a string) in the ``device_id`` parameter - this is the first parameter in both
+Device() and BitBangDevice() constructors. Alternatively the device 'description'
+can be given, and an attempt will be made to match this if matching by serial
+number fails.
+
+Examples
+~~~~~~~~
+
+::
+
+    >>> from pylibftdi import Device
+    >>>
+    >>> with Device(mode='t') as dev:
+    ...     dev.baudrate = 115200
+    ...     dev.write('Hello World')
+
+The pylibftdi.BitBangDevice wrapper provides access to the parallel IO mode of
+operation through the ``port`` and ``direction`` properties.  These provide an
+8 bit IO port including all the relevant bit operations to make things simple.
+
+::
+
+    >>> from pylibftdi import BitBangDevice
+    >>>
+    >>> with BitBangDevice('FTE00P4L') as bb:
+    ...     bb.direction = 0x0F  # four LSB are output(1), four MSB are input(0)
+    ...     bb.port |= 2         # set bit 1
+    ...     bb.port &= 0xFE      # clear bit 0
+
+There is support for a number of external devices and protocols, specifically
+for interfacing with HD44780 LCDs using the 4-bit interface.
+

docs/Makefile

-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
-PAPER         =
-BUILDDIR      = _build
-
-# Internal variables.
-PAPEROPT_a4     = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
-
-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 "  singlehtml to make a single large HTML file"
-	@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 "  devhelp    to make HTML files and a Devhelp project"
-	@echo "  epub       to make an epub"
-	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-	@echo "  text       to make text files"
-	@echo "  man        to make manual pages"
-	@echo "  texinfo    to make Texinfo files"
-	@echo "  info       to make Texinfo files and run them through makeinfo"
-	@echo "  gettext    to make PO message catalogs"
-	@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 $(BUILDDIR)/*
-
-html:
-	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
-	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
-	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
-	@echo
-	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
-	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-	@echo
-	@echo "Build finished; now you can process the pickle files."
-
-json:
-	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-	@echo
-	@echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
-	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-	@echo
-	@echo "Build finished; now you can run HTML Help Workshop with the" \
-	      ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
-	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-	@echo
-	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
-	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pylibftdi.qhcp"
-	@echo "To view the help file:"
-	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pylibftdi.qhc"
-
-devhelp:
-	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
-	@echo
-	@echo "Build finished."
-	@echo "To view the help file:"
-	@echo "# mkdir -p $$HOME/.local/share/devhelp/pylibftdi"
-	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pylibftdi"
-	@echo "# devhelp"
-
-epub:
-	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
-	@echo
-	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo
-	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-	@echo "Run \`make' in that directory to run these through (pdf)latex" \
-	      "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo "Running LaTeX files through pdflatex..."
-	$(MAKE) -C $(BUILDDIR)/latex all-pdf
-	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
-	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
-	@echo
-	@echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
-	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
-	@echo
-	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
-	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-	@echo
-	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
-	@echo "Run \`make' in that directory to run these through makeinfo" \
-	      "(use \`make info' here to do that automatically)."
-
-info:
-	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-	@echo "Running Texinfo files through makeinfo..."
-	make -C $(BUILDDIR)/texinfo info
-	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
-
-gettext:
-	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
-	@echo
-	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-changes:
-	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
-	@echo
-	@echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
-	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
-	@echo
-	@echo "Link check complete; look for any errors in the above output " \
-	      "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
-	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
-	@echo "Testing of doctests in the sources finished, look at the " \
-	      "results in $(BUILDDIR)/doctest/output.txt."

docs/bit_server.rst

-bit_server Module
-=================
-
-.. automodule:: bit_server
-    :members:
-    :undoc-members:
-    :show-inheritance:

docs/conf.py

-# -*- coding: utf-8 -*-
-#
-# pylibftdi documentation build configuration file, created by
-# sphinx-quickstart on Mon Oct 31 22:36:38 2011.
-#
-# 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
-import 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.insert(0, os.path.abspath('.'))
-sys.path.insert(0, os.path.abspath('..'))
-
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# 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.autodoc', 'sphinx.ext.viewcode']
-
-# 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-sig'
-
-# The master toctree document.
-master_doc = 'index'
-
-# General information about the project.
-project = u'pylibftdi'
-copyright = u'2010-2012, Ben Bass'
-
-# 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.9'
-# The full version, including alpha/beta/rc tags.
-release = '0.9'
-
-# 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 patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = ['_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.  See the documentation for
-# a list of builtin themes.
-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 = None
-
-# 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_domain_indices = 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, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = 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 = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'pylibftdidoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
-}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
-  ('index', 'pylibftdi.tex', u'pylibftdi Documentation',
-   u'Ben Bass', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    ('index', 'pylibftdi', u'pylibftdi Documentation',
-     [u'Ben Bass'], 1)
-]
-
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-
-# -- Options for Texinfo output ------------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-#  dir menu entry, description, category)
-texinfo_documents = [
-  ('index', 'pylibftdi', u'pylibftdi Documentation', u'Ben Bass',
-   'pylibftdi', 'One line description of project.', 'Miscellaneous'),
-]
-
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'

docs/index.rst

-.. pylibftdi documentation master file, created by
-   sphinx-quickstart on Mon Oct 31 22:36:38 2011.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
-Welcome to pylibftdi's documentation!
-=====================================
-
-Contents:
-
-.. toctree::
-   :maxdepth: 2
-
-   introduction
-   tutorial
-   pylibftdi
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
-

docs/introduction.rst

-Introduction
-============
-
-pylibftdi is a minimal Pythonic interface to FTDI devices using libftdi_.
-
-.. _libftdi: http://www.intra2net.com/en/developer/libftdi/
-
-:Features:
-
- - Supports Python 2 and Python 3
- - Supports parallel and serial devices
- - Support for multiple devices
- - File-like interface wherever appropriate
- - Cross-platform
-
-:Limitations:
-
- - Currently only one port per device is used; I've not tested with dual
-   port devices yet.
- - The API might change prior to reaching a 1.0 release.
-
-Usage
------
-
-The primary interface is the ``Device`` class in the pylibftdi package; this
-gives serial access on relevant FTDI devices (e.g. the UM232R), providing a
-file-like interface (read, write).  Baudrate is controlled with the ``baudrate``
-property.
-
-If a Device instance is created with ``mode='t'`` (text mode) then read() and
-write() can use the given ``encoding`` (defaulting to latin-1). This doesn't
-make a lot of difference on Python 2 (and can be omitted), but allows easier
-integration with passing unicode strings between devices in Python 3.
-
-Multiple devices are supported by passing the desired device serial number (as
-a string) in the ``device_id`` parameter - this is the first parameter in both
-Device() and BitBangDevice() constructors. Alternatively the device 'description'
-can be given, and an attempt will be made to match this if matching by serial
-number fails.
-
-History & Motivation
---------------------
-This package is the result of various bits of work using FTDI's
-devices, primarily for controlling external devices.  Some of this
-is documented on the codedstructure blog, codedstructure.blogspot.com
-
-At least two other open-source Python FTDI wrappers exist, and each
-of these may be best for some projects.
-
- * ftd2xx_ - ctypes binding to FTDI's own D2XX driver
- * pyftdi_ - a C extension libftdi binding
-
-.. _ftd2xx: http://pypi.python.org/pypi/ftd2xx
-.. _pyftdi: http://git.marcansoft.com/?p=pyftdi.git
-
-pylibftdi exists in the gap between these two projects; ftd2xx uses
-the (closed-source) D2XX driver, but provides a high-level Python
-interface, while pyftdi works with libftdi but is very low-level.
-The aim for pylibftdi is to work with the libftdi, but to provide
-a high-level Pythonic interface.  Various wrappers and utility
-functions are also part of the distribution; following Python's
-batteries included approach, there are various interesting devices
-supported out-of-the-box - or at least there will be soon!
-
-Plans
------
- * Add more examples: SPI devices, knight-rider effects, input devices, MIDI...
- * Perhaps add support for D2XX driver, though the name then becomes a
-   slight liability ;)
- * General code quality improvements: solid unit tests, decent documentation.
-
-License
--------
-
-Copyright (c) 2010-2012 Ben Bass <benbass@codedstructure.net>
-
-pylibftdi is released under the MIT licence; see the file "LICENSE.txt"
-for information.
-
-All trademarks referenced herein are property of their respective
-holders.
-libFTDI itself is developed by Intra2net AG.  No association with
-Intra2net is claimed or implied, but I have found their library
-helpful and had fun with it...
-

docs/lcd.rst

-lcd Module
-==========
-
-.. automodule:: lcd
-    :members:
-    :undoc-members:
-    :show-inheritance:

docs/led_flash.rst

-led_flash Module
-================
-
-.. automodule:: led_flash
-    :members:
-    :undoc-members:
-    :show-inheritance:

docs/list_devices.rst

-list_devices Module
-===================
-
-.. automodule:: list_devices
-    :members:
-    :undoc-members:
-    :show-inheritance:

docs/make.bat

-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%SPHINXBUILD%" == "" (
-	set SPHINXBUILD=sphinx-build
-)
-set BUILDDIR=_build
-set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
-set I18NSPHINXOPTS=%SPHINXOPTS% .
-if NOT "%PAPER%" == "" (
-	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
-	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
-)
-
-if "%1" == "" goto help
-
-if "%1" == "help" (
-	: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.  singlehtml to make a single large HTML file
-	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.  devhelp    to make HTML files and a Devhelp project
-	echo.  epub       to make an epub
-	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
-	echo.  text       to make text files
-	echo.  man        to make manual pages
-	echo.  texinfo    to make Texinfo files
-	echo.  gettext    to make PO message catalogs
-	echo.  changes    to make an overview over 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
-	goto end
-)
-
-if "%1" == "clean" (
-	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
-	del /q /s %BUILDDIR%\*
-	goto end
-)
-
-if "%1" == "html" (
-	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
-	goto end
-)
-
-if "%1" == "dirhtml" (
-	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
-	goto end
-)
-
-if "%1" == "singlehtml" (
-	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
-	goto end
-)
-
-if "%1" == "pickle" (
-	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can process the pickle files.
-	goto end
-)
-
-if "%1" == "json" (
-	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can process the JSON files.
-	goto end
-)
-
-if "%1" == "htmlhelp" (
-	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can run HTML Help Workshop with the ^
-.hhp project file in %BUILDDIR%/htmlhelp.
-	goto end
-)
-
-if "%1" == "qthelp" (
-	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can run "qcollectiongenerator" with the ^
-.qhcp project file in %BUILDDIR%/qthelp, like this:
-	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pylibftdi.qhcp
-	echo.To view the help file:
-	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pylibftdi.ghc
-	goto end
-)
-
-if "%1" == "devhelp" (
-	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished.
-	goto end
-)
-
-if "%1" == "epub" (
-	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The epub file is in %BUILDDIR%/epub.
-	goto end
-)
-
-if "%1" == "latex" (
-	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
-	goto end
-)
-
-if "%1" == "text" (
-	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The text files are in %BUILDDIR%/text.
-	goto end
-)
-
-if "%1" == "man" (
-	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The manual pages are in %BUILDDIR%/man.
-	goto end
-)
-
-if "%1" == "texinfo" (
-	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
-	goto end
-)
-
-if "%1" == "gettext" (
-	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
-	goto end
-)
-
-if "%1" == "changes" (
-	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.The overview file is in %BUILDDIR%/changes.
-	goto end
-)
-
-if "%1" == "linkcheck" (
-	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Link check complete; look for any errors in the above output ^
-or in %BUILDDIR%/linkcheck/output.txt.
-	goto end
-)
-
-if "%1" == "doctest" (
-	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Testing of doctests in the sources finished, look at the ^
-results in %BUILDDIR%/doctest/output.txt.
-	goto end
-)
-
-:end

docs/modules.rst

-pylibftdi
-=========
-
-.. toctree::
-   :maxdepth: 4
-
-   pylibftdi

docs/pylibftdi.examples.rst

-examples Package
-================
-
-:mod:`examples` Package
------------------------
-
-.. automodule:: pylibftdi.examples
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`bit_server` Module
-------------------------
-
-.. automodule:: pylibftdi.examples.bit_server
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`lcd` Module
------------------
-
-.. automodule:: pylibftdi.examples.lcd
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`led_flash` Module
------------------------
-
-.. automodule:: pylibftdi.examples.led_flash
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`list_devices` Module
---------------------------
-
-.. automodule:: pylibftdi.examples.list_devices
-    :members:
-    :undoc-members:
-    :show-inheritance:
-

docs/pylibftdi.rst

-pylibftdi Package
-=================
-
-:mod:`pylibftdi` Package
-------------------------
-
-.. automodule:: pylibftdi.__init__
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`_base` Module
--------------------
-
-.. automodule:: pylibftdi._base
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`bitbang` Module
----------------------
-
-.. automodule:: pylibftdi.bitbang
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`driver` Module
---------------------
-
-.. automodule:: pylibftdi.driver
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`test_bitbang` Module
---------------------------
-
-.. automodule:: pylibftdi.test_bitbang
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`test_common` Module
--------------------------
-
-.. automodule:: pylibftdi.test_common
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`test_driver` Module
--------------------------
-
-.. automodule:: pylibftdi.test_driver
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`util` Module
-------------------
-
-.. automodule:: pylibftdi.util
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-Subpackages
------------
-
-.. toctree::
-
-    pylibftdi.examples
-

docs/tutorial.rst

-Tutorial
-========
-
-pylibftdi is a minimal Pythonic interface to FTDI devices using libftdi_.
-
-.. _libftdi: http://www.intra2net.com/en/developer/libftdi/
-
-Usage
------
-
-The primary interface is the ``Device`` class in the pylibftdi package; this
-gives serial access on relevant FTDI devices (e.g. the UM232R), providing a
-file-like interface (read, write).  Baudrate is controlled with the ``baudrate``
-property.
-
-If a Device instance is created with ``mode='t'`` (text mode) then read() and
-write() can use the given ``encoding`` (defaulting to latin-1). This doesn't
-make a lot of difference on Python 2 (and can be omitted), but allows easier
-integration with passing unicode strings between devices in Python 3.
-
-Multiple devices are supported by passing the desired device serial number (as
-a string) in the ``device_id`` parameter - this is the first parameter in both
-Device() and BitBangDevice() constructors. Alternatively the device 'description'
-can be given, and an attempt will be made to match this if matching by serial
-number fails.
-
-Examples
-~~~~~~~~
-
-::
-
-    >>> from pylibftdi import Device
-    >>>
-    >>> with Device(mode='t') as dev:
-    ...     dev.baudrate = 115200
-    ...     dev.write('Hello World')
-
-The pylibftdi.BitBangDevice wrapper provides access to the parallel IO mode of
-operation through the ``port`` and ``direction`` properties.  These provide an
-8 bit IO port including all the relevant bit operations to make things simple.
-
-::
-
-    >>> from pylibftdi import BitBangDevice
-    >>>
-    >>> with BitBangDevice('FTE00P4L') as bb:
-    ...     bb.direction = 0x0F  # four LSB are output(1), four MSB are input(0)
-    ...     bb.port |= 2         # set bit 1
-    ...     bb.port &= 0xFE      # clear bit 0
-
-There is support for a number of external devices and protocols, specifically
-for interfacing with HD44780 LCDs using the 4-bit interface.
-

pylibftdi/__init__.py

 rather than a problem with the libftdi library.
 """
 
-__VERSION__ = "0.9"
+__VERSION__ = "0.10pre"
 __AUTHOR__ = "Ben Bass"
 
 
 FLUSH_BOTH = driver.FLUSH_BOTH
 FLUSH_INPUT = driver.FLUSH_INPUT
 FLUSH_OUTPUT = driver.FLUSH_OUTPUT
-
-# LEGACY SUPPORT
-
-
-class BitBangDriver(bitbang.BitBangDevice):
-    def __init__(self, direction=ALL_OUTPUTS):
-        import warnings
-        warnings.warn('change BitBangDriver reference to BitBangDevice',
-                      DeprecationWarning)
-        return BitBangDevice.__init__(self, direction=direction, lazy_open=True)

pylibftdi/tests/__init__.py

-"""tests for pylibftdi"""

pylibftdi/tests/test_all.py

-
-#from pylibftdi.tests.test_common import unittest
-#from pylibftdi.tests import test_bitbang, test_driver
-
-#unittest.main()

pylibftdi/tests/test_bitbang.py

-"""
-pylibftdi - python wrapper for libftdi
-
-Copyright (c) 2010-2012 Ben Bass <benbass@codedstructure.net>
-See LICENSE file for details and (absence of) warranty
-
-pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
-
-This module contains some basic tests for the higher-level
-functionality without requiring an actual hardware device
-to be attached.
-"""
-
-from pylibftdi.tests.test_common import (LoopDevice, CallCheckMixin, unittest)
-from pylibftdi.bitbang import BitBangDevice
-from pylibftdi import FtdiError
-
-
-class TestBitBangDevice(BitBangDevice, LoopDevice):
-    pass
-
-BitBangDevice = TestBitBangDevice
-
-
-# and now some test cases...
-class BitBangFunctions(CallCheckMixin, unittest.TestCase):
-
-    def testContextManager(self):
-        def _():
-            with BitBangDevice():
-                pass
-        self.assertCallsExact(_,
-                ['ftdi_init', 'ftdi_usb_open',
-                 'ftdi_set_bitmode',
-                 'ftdi_usb_close', 'ftdi_deinit'])
-
-    def testOpen(self):
-        """
-        check same opening things as a normal Device still work
-        for BitBangDevice
-        """
-        # a lazy_open open() shouldn't do anything
-        self.assertCallsExact(lambda: BitBangDevice(lazy_open=True), [])
-        # a non-lazy_open open() should open the port...
-        self.assertCalls(lambda: BitBangDevice(), 'ftdi_usb_open')
-        # and set the bit mode
-        self.assertCalls(lambda: BitBangDevice(), 'ftdi_set_bitmode')
-        # and given a device_id, it should do a open_desc
-        self.assertCalls(lambda: BitBangDevice('bogus'), 'ftdi_usb_open_desc')
-
-    def testInitDirection(self):
-        # check that a direction can be given on open and is honoured
-        for dir_test in (0, 1, 4, 12, 120, 255):
-
-            dev = BitBangDevice(direction=dir_test)
-            self.assertEqual(dev.direction, dir_test)
-            self.assertEqual(dev._direction, dir_test)
-            self.assertEqual(dev._last_set_dir, dir_test)
-        # check an invalid direction on open gives error
-        self.assertRaises(FtdiError, lambda: BitBangDevice(direction=300))
-
-    def testDirection(self):
-        dev = BitBangDevice()
-        # check that a direction can be given on open and is honoured
-        for dir_test in (0, 1, 4, 12, 120, 255):
-            def _(dt):
-                dev.direction = dt
-            self.assertCalls(lambda: _(dir_test), 'ftdi_set_bitmode')
-            self.assertEqual(dev.direction, dir_test)
-            self.assertEqual(dev._direction, dir_test)
-            self.assertEqual(dev._last_set_dir, dir_test)
-        # check an invalid direction on open gives error
-        def _():  # NOQA
-            dev.direction = 300
-        self.assertRaises(FtdiError, _)
-
-    def testPort(self):
-        dev = BitBangDevice()
-        # check that a direction can be given on open and is honoured
-        for port_test in (0, 1, 4, 12, 120, 255):
-            def _(pt):
-                dev.port = pt
-            self.assertCalls(lambda: _(port_test), 'ftdi_write_data')
-            self.assertEqual(dev._latch, port_test)
-            self.assertEqual(dev.port, port_test)
-        # TODO: this is incomplete.
-        # could check for various directions and how that impacts
-        # port read / write, as well as r/m/w operations.
-
-if __name__ == "__main__":
-    unittest.main()

pylibftdi/tests/test_bus.py

-
-from pylibftdi.tests.test_common import unittest
-from pylibftdi.util import Bus
-
-
-class TestBus(unittest.TestCase):
-
-    class MockDriver(object):
-        port = 0
-
-    class Bus1(object):
-        a = Bus(0, 2)
-        b = Bus(2, 1)
-        c = Bus(3, 5)
-
-        def __init__(self):
-            self.driver = TestBus.MockDriver()
-
-    def test_bus_write(self):
-        test_bus = TestBus.Bus1()
-        # test writing to the bus
-        self.assertEqual(test_bus.driver.port, 0)
-        test_bus.a = 3
-        test_bus.b = 1
-        test_bus.c = 31
-        self.assertEqual(test_bus.driver.port, 255)
-        test_bus.b = 0
-        self.assertEqual(test_bus.driver.port, 251)
-        test_bus.c = 16
-        self.assertEqual(test_bus.driver.port, 131)
-
-    def test_bus_read(self):
-        test_bus = TestBus.Bus1()
-        # test reading from the bus
-        test_bus.driver.port = 0x55
-        assert test_bus.a == 1
-        assert test_bus.b == 1
-        assert test_bus.c == 10
-        test_bus.driver.port = 0xAA
-        assert test_bus.a == 2
-        assert test_bus.b == 0
-        assert test_bus.c == 21

pylibftdi/tests/test_common.py

-"""
-pylibftdi - python wrapper for libftdi
-
-Copyright (c) 2010-2012 Ben Bass <benbass@codedstructure.net>
-See LICENSE file for details and (absence of) warranty
-
-pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
-
-This module contains some basic tests for the higher-level
-functionality without requiring an actual hardware device
-to be attached.
-"""
-
-import sys
-if sys.version_info < (2, 7):
-    try:
-        import unittest2 as unittest
-    except ImportError:
-        raise SystemExit("The test functionality is only supported in"
-                "Python 2.7+ unless unittest2 is installed")
-else:
-    import unittest  # NOQA
-
-VERBOSE = False
-
-
-class SimpleMock(object):
-    """
-    This is a simple mock plugin for fdll which logs any calls
-    made through it to fn_log, which is currently rather ugly
-    global state.
-    """
-    def __init__(self, name="<base>"):
-        self.__name = name
-
-    def __getattr__(self, key):
-        return SimpleMock(key)
-
-    def __call__(self, *o, **k):
-        CallLog.append(self.__name)
-        if VERBOSE:
-            print("%s(*%s, **%s)" % (self.__name, o, k))
-        return 0
-
-
-class CallLog(object):
-
-    fn_log = []
-
-    @classmethod
-    def reset(cls):
-        del cls.fn_log[:]
-
-    @classmethod
-    def append(cls, value):
-        cls.fn_log.append(value)
-
-    @classmethod
-    def get(cls):
-        return cls.fn_log[:]
-
-
-class CallCheckMixin(object):
-    """
-    this should be used as a mixin for unittest.TestCase classes,
-    where it allows the calls through the MockDriver to be checked
-    this does not support multi-threading.
-    """
-
-    def setUp(self):
-        super(CallCheckMixin, self).setUp()
-
-    def assertCalls(self, fn, methodname):
-        CallLog.reset()
-        fn()
-        self.assertIn(methodname, CallLog.get())
-
-    def assertCallsExact(self, fn, call_list):
-        CallLog.reset()
-        fn()
-        self.assertEqual(call_list, CallLog.get())
-
-
-# monkey patch the Driver class to be the mock thing above.
-class MockDriver(object):
-    def __init__(self, *o, **k):
-        self.fdll = SimpleMock()
-
-
-import pylibftdi.driver
-from pylibftdi.driver import Device
-
-
-class LoopDevice(Device):
-    """
-    a mock device object which overrides read and write
-    to operate as an unbounded loopback pair
-    """
-    def __init__(self, *o, **k):
-        super(LoopDevice, self).__init__(*o, **k)
-        self.__buffer = []
-
-    def _read(self, size):
-        super(LoopDevice, self)._read(size)  # discard result
-        result = bytes(bytearray(self.__buffer[:size]))
-        self.__buffer = self.__buffer[size:]
-        return result
-
-    def _write(self, data):
-        super(LoopDevice, self)._write(data)  # discard result
-        self.__buffer.extend(bytearray(data))
-        return len(data)
-
-# importing this _does_ things...
-pylibftdi.driver.Driver = MockDriver
-
-if set(['-v', '--verbose']) & set(sys.argv):
-    VERBOSE = True

pylibftdi/tests/test_driver.py

-"""
-pylibftdi - python wrapper for libftdi
-
-Copyright (c) 2010-2012 Ben Bass <benbass@codedstructure.net>
-See LICENSE file for details and (absence of) warranty
-
-pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
-
-This module contains some basic tests for the higher-level
-functionality without requiring an actual hardware device
-to be attached.
-"""
-
-from pylibftdi.tests.test_common import (LoopDevice, Device, CallCheckMixin, unittest)
-
-# and now some test cases...
-
-
-class DeviceFunctions(CallCheckMixin, unittest.TestCase):
-
-    def testContextManager(self):
-        def _():
-            with Device():
-                pass
-        self.assertCallsExact(_,
-                ['ftdi_init', 'ftdi_usb_open',
-                 'ftdi_usb_close', 'ftdi_deinit'])
-
-    def testOpen(self):
-        # a lazy_open open() shouldn't do anything
-        self.assertCallsExact(lambda: Device(lazy_open=True), [])
-        # a non-lazy_open open() should open the port...
-        self.assertCalls(lambda: Device(), 'ftdi_usb_open')
-        # and given a device_id, it should do a open_desc
-        self.assertCalls(lambda: Device('bogus'), 'ftdi_usb_open_desc')
-
-    def testReadWrite(self):
-        with Device() as dev:
-            self.assertCalls(lambda: dev.write('xxx'), 'ftdi_write_data')
-            self.assertCalls(lambda: dev.read(10), 'ftdi_read_data')
-
-    def testFlush(self):
-        with Device() as dev:
-            self.assertCalls(dev.flush_input, 'ftdi_usb_purge_rx_buffer')
-            self.assertCalls(dev.flush_output, 'ftdi_usb_purge_tx_buffer')
-            self.assertCalls(dev.flush, 'ftdi_usb_purge_buffers')
-
-
-class LoopbackTest(unittest.TestCase):
-    """
-    these all require mode='t' to pass in Python3
-    """
-
-    def testPrint(self):
-        d = LoopDevice(mode='t')
-        d.write('Hello')
-        d.write(' World\n')
-        d.write('Bye')
-        self.assertEqual(d.readline(), 'Hello World\n')
-        self.assertEqual(d.readline(), 'Bye')
-
-    def testLines(self):
-        d = LoopDevice(mode='t')
-        lines = ['Hello\n', 'World\n', 'And\n', 'Goodbye\n']
-        d.writelines(lines)
-        self.assertEqual(d.readlines(), lines)
-
-    def testIterate(self):
-        d = LoopDevice(mode='t')
-        lines = ['Hello\n', 'World\n', 'And\n', 'Goodbye\n']
-        d.writelines(lines)
-        for idx, line in enumerate(d):
-            self.assertEqual(line, lines[idx])
-
-
-if __name__ == "__main__":
-    unittest.main()

pylibftdi/util.py

 # The Bus descriptor class is probably useful outside of
 # pylibftdi.  It tries to be to Python what bitfields are
 # to C. Its only requirement (which is fairly pylibftdi-ish)
-# is a 'driver' attribute on the object this is attached
+# is a 'device' attribute on the object this is attached
 # to, which has a 'port' property which is readable and