From ab40ff276a60650d0abf0abf89af48658d3c3ea8 Mon Sep 17 00:00:00 2001 From: cliechti Date: Sat, 2 Jan 2010 03:18:37 +0000 Subject: tag 2.5-rc2 --- CHANGES.txt | 336 ++++++ LICENSE.txt | 61 ++ MANIFEST.in | 34 + README.txt | 38 + documentation/Makefile | 88 ++ documentation/appendix.rst | 100 ++ documentation/conf.py | 194 ++++ documentation/examples.rst | 351 ++++++ documentation/index.rst | 41 + documentation/pyparallel.rst | 165 +++ documentation/pyserial.png | Bin 0 -> 7050 bytes documentation/pyserial.rst | 113 ++ documentation/pyserial_api.rst | 800 ++++++++++++++ documentation/shortintro.rst | 57 + examples/enhancedserial.py | 62 ++ examples/miniterm.py | 573 ++++++++++ examples/port_publisher.py | 483 ++++++++ examples/port_publisher.sh | 44 + examples/rfc2217_server.py | 204 ++++ examples/scan.py | 30 + examples/scanlinux.py | 20 + examples/scanwin32.py | 232 ++++ examples/setup-miniterm-py2exe.py | 26 + examples/setup-rfc2217_server-py2exe.py | 24 + examples/setup-wxTerminal-py2exe.py | 35 + examples/tcp_serial_redirect.py | 326 ++++++ examples/wxSerialConfigDialog.py | 260 +++++ examples/wxSerialConfigDialog.wxg | 262 +++++ examples/wxTerminal.py | 333 ++++++ examples/wxTerminal.wxg | 127 +++ pyparallel/CHANGES.txt | 9 - pyparallel/LICENSE.txt | 61 -- pyparallel/MANIFEST | 23 - pyparallel/README.txt | 62 -- pyparallel/examples/lcd.py | 182 --- pyparallel/makefile | 6 - pyparallel/parallel/__init__.py | 22 - pyparallel/parallel/parallelppdev.py | 595 ---------- pyparallel/parallel/parallelutil.py | 124 --- pyparallel/parallel/parallelwin32.py | 139 --- pyparallel/setup.py | 52 - pyparallel/src/win32/README.txt | 32 - pyparallel/src/win32/_pyparallel.c | 69 -- pyparallel/src/win32/giveio/GIVEIO.C | 168 --- pyparallel/src/win32/giveio/MAKEFILE | 7 - pyparallel/src/win32/giveio/README.TXT | 92 -- pyparallel/src/win32/giveio/SOURCES | 7 - pyparallel/src/win32/install_giveio.bat | 18 - pyparallel/src/win32/loaddrv_console/loaddrv.c | 458 -------- pyparallel/src/win32/loaddrv_console/loaddrv.h | 18 - pyparallel/src/win32/loaddrv_console/makefile | 5 - pyparallel/src/win32/makefile | 9 - pyparallel/src/win32/remove_giveio.bat | 13 - pyparallel/src/win32/simpleio.c | 47 - pyparallel/src/win32/simpleio.dll | Bin 5632 -> 0 bytes pyserial/CHANGES.txt | 372 ------- pyserial/LICENSE.txt | 61 -- pyserial/MANIFEST.in | 34 - pyserial/README.txt | 38 - pyserial/documentation/Makefile | 88 -- pyserial/documentation/appendix.rst | 100 -- pyserial/documentation/conf.py | 194 ---- pyserial/documentation/examples.rst | 351 ------ pyserial/documentation/index.rst | 41 - pyserial/documentation/pyparallel.rst | 165 --- pyserial/documentation/pyserial.png | Bin 7050 -> 0 bytes pyserial/documentation/pyserial.rst | 113 -- pyserial/documentation/pyserial_api.rst | 816 -------------- pyserial/documentation/shortintro.rst | 57 - pyserial/examples/enhancedserial.py | 62 -- pyserial/examples/miniterm.py | 584 ---------- pyserial/examples/port_publisher.py | 485 -------- pyserial/examples/port_publisher.sh | 44 - pyserial/examples/rfc2217_server.py | 204 ---- pyserial/examples/scan.py | 30 - pyserial/examples/scanlinux.py | 20 - pyserial/examples/scanwin32.py | 232 ---- pyserial/examples/setup-miniterm-py2exe.py | 26 - pyserial/examples/setup-rfc2217_server-py2exe.py | 24 - pyserial/examples/setup-wxTerminal-py2exe.py | 35 - pyserial/examples/tcp_serial_redirect.py | 326 ------ pyserial/examples/wxSerialConfigDialog.py | 260 ----- pyserial/examples/wxSerialConfigDialog.wxg | 262 ----- pyserial/examples/wxTerminal.py | 333 ------ pyserial/examples/wxTerminal.wxg | 127 --- pyserial/serial/.cvsignore | 1 - pyserial/serial/__init__.py | 60 - pyserial/serial/loopback_connection.py | 260 ----- pyserial/serial/rfc2217.py | 1279 ---------------------- pyserial/serial/serialcli.py | 271 ----- pyserial/serial/serialjava.py | 260 ----- pyserial/serial/serialposix.py | 650 ----------- pyserial/serial/serialutil.py | 504 --------- pyserial/serial/serialwin32.py | 386 ------- pyserial/serial/sermsdos.py | 200 ---- pyserial/serial/socket_connection.py | 259 ----- pyserial/serial/win32.py | 288 ----- pyserial/setup.py | 65 -- pyserial/test/run_all_tests.py | 51 - pyserial/test/test.py | 230 ---- pyserial/test/test_advanced.py | 181 --- pyserial/test/test_high_load.py | 77 -- pyserial/test/test_iolib.py | 79 -- serial/.cvsignore | 1 + serial/__init__.py | 60 + serial/loopback_connection.py | 260 +++++ serial/rfc2217.py | 1271 +++++++++++++++++++++ serial/serialcli.py | 271 +++++ serial/serialjava.py | 260 +++++ serial/serialposix.py | 628 +++++++++++ serial/serialutil.py | 504 +++++++++ serial/serialwin32.py | 383 +++++++ serial/sermsdos.py | 200 ++++ serial/socket_connection.py | 259 +++++ serial/win32.py | 288 +++++ setup.py | 65 ++ test/run_all_tests.py | 46 + test/test.py | 230 ++++ test/test_advanced.py | 181 +++ test/test_high_load.py | 77 ++ test/test_iolib.py | 79 ++ 121 files changed, 10482 insertions(+), 12803 deletions(-) create mode 100644 CHANGES.txt create mode 100644 LICENSE.txt create mode 100644 MANIFEST.in create mode 100644 README.txt create mode 100644 documentation/Makefile create mode 100644 documentation/appendix.rst create mode 100644 documentation/conf.py create mode 100644 documentation/examples.rst create mode 100644 documentation/index.rst create mode 100644 documentation/pyparallel.rst create mode 100644 documentation/pyserial.png create mode 100644 documentation/pyserial.rst create mode 100644 documentation/pyserial_api.rst create mode 100644 documentation/shortintro.rst create mode 100644 examples/enhancedserial.py create mode 100644 examples/miniterm.py create mode 100644 examples/port_publisher.py create mode 100644 examples/port_publisher.sh create mode 100644 examples/rfc2217_server.py create mode 100644 examples/scan.py create mode 100644 examples/scanlinux.py create mode 100644 examples/scanwin32.py create mode 100644 examples/setup-miniterm-py2exe.py create mode 100644 examples/setup-rfc2217_server-py2exe.py create mode 100644 examples/setup-wxTerminal-py2exe.py create mode 100644 examples/tcp_serial_redirect.py create mode 100644 examples/wxSerialConfigDialog.py create mode 100644 examples/wxSerialConfigDialog.wxg create mode 100644 examples/wxTerminal.py create mode 100644 examples/wxTerminal.wxg delete mode 100644 pyparallel/CHANGES.txt delete mode 100644 pyparallel/LICENSE.txt delete mode 100644 pyparallel/MANIFEST delete mode 100644 pyparallel/README.txt delete mode 100644 pyparallel/examples/lcd.py delete mode 100644 pyparallel/makefile delete mode 100644 pyparallel/parallel/__init__.py delete mode 100644 pyparallel/parallel/parallelppdev.py delete mode 100644 pyparallel/parallel/parallelutil.py delete mode 100644 pyparallel/parallel/parallelwin32.py delete mode 100644 pyparallel/setup.py delete mode 100644 pyparallel/src/win32/README.txt delete mode 100644 pyparallel/src/win32/_pyparallel.c delete mode 100644 pyparallel/src/win32/giveio/GIVEIO.C delete mode 100644 pyparallel/src/win32/giveio/MAKEFILE delete mode 100644 pyparallel/src/win32/giveio/README.TXT delete mode 100644 pyparallel/src/win32/giveio/SOURCES delete mode 100644 pyparallel/src/win32/install_giveio.bat delete mode 100644 pyparallel/src/win32/loaddrv_console/loaddrv.c delete mode 100644 pyparallel/src/win32/loaddrv_console/loaddrv.h delete mode 100644 pyparallel/src/win32/loaddrv_console/makefile delete mode 100644 pyparallel/src/win32/makefile delete mode 100644 pyparallel/src/win32/remove_giveio.bat delete mode 100644 pyparallel/src/win32/simpleio.c delete mode 100644 pyparallel/src/win32/simpleio.dll delete mode 100644 pyserial/CHANGES.txt delete mode 100644 pyserial/LICENSE.txt delete mode 100644 pyserial/MANIFEST.in delete mode 100644 pyserial/README.txt delete mode 100644 pyserial/documentation/Makefile delete mode 100644 pyserial/documentation/appendix.rst delete mode 100644 pyserial/documentation/conf.py delete mode 100644 pyserial/documentation/examples.rst delete mode 100644 pyserial/documentation/index.rst delete mode 100644 pyserial/documentation/pyparallel.rst delete mode 100644 pyserial/documentation/pyserial.png delete mode 100644 pyserial/documentation/pyserial.rst delete mode 100644 pyserial/documentation/pyserial_api.rst delete mode 100644 pyserial/documentation/shortintro.rst delete mode 100644 pyserial/examples/enhancedserial.py delete mode 100644 pyserial/examples/miniterm.py delete mode 100644 pyserial/examples/port_publisher.py delete mode 100644 pyserial/examples/port_publisher.sh delete mode 100644 pyserial/examples/rfc2217_server.py delete mode 100644 pyserial/examples/scan.py delete mode 100644 pyserial/examples/scanlinux.py delete mode 100644 pyserial/examples/scanwin32.py delete mode 100644 pyserial/examples/setup-miniterm-py2exe.py delete mode 100644 pyserial/examples/setup-rfc2217_server-py2exe.py delete mode 100644 pyserial/examples/setup-wxTerminal-py2exe.py delete mode 100644 pyserial/examples/tcp_serial_redirect.py delete mode 100644 pyserial/examples/wxSerialConfigDialog.py delete mode 100644 pyserial/examples/wxSerialConfigDialog.wxg delete mode 100644 pyserial/examples/wxTerminal.py delete mode 100644 pyserial/examples/wxTerminal.wxg delete mode 100644 pyserial/serial/.cvsignore delete mode 100644 pyserial/serial/__init__.py delete mode 100644 pyserial/serial/loopback_connection.py delete mode 100644 pyserial/serial/rfc2217.py delete mode 100644 pyserial/serial/serialcli.py delete mode 100644 pyserial/serial/serialjava.py delete mode 100644 pyserial/serial/serialposix.py delete mode 100644 pyserial/serial/serialutil.py delete mode 100644 pyserial/serial/serialwin32.py delete mode 100644 pyserial/serial/sermsdos.py delete mode 100644 pyserial/serial/socket_connection.py delete mode 100644 pyserial/serial/win32.py delete mode 100644 pyserial/setup.py delete mode 100644 pyserial/test/run_all_tests.py delete mode 100644 pyserial/test/test.py delete mode 100644 pyserial/test/test_advanced.py delete mode 100644 pyserial/test/test_high_load.py delete mode 100644 pyserial/test/test_iolib.py create mode 100644 serial/.cvsignore create mode 100644 serial/__init__.py create mode 100644 serial/loopback_connection.py create mode 100644 serial/rfc2217.py create mode 100644 serial/serialcli.py create mode 100644 serial/serialjava.py create mode 100644 serial/serialposix.py create mode 100644 serial/serialutil.py create mode 100644 serial/serialwin32.py create mode 100644 serial/sermsdos.py create mode 100644 serial/socket_connection.py create mode 100644 serial/win32.py create mode 100644 setup.py create mode 100644 test/run_all_tests.py create mode 100644 test/test.py create mode 100644 test/test_advanced.py create mode 100644 test/test_high_load.py create mode 100644 test/test_iolib.py diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..6b28b6e --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,336 @@ +======================== + pySerial Release Notes +======================== + +Version 1.0 13 Feb 2002 +--------------------------- +- First public release. +- Split from the pybsl application (see http://mspgcc.sourceforge.net) + +New Features: + +- Added Jython support + + +Version 1.1 14 Feb 2002 +--------------------------- +Bugfixes: + +- Win32, when not specifying a timeout +- Typos in the Docs + +New Features: + +- added ``serialutil`` which provides a base class for the ``Serial`` + objects. + +- ``readline``, ``readlines``, ``writelines`` and ``flush`` are now supported + see README.txt for deatils. + + +Version 1.11 14 Feb 2002 +--------------------------- +Same as 1.1 but added missing files. + + +Version 1.12 18 Feb 2002 +--------------------------- +Removed unneded constants to fix RH7.x problems. + + +Version 1.13 09 Apr 2002 +--------------------------- +Added alternate way for enabling rtscts (CNEW_RTSCTS is tried too) +If port opening fails, a ``SerialException`` is raised on all platforms + + +Version 1.14 29 May 2002 +--------------------------- +Added examples to archive +Added non-blocking mode for ``timeout=0`` (tnx Mat Martineau) + +Bugfixes: + +- win32 does now return the remaining characters on timeout + + +Version 1.15 04 Jun 2002 +--------------------------- +Bugfixes (win32): + +- removed debug messages +- compatibility to win9x improved + + +Version 1.16 02 Jul 2002 +--------------------------- +Added implementation of RI and corrected RTS/CTS on Win32 + + +Version 1.17 03 Jul 2002 +--------------------------- +Silly mix of two versions in win32 code corrected + + +Version 1.18 06 Dec 2002 +--------------------------- +Bugfixes (general): + +- remove the mapping of flush to the destructive flushOutput as + this is not the expected behaviour. +- readline: EOL character for lines can be chosen idea by + John Florian. + +Bugfixes (posix): + +- cygwin port numbering fixed +- test each and every constant for it's existence in termios module, + use default if not existent (fix for Bug item #640214) +- wrong exception on nonexistent ports with /dev file. bug report + by Louis Cordier + +Bugfixes (win32): + +- RTS/CTS handling as suggested in Bug #635072 +- bugfix of timeouts brought up by Markus Hoffrogge + + +Version 1.19 19 Mar 2003 +--------------------------- +Bugfixes (posix): + +- removed ``dgux`` entry which actually had a wrong comment and is + probably not in use anywhere. + +Bugfixes (win32): + +- added ``int()`` conversion, [Bug 702120] +- remove code to set control lines in close method of win32 + version. [Bug 669625] + + +Version 1.20 28 Aug 2003 +--------------------------- +- Added ``serial.device()`` for all platforms + +Bugfixes (win32): + +- don't recreate overlapped structures and events on each + read/write. +- don't set unneeded event masks. +- dont use DOS device names for ports > 9. +- remove send timeout (its not used in the linux impl. anyway). + + +Version 1.21 30 Sep 2003 +--------------------------- +Bugfixes (win32): + +- name for COM10 was not built correctly, found by Norm Davis. + +Bugfixes (examples): + +- small change in ``miniterm.py`` that should mage it run on cygwin, + [Bug 809904] submitted by Rolf Campbell. + + +Version 2.0b1 1 Oct 2003 +--------------------------- +Transition to the Python 2.0 series: + +- New implementation only supports Python 2.2+, backwards compatibility + should be maintained almost everywhere. + The OS handles (like the ``hComPort`` or ``fd`` attribute) were prefixed + with an underscore. The different names stay, as anyone that uses one of + these has to write platform specific code anyway. +- Common base class ``serialutil.SerialBase`` for all implementations. +- ``PARITY_NONE``, ``PARITY_EVEN``, ``PARITY_ODD`` constants changed and all + these constants moved to ``serialutil.py`` (still available as + ``serial.PARITY_NONE`` etc. and they should be used that way) +- Added ``serial.PARITY_NAMES`` (implemented in ``serialutil.PARITY_NAMES``). + This dictionary can be used to convert parity constants to meaningful + strings. +- Each Serial class and instance has a list of supported values: + ``BAUDRATES``, ``BYTESIZES``, ``PARITIES``, ``STOPBITS`` + (i.e. ``serial.Serial.BAUDRATES or s = serial.Serial; s.BAUDRATES``) + these values can be used to fill in value sin GUI dialogs etc. +- Creating a ``Serial()`` object without port spec returns an unconfigured, + closed port. Useful if a GUI dialog should take a port and configure + it. +- New methods for ``serial.Serial`` instances: ``open()``, ``isOpen()`` +- A port can be opened and closed as many times as desired. +- Instances of ``serial.Serial`` have ``baudrate``, ``bytesize``, ``timeout`` + etc. attributes implemented as properties, all can be set while the port is + opened. It will then be reconfigured. +- Improved ``__doc__``'s. +- New ``test_advanced.py`` for the property setting/getting testing. +- Small bugfix on posix with get* methods (return value should be true a + boolean). +- added a ``__repr__`` that returns a meaningful string will all the serial + setting, easy for debugging. +- The serialposix module does not throw an exception on unsupported + platforms, the message is still printed. The idea that it may still + work even if the platform itself s not known, it simply tries to do + the posix stuff anyway (It's likely that opening ports by number + fails, but by name it should work). + + +Version 2.0b2 4 Oct 2003 +--------------------------- +- Added serial port configuration dialog for wxPython to the examples. +- Added terminal application for wxPython with wxGlade design file + to the examples. +- Jython support is currently broken as Jython does not have a Python 2.2 + compatible release out yet + + +Version 2.0 6 Nov 2003 +--------------------------- +- Fixes ``setup.py`` for older distutils + + +Version 2.1 28 Jul 2004 +--------------------------- +Bugfixes: + +- Fix XON/XOFF values [Bug 975250] + +Bugfixes (posix): + +- ``fd == 0`` fix from Vsevolod Lobko +- netbsd fixes from Erik Lindgren +- Dynamicaly lookup baudrates and some cleanups + +Bugfixes (examples): + +- CRLF handling of ``miniterm.py`` should be more consistent on Win32 + and others. Added LF only command line option +- Multithreading fixes to ``wxTerminal.py`` (helps with wxGTK) +- Small change for wxPython 2.5 in ``wxSerialConfigDialog.py`` [Bug 994856] + +New Features: + +- Implement write timeouts (``writeTimeout`` parameter) + + +Version 2.2 31 Jul 2005 +--------------------------- +Bugfixes: + +- [Bug 1014227]: property broken +- [Bug 1105687]: ``serial_tcp_example.py``: ``--localport`` option +- [Bug 1106313]: device (port) strings cannot be unicode + +Bugfixes (posix): + +- [Patch 1043436] Fix for [Bug 1043420] (OSError: EAGAIN) +- [Patch 1102700] ``fileno()`` added +- ensure disabled PARMRK + +Bugfixes (win32): + +- [Patch 983106]: keep RTS/CTS state on port setting changes + +New Features: + +- ``dsrdtr`` setting to enable/disable DSR/DTR flow control independently + from the ``rtscts`` setting. (Currenly Win32 only, ignored on other + platforms) + + +Version 2.3 19 Jun 2008 +--------------------------- +New Features: + +- iterator interface. ``for line in Serial(...): ...`` is now possible + Suggested by Bernhard Bender +- ``sendBreak()`` accepts a ``duration`` argument. Default duration increased. +- win32 handles \\.\COMx format automatically for com ports of higher number + (COM10 is internally translated to \\.\COM10 etc.) +- miniterm.py has a new feature to send a file (upload) and configurable + special characters for exit and upload. Refactored internals to class based + structure (upload and class refactoring by Colin D Bennett) + +Bugfixes: + +- [Bug 1451535] TCP/serial redirect example "--help" +- update VERSION variable +- update wxSerialConfigDialog.py and wxTerminal.py compatibility with + wxPython 2.8 (Peleg) +- Check for string in write function. Using unicode causes errors, this + helps catching errors early (Tom Lynn) + +Bugfixes (posix): + +- [Bug 1554183] setRTS/setDTR reference to non existing local "on" +- [Bug 1513653] file descriptor not closed when exception is thrown +- FreeBSD now uses cuadX instead of cuaaX (Patrick Phalen) + +Bugfixes (win32): + +- [Bug 1520357] Handle leak +- [Bug 1679013] Ignore exception raised by SetCommTimeout() in close(). +- [Bug 1938118] process hang forever under XP + + +Version 2.4 6 Jul 2008 +--------------------------- +New Features: + +- [Patch 1616790] pyserial: Add inter-character timeout feature +- [Patch 1924805] add a setBreak function +- Add mark/space parity +- Add .NET/Mono backend (IronPython) + +Bugfixes (posix): + +- [Bug 1783159] Arbitrary baud rates (Linux/Posix) + +Bugfixes (win32): + +- [Patch 1561423] Add mark/space parity, Win32 +- [Bug 2000771] serial port CANNOT be specified by number on windows +- examples/scanwin32.py does no longer return \\.\ names +- fix \\.\ handling for some cases + +Bugfixes (jython): + + - The Jython backend tries javax.comm and gnu.io (Seo Sanghyeon) + + +Version 2.5 +--------------------------- +New Features: + +- Python 3.x support (through 2to3) +- compatible with Python io library (Python 2.6+) +- Support for Win32 is now written on the top of ctypes (bundled with + Python 2.5+) instead of pywin32 (patch by Giovanni Bajo). +- 1.5 stop bits (STOPBITS_ONE_POINT_FIVE, implemented on all platforms) +- Documentation update, now written with Sphinx/ReST +- miniterm application extended (CTRL+T -> menu) +- miniterm.py is now installed as "script" +- add scanlinux.py example +- add port_publisher example +- experimental RFC-2217 client support (serial.rfc2217.Serial, see docs) +- experimental RFC-2217 server support (examples/rfc2217_server.py) +- add ``serial.serial_for_url`` factory function (support for native ports and + ``rfc2217``, ``socket`` and ``loop`` URLs) +- add ``getSettingsDict`` and ``applySettingsDict`` serial object methods + +Bugfixes: + +- Improve and fix tcp_serial_redirector example. +- [Bug 2603052] 5-bit mode (needs 1.5 stop bits in some cases) + +Bugfixes (posix): + +- [Bug 2810169] Propagate exceptions raised in serialposix _reconfigure +- [Bug 2562610] setting non standard baud rates on Darwin (Emmanuel Blot) + +Bugfixes (win32): + +- [Bug 2469098] parity PARITY_MARK, PARITY_SPACE isn't supported on win32 +- [SF 2446218] outWaiting implemented +- [Bug 2392892] scanwin32.py better exception handling +- [Bug 2505422] scanwin32.py Vista 64bit compatibility diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e8664f4 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,61 @@ +Copyright (c) 2001-2008 Chris Liechti ; +All Rights Reserved. + +This is the Python license. In short, you can use this product in +commercial and non-commercial applications, modify it, redistribute it. +A notification to the author when you use and/or modify it is welcome. + + +TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE +=================================================================== + +LICENSE AGREEMENT +----------------- + +1. This LICENSE AGREEMENT is between the copyright holder of this +product, and the Individual or Organization ("Licensee") accessing +and otherwise using this product in source or binary form and its +associated documentation. + +2. Subject to the terms and conditions of this License Agreement, +the copyright holder hereby grants Licensee a nonexclusive, +royalty-free, world-wide license to reproduce, analyze, test, +perform and/or display publicly, prepare derivative works, distribute, +and otherwise use this product alone or in any derivative version, +provided, however, that copyright holders License Agreement and +copyright holders notice of copyright are retained in this product +alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates this product or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to this product. + +4. The copyright holder is making this product available to Licensee on +an "AS IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS OR +WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, +THE COPYRIGHT HOLDER MAKES NO AND DISCLAIMS ANY REPRESENTATION OR +WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR +THAT THE USE OF THIS PRODUCT WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. + +5. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER +USERS OF THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL +DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE +USING THIS PRODUCT, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE +POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between the +copyright holder and Licensee. This License Agreement does not grant +permission to use trademarks or trade names from the copyright holder +in a trademark sense to endorse or promote products or services of +Licensee, or any third party. + +8. By copying, installing or otherwise using this product, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..64f7d0a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,34 @@ +include README.txt +include LICENSE.txt +include CHANGES.txt +include MANIFEST.in +include setup.py + +include examples/enhancedserial.py +include examples/miniterm.py +include examples/port_publisher.py +include examples/port_publisher.sh +include examples/rfc2217_server.py +include examples/scan.py +include examples/scanlinux.py +include examples/scanwin32.py +include examples/setup-miniterm-py2exe.py +include examples/setup-rfc2217_server-py2exe.py +include examples/setup-wxTerminal-py2exe.py +include examples/tcp_serial_redirect.py +include examples/wxSerialConfigDialog.py +include examples/wxSerialConfigDialog.wxg +include examples/wxTerminal.py +include examples/wxTerminal.wxg + +include test/run_all_tests.py +include test/test.py +include test/test_advanced.py +include test/test_high_load.py +include test/test_io_lib.py + +include documentation/*.rst +include documentation/pyserial.png +include documentation/conf.py +include documentation/Makefile + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..7767da3 --- /dev/null +++ b/README.txt @@ -0,0 +1,38 @@ +========== + pySerial +========== + +Overview +======== +This module encapsulates the access for the serial port. It provides backends +for Python running on Windows, Linux, BSD (possibly any POSIX compliant +system), Jython and IronPython (.NET and Mono). The module named "serial" +automatically selects the appropriate backend. + +- Project Homepage: http://pyserial.sourceforge.net +- Project page on SourceForge: http://sourceforge.net/projects/pyserial/ +- SVN repository: http://sourceforge.net/svn/?group_id=46487 +- Download Page: http://sourceforge.net/project/showfiles.php?group_id=46487 + +BSD license, (C) 2001-2009 Chris Liechti + + +Documentation +============= +For API documentation, usage and examples see files in the "documentation" +directory. The ".rst" files can be read in any text editor or being converted to +HTML or PDF using Sphinx. An online HTML version is at +http://pyserial.sourceforge.net. + + +Examples +======== +Examples and unit tests are in the directory "examples". + + +Installation +============ +Detailed information can be found in "documentation/pyserial.rst". + +The usual setup.py for Python libraries is used for the source distribution. +Windows installers are also available (see download link above). diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..8384360 --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,88 @@ +# 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 ' where 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." diff --git a/documentation/appendix.rst b/documentation/appendix.rst new file mode 100644 index 0000000..8492717 --- /dev/null +++ b/documentation/appendix.rst @@ -0,0 +1,100 @@ +========== + Appendix +========== + +How To +====== + +Enable :rfc:`2217` in programs using pySerial. + Patch the code where the :class:`serial.Serial` is instantiated. Replace + it with:: + + try: + s = serial.serial_for_url(...) + except AttributeError: + s = serial.Serial(...) + + Assuming the application already stores port names as strings that's all + that is required. The user just needs a way to change the port setting of + your application to an ``rfc2217://`` :ref:`URL ` (e.g. by editing a + configuration file, GUI dialog etc.). + + Please note that this enables all :ref:`URL ` types supported by + pySerial and that those involving the network are unencrypted and not + protected against eavesdropping. + +Test your setup. + Is the device not working as expected? Maybe it's time to check the + connection before proceeding. :ref:`miniterm` from the :ref:`examples` + can be used to open the serial port and do some basic tests. + + To test cables, connecting RX to TX (loop back) and typing some characters + in :ref:`miniterm` is a simple test. When the characters are displayed + on the screen, then at least RX and TX work (they still could be swapped + though). + + +Related software +================ + +com0com - http://com0com.sourceforge.net/ + Provides virtual serial ports for Windows. + + +License +======= + +Copyright (C) 2001-2009 Chris Liechti ; +All Rights Reserved. + +This is the Python license. In short, you can use this product in commercial +and non-commercial applications, modify it, redistribute it. A notification to +the author when you use and/or modify it is welcome. + + +**TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE** + +*LICENSE AGREEMENT* + +1. This LICENSE AGREEMENT is between the copyright holder of this product, and + the Individual or Organization ("Licensee") accessing and otherwise using + this product in source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, the copyright + holder hereby grants Licensee a nonexclusive, royalty-free, world-wide + license to reproduce, analyze, test, perform and/or display publicly, + prepare derivative works, distribute, and otherwise use this product alone + or in any derivative version, provided, however, that copyright holders + License Agreement and copyright holders notice of copyright are retained in + this product alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on or + incorporates this product or any part thereof, and wants to make the + derivative work available to others as provided herein, then Licensee hereby + agrees to include in any such work a brief summary of the changes made to + this product. + +4. The copyright holder is making this product available to Licensee on an "AS + IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS OR WARRANTIES, + EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, THE COPYRIGHT + HOLDER MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF + MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF + THIS PRODUCT WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. + +5. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF + THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS + AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING THIS PRODUCT, OR + ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material breach + of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any relationship + of agency, partnership, or joint venture between the copyright holder and + Licensee. This License Agreement does not grant permission to use trademarks + or trade names from the copyright holder in a trademark sense to endorse or + promote products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using this product, Licensee agrees to + be bound by the terms and conditions of this License Agreement. + diff --git a/documentation/conf.py b/documentation/conf.py new file mode 100644 index 0000000..7420982 --- /dev/null +++ b/documentation/conf.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# pySerial 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 = [] + +# 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' +copyright = u'2009, Chris Liechti' + +# 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 = '2.5' +# The full version, including alpha/beta/rc tags. +release = '2.5 preview' + +# 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 +# " v 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.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 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 = 'pySerialdoc' + + +# -- 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.tex', u'pySerial Documentation', + u'Chris Liechti', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +latex_logo = 'pyserial.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 diff --git a/documentation/examples.rst b/documentation/examples.rst new file mode 100644 index 0000000..0bfdaae --- /dev/null +++ b/documentation/examples.rst @@ -0,0 +1,351 @@ +.. _examples: + +========== + Examples +========== + +.. _miniterm: + +Miniterm +======== +This is a console application that provides a small terminal application. +miniterm itself does not implement any terminal features such as VT102 +compatibility. However it inherits these features from the terminal it is run. +For example on GNU/Linux running from an xterm it will support the escape +sequences of the xterm. On Windows the typical console window is dumb and does +not support any escapes. When ANSI.sys is loaded it supports some escapes. + +miniterm:: + + --- Miniterm on /dev/ttyS0: 9600,8,N,1 --- + --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- + +Command line options can be given so that binary data including escapes for +terminals are escaped or output as hex. + +miniterm supports :rfc:`2217` remote serial ports and raw sockets using URLs +such as ``rfc2217:://:`` respectively ``socket://:`` as +*port* argument when invoking. + +Command line options ``miniterm.py -h``:: + + Usage: miniterm.py [options] [port [baudrate]] + + Miniterm - A simple terminal program for the serial port. + + Options: + -h, --help show this help message and exit + -p PORT, --port=PORT port, a number (default 0) or a device name + (deprecated option) + -b BAUDRATE, --baud=BAUDRATE + set baud rate, default 9600 + --parity=PARITY set parity, one of [N, E, O, S, M], default=N + -e, --echo enable local echo (default off) + --rtscts enable RTS/CTS flow control (default off) + --xonxoff enable software flow control (default off) + --cr do not send CR+LF, send CR only + --lf do not send CR+LF, send LF only + -D, --debug debug received data (escape non-printable chars) + --debug can be given multiple times: 0: just print + what is received 1: escape non-printable characters, + do newlines as unusual 2: escape non-printable + characters, newlines too 3: hex dump everything + --rts=RTS_STATE set initial RTS line state (possible values: 0, 1) + --dtr=DTR_STATE set initial DTR line state (possible values: 0, 1) + -q, --quiet suppress non error messages + --exit-char=EXIT_CHAR + ASCII code of special character that is used to exit + the application + --menu-char=MENU_CHAR + ASCII code of special character that is used to + control miniterm (menu) + + +miniterm supports some control functions. Typing :kbd:`Control+t Control+h` when it is +running shows the help text:: + + --- pySerial - miniterm - help + --- + --- Ctrl+] Exit program + --- Ctrl+T Menu escape key, followed by: + --- Menu keys: + --- Ctrl+T Send the menu character itself to remote + --- Ctrl+] Send the exit character to remote + --- Ctrl+I Show info + --- Ctrl+U Upload file (prompt will be shown) + --- Toggles: + --- Ctrl+R RTS Ctrl+E local echo + --- Ctrl+D DTR Ctrl+B BREAK + --- Ctrl+L line feed Ctrl+A Cycle repr mode + --- + --- Port settings (Ctrl+T followed by the following): + --- 7 8 set data bits + --- n e o s m change parity (None, Even, Odd, Space, Mark) + --- 1 2 3 set stop bits (1, 2, 1.5) + --- b change baud rate + --- x X disable/enable software flow control + --- r R disable/enable hardware flow control + +.. versionchanged:: 2.5 + Added :kbd:`Control+t` menu and added support for opening URLs. + +miniterm.py_ + The miniterm program. + +setup-miniterm-py2exe.py_ + This is a py2exe setup script for Windows. It can be used to create a + standalone ``miniterm.exe``. + +.. _miniterm.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/miniterm.py +.. _setup-miniterm-py2exe.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/setup-miniterm-py2exe.py + + +TCP/IP - serial bridge +====================== +This program opens a TCP/IP port. When a connection is made to that port (e.g. +with telnet) it forwards all data to the serial port and vice versa. + +This example only exports a raw socket connection. The next example +below gives the client much more control over the remote serial port. + +- The serial port settings are set on the command line when starting the + program. +- There is no possibility to change settings from remote. +- All data is passed through as-is. + +:: + + Usage: tcp_serial_redirect.py [options] [port [baudrate]] + + Simple Serial to Network (TCP/IP) redirector. + + Options: + -h, --help show this help message and exit + -q, --quiet suppress non error messages + --spy peek at the communication and print all data to the + console + + Serial Port: + Serial port settings + + -p PORT, --port=PORT + port, a number (default 0) or a device name + -b BAUDRATE, --baud=BAUDRATE + set baud rate, default: 9600 + --parity=PARITY set parity, one of [N, E, O], default=N + --rtscts enable RTS/CTS flow control (default off) + --xonxoff enable software flow control (default off) + --rts=RTS_STATE set initial RTS line state (possible values: 0, 1) + --dtr=DTR_STATE set initial DTR line state (possible values: 0, 1) + + Network settings: + Network configuration. + + -P LOCAL_PORT, --localport=LOCAL_PORT + local TCP port + --rfc2217 allow control commands with Telnet extension RFC-2217 + + Newline Settings: + Convert newlines between network and serial port. Conversion is + normally disabled and can be enabled by --convert. + + -c, --convert enable newline conversion (default off) + --net-nl=NET_NEWLINE + type of newlines that are expected on the network + (default: LF) + --ser-nl=SER_NEWLINE + type of newlines that are expected on the serial port + (default: CR+LF) + + NOTE: no security measures are implemented. Anyone can remotely connect to + this service over the network. Only one connection at once is supported. When + the connection is terminated it waits for the next connect. + + +tcp_serial_redirect.py_ + Main program. + +.. _tcp_serial_redirect.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/tcp_serial_redirect.py + +Single-port TCP/IP - serial bridge (RFC 2217) +============================================= +Simple cross platform :rfc:`2217` serial port server. It uses threads and is +portable (runs on POSIX, Windows, etc). + +- The port settings and control lines (RTS/DTR) can be changed at any time + using :rfc:`2217` requests. The status lines (DSR/CTS/RI/CD) are polled every + second and notifications are sent to the client. +- Telnet character IAC (0xff) needs to be doubled in data stream. IAC followed + by an other value is interpreted as Telnet command sequence. +- Telnet negotiation commands are sent when connecting to the server. +- RTS/DTR are activated on client connect and deactivated on disconnect. +- Default port settings are set again when client disconnects. + +:: + + Usage: rfc2217_server.py [options] port + + RFC 2217 Serial to Network (TCP/IP) redirector. + + Options: + -h, --help show this help message and exit + -p LOCAL_PORT, --localport=LOCAL_PORT + local TCP port + + NOTE: no security measures are implemented. Anyone can remotely connect to + this service over the network. Only one connection at once is supported. When + the connection is terminated it waits for the next connect. + +.. versionadded:: 2.5 + +rfc2217_server.py_ + Main program. + +setup-rfc2217_server-py2exe.py_ + This is a py2exe setup script for Windows. It can be used to create a + standalone ``rfc2217_server.exe``. + +.. _rfc2217_server.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/rfc2217_server.py +.. _setup-rfc2217_server-py2exe.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/setup-rfc2217_server-py2exe.py + + +Multi-port TCP/IP - serial bridge (RFC 2217) +============================================ +This example implements a TCP/IP to serial port service that works with +multiple ports at once. It uses select, no threads, for the serial ports and +the network sockets and therefore runs on POSIX systems only. + +- Full control over the serial port with :rfc:`2217`. +- Check existence of ``/tty/USB0...8``. This is done every 5 seconds using + ``os.path.exists``. +- Send zeroconf announcements when port appears or disappears (uses + python-avahi and dbus). Service name: ``_serial_port._tcp``. +- Each serial port becomes available as one TCP/IP server. e.g. + ``/dev/ttyUSB0`` is reachable at ``:7000``. +- Single process for all ports and sockets (not per port). +- The script can be started as daemon. +- Logging to stdout or when run as daemon to syslog. +- Default port settings are set again when client disconnects. +- modem status lines (CTS/DSR/RI/CD) are not polled periodically and the server + therefore does not send NOTIFY_MODEMSTATE on its own. However it responds to + request from the client (i.e. use the ``poll_modem`` option in the URL when + using a pySerial client.) + +Requirements: + +- Python (>= 2.4) +- python-avahi +- python-dbus +- python-serial (>= 2.5) + +Installation as daemon: + +- Copy the script ``port_publisher.py`` to ``/usr/local/bin``. +- Copy the script ``port_publisher.sh`` to ``/etc/init.d``. +- Add links to the runlevels using ``update-rc.d port_publisher.sh defaults 99`` +- Thats it :-) the service will be started on next reboot. Alternatively run + ``invoke-rc.d port_publisher.sh start`` as root. + +.. versionadded:: 2.5 new example + +port_publisher.py_ + Multi-port TCP/IP-serial converter (RFC 2217) for POSIX environments. + +port_publisher.sh_ + Example init.d script. + +.. _port_publisher.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/port_publisher.py +.. _port_publisher.sh: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/port_publisher.sh + + +wxPython examples +================= +A simple terminal application for wxPython and a flexible serial port +configuration dialog are shown here. + +wxTerminal.py_ + A simple terminal application. Note that the length of the buffer is + limited by wx and it may suddenly stop displaying new input. + +wxTerminal.wxg_ + A wxGlade design file for the terminal application. + +wxSerialConfigDialog.py_ + A flexible serial port configuration dialog. + +wxSerialConfigDialog.wxg_ + The wxGlade design file for the configuration dialog. + +setup-wxTerminal-py2exe.py_ + A py2exe setup script to package the terminal application. + +.. _wxTerminal.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxTerminal.py +.. _wxTerminal.wxg: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxTerminal.wxg +.. _wxSerialConfigDialog.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxSerialConfigDialog.py +.. _wxSerialConfigDialog.wxg: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxSerialConfigDialog.wxg +.. _setup-wxTerminal-py2exe.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/setup-wxTerminal-py2exe.py + + +Wrapper class +============= +This example provides a subclass based on ``Serial`` that has an alternative +implementation of ``readline()`` + +enhancedserial.py_ + A class with alternative ``readline()`` implementation. + +.. _enhancedserial.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/enhancedserial.py + + +Finding serial ports +==================== +scan.py_ + A simple loop that probes serial ports by number. + +scanlinux.py_ + A Linux only version looking at the entries in ``/dev``. It works best with + on systems with devfs or udev that only create those entries that represent + devices. On older installations a lot of pre-created device files are found + and an additional open check should be added to ensure that the device is + real. + +scanwin32.py_ + A Windows only version that returns a list of serial ports with information + from the registry. + +.. _scan.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/scan.py +.. _scanlinux.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/scanlinux.py +.. _scanwin32.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/scanwin32.py + + +Unit tests +========== +The project uses a number of unit test to verify the functionality. They all +need a loop back connector. The scripts itself contain more information. All +test scripts are contained in the directory ``test``. + +The unit tests are performed on port ``0`` unless a different device name or +``rfc2217://`` URL is given on the command line (argv[1]). + +run_all_tests.py_ + Collect all tests from all ``test*`` files and run them. By default, the + ``loop://`` device is used. + +test.py_ + Basic tests (binary capabilities, timeout, control lines). + +test_advanced.py_ + Test more advanced features (properties). + +test_high_load.py_ + Tests involving sending a lot of data. + +test_iolib.py_ + Tests involving the :mod:`io` library. Only available for Python 2.6 and + newer. + +.. _run_all_tests.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/test/run_all_tests.py +.. _test.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/test/test.py +.. _test_advanced.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/test/test_advanced.py +.. _test_high_load.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/test/test_high_load.py +.. _test_iolib.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/test/test_iolib.py diff --git a/documentation/index.rst b/documentation/index.rst new file mode 100644 index 0000000..77dae93 --- /dev/null +++ b/documentation/index.rst @@ -0,0 +1,41 @@ +.. pySerial documentation master file + +Welcome to pySerial's documentation +=================================== + +This module encapsulates the access for the serial port. It provides backends +for Python running on Windows, Linux, BSD (possibly any POSIX compliant +system), Jython and IronPython (.NET and Mono). The module named "serial" +automatically selects the appropriate backend. + +Other pages (online) + +- `project page on SourceForge`_ +- `SVN repository`_ +- `Download Page`_ with releases +- This page, when viewed online is at http://pyserial.sf.net. + +.. _`project page on SourceForge`: http://sourceforge.net/projects/pyserial/ +.. _`SVN repository`: http://sourceforge.net/svn/?group_id=46487 +.. _`Download Page`: http://sourceforge.net/project/showfiles.php?group_id=46487 + + +Contents: + +.. toctree:: + :maxdepth: 2 + + pyserial + shortintro + examples + pyserial_api + pyparallel + appendix + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/documentation/pyparallel.rst b/documentation/pyparallel.rst new file mode 100644 index 0000000..00c0b95 --- /dev/null +++ b/documentation/pyparallel.rst @@ -0,0 +1,165 @@ +============ + pyParallel +============ + +.. note:: This module is in development (since years ;-) + +Overview +======== +This module encapsulates the access for the parallel port. It provides backends +for Python running on Windows and Linux. Other platforms are possible too but +not yet integrated. + +This module is still under development. But it may be useful for developers. + +Copyright (C) 2001-2003 Chris Liechti + +Here is the `project page on SourceForge`_ and here is the `SVN repository`_. + +.. _`project page on SourceForge`: http://sourceforge.net/projects/pyserial/ +.. _`SVN repository`: http://sourceforge.net/svn/?group_id=46487 + + +Features +-------- +* same class based interface on all supported platforms +* port numbering starts at zero, no need to know the port name in the user program +* port string (device name) can be specified if access through numbering is inappropriate + + +Requirements +------------ +* Python 2.2 or newer +* "Java Communications" (JavaComm) extension for Java/Jython + + +Installation +------------ +Extract files from the archive, open a shell/console in that directory and let +Distutils do the rest: ``python setup.py install`` + +The files get installed in the "Lib/site-packages" directory in newer Python versions. + +The windows version needs a compiled extension and the giveio.sys driver for +Windows NT/2k/XP. The extension module can be compiled with Distutils with +either MSVC or GCC/mingw32. + +It is released under a free software license, see LICENSE.txt for more details. + + +Short introduction +================== +:: + + >>> import parallel + >>> p = parallel.Parallel() # open LPT1 + >>> p.setData(0x55) + + +Examples +-------- +Please look in the SVN Repository. There is an example directory where you can +find a simple terminal and more. +http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyparallel/examples/ + + +API +=== + +.. module:: parallel + +.. class:: Parallel + + .. method:: __init__(port) + + Open given parallel port. + + .. method:: setData(value) + + Apply the given byte to the data pins of the parallel port. + + .. method:: setDataStrobe(level) + + Set the "data strobe" line to the given state. + + .. method:: setAutoFeed(level) + + Set "auto feed" line to given state. + + .. method:: setInitOut(level) + + Set "initialize" line to given state. + + .. method: setSelect(level) + + Set "select" line to given state. + + .. method:getInError() + + Set "Error" line to given state. + + .. method:: getInSelected() + + Read level of "select" line. + + .. method:: getInPaperOut() + + Read level of "paper out" line. + + .. method:: getInAcknowledge() + + Read level of "Acknowledge" line. + + .. method: getInBusy() + + Read level of "busy" line. + + +.. module:: parallel.parallelutil + +.. class:: BitaccessMeta + + This mix-in class adds a few properties that allow easier bit access to the + data lines. (D0 .. D7) e.g. p.D0 refers to the first bit of the data + lines. + +.. class:: VirtualParallelPort + + This class provides a virtual parallel port implementation, useful + for tests and simulations without real hardware. + + +Notes +===== + +Linux +----- +1. The :manpage:`lp(4)` module must be unloaded, ``rmmod lp``. ``lp`` claims + exclusive access to the port and other programs won't be able to use it. + +2. The :manpage:`ppdev(4)` module needs to be loaded, ``modprobe ppdev``. When + ``udev`` is in use, (default with 2.6 kernels) this will create a + ``/dev/parport0``. + +3. The user needs to have write permissions to ``/dev/parport0``. Many + distributions have an ``lp`` group that owns the device; the simplest is to + add the user account to this group. Simply changing permissions on the + device is not the best strategy as they will be reverted to their defaults + next time the driver is loaded. + + +Windows +------- +The giveio driver must be installed as the module needs direct access to the +hardware. This also means that USB parallel port adapters won't be supported. + + +Misc +==== +References +---------- +* Python: http://www.python.org/ +* Jython: http://www.jython.org/ +* Java@IBM: http://www-106.ibm.com/developerworks/java/jdk/ (JavaComm links are + on the download page for the respective platform JDK) +* Java@SUN: http://java.sun.com/products/ diff --git a/documentation/pyserial.png b/documentation/pyserial.png new file mode 100644 index 0000000..7fd45f4 Binary files /dev/null and b/documentation/pyserial.png differ diff --git a/documentation/pyserial.rst b/documentation/pyserial.rst new file mode 100644 index 0000000..0bc6522 --- /dev/null +++ b/documentation/pyserial.rst @@ -0,0 +1,113 @@ +========== + pySerial +========== + +Overview +======== +This module encapsulates the access for the serial port. It provides backends +for Python running on Windows, Linux, BSD (possibly any POSIX compliant +system), Jython and IronPython (.NET and Mono). The module named "serial" +automatically selects the appropriate backend. + +It is released under a free software license, see LICENSE_ for more +details. + +Copyright (C) 2001-2009 Chris Liechti + +Other pages (online) + +- `project page on SourceForge`_ +- `SVN repository`_ +- `Download Page`_ with releases +- This page, when viewed online is at http://pyserial.sf.net. + +.. _LICENSE: appendix.html#license +.. _`project page on SourceForge`: http://sourceforge.net/projects/pyserial/ +.. _`SVN repository`: http://sourceforge.net/svn/?group_id=46487 +.. _`Download Page`: http://sourceforge.net/project/showfiles.php?group_id=46487 + + +Features +======== +- Same class based interface on all supported platforms. +- Access to the port settings through Python properties. +- Support for different byte sizes, stop bits, parity and flow control with + RTS/CTS and/or Xon/Xoff. +- Working with or without receive timeout. +- File like API with "read" and "write" ("readline" etc. also supported). +- The files in this package are 100% pure Python. +- The port is set up for binary transmission. No NULL byte stripping, CR-LF + translation etc. (which are many times enabled for POSIX.) This makes this + module universally useful. +- Compatible with :mod:`io` library (Python 2.6+) +- RFC 2217 client (experimental), server provided in the examples. + + +Requirements +============ +- Python 2.3 or newer, including Python 3.x +- ctypes extensions on Windows (is in standard library since Python 2.5+) +- "Java Communications" (JavaComm) or compatible extension for Java/Jython + + +Installation +============ + +pyserial +-------- +This installs a package that can be used from Python (``import serial``). + +To install the module for all users on the system, administrator rights (root) +is required.. + +From source (tar.gz or checkout) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +http://pypi.python.org/pypi/pyserial +Unpack the archive, enter the ``pyserial-x.y`` directory and run:: + + python setup.py install + +Setuptools/PyPI +~~~~~~~~~~~~~~~ +Alternatively it can be installed from PyPI, either manually downloading the +files and installing as described above or using:: + + easy_install -U pyserial + +Packages +~~~~~~~~ +There are also packaged versions for some Linux distributions and Windows: + +Debian/Ubuntu + A package is available under the name "python-serial". + +Windows + There is also a Windows installer for end users. It is located in the + PyPi_. Developers may be interested to get the source archive, because it + contains examples and the readme. + +.. _PyPi: http://pypi.python.org/pypi/pyserial + + +References +========== +* Python: http://www.python.org/ +* Jython: http://www.jython.org/ +* Java@IBM: http://www-106.ibm.com/developerworks/java/jdk/ (JavaComm links are + on the download page for the respective platform JDK) +* Java@SUN: http://java.sun.com/products/ +* IronPython: http://www.codeplex.com/IronPython +* setuptools: http://peak.telecommunity.com/DevCenter/setuptools + + +Older Versions +============== +Older versions are still available on the `Download Page`_. pySerial 1.21 is +compatible with Python 2.0 on Windows, Linux and several un*x like systems, +MacOSX and Jython. + +On windows releases older than 2.5 will depend on pywin32_ (previously known as +win32all) + +.. _`Download Page`: http://sourceforge.net/project/showfiles.php?group_id=46487 +.. _pywin32: http://pypi.python.org/pypi/pywin32 diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst new file mode 100644 index 0000000..5f15046 --- /dev/null +++ b/documentation/pyserial_api.rst @@ -0,0 +1,800 @@ +============== + pySerial API +============== + +.. module:: serial + +Classes +======= + +Native ports +------------ + +.. class:: Serial + + .. method:: __init__(port=None, baudrate=9600, bytesize=EIGHTBITS, parity=PARITY_NONE, stopbits=STOPBITS_ONE, timeout=None, xonxoff=0, rtscts=0, interCharTimeout=None) + + :param port: + Device name or port number number or :const:`None`. + + :param baudrate: + Baud rate such as 9600 or 115200 etc. + + :param bytesize: + Number of data bits. Possible values: + :const:`FIVEBITS`, :const:`SIXBITS`, :const:`SEVENBITS`, + :const:`EIGHTBITS` + + :param parity: + Enable parity checking. Possible values: + :const:`PARITY_NONE` :const:`PARITY_EVEN` :const:`PARITY_ODD` + :const:`PARITY_MARK` :const:`PARITY_SPACE` + + :param stopbits: + Number of stop bits. Possible values: + :const:`STOPBITS_ONE` :const:`STOPBITS_ONE_POINT_FIVE` + :const:`STOPBITS_TWO` + + :param timeout: + Set a read timeout value. + + :param xonxoff: + Enable software flow control. + + :param rtscts: + Enable hardware (RTS/CTS) flow control. + + :param interCharTimeout: + Inter-character timeout, :const:`None` to disable (default). + + :exception ValueError: + Will be raised when parameter are out of range, e.g. baud rate, data bits. + + :exception SerialException: + In case the device can not be found or can not be configured. + + + The port is immediately opened on object creation, when a *port* is + given. It is not opened when *port* is :const:`None` and a successive call + to :meth:`open` will be needed. + + Possible values for the parameter *port*: + + - Number: number of device, numbering starts at zero. + - Device name: depending on operating system. e.g. ``/dev/ttyUSB0`` + on GNU/Linux or ``COM3`` on Windows. + + Possible values for the parameter *timeout*: + + - ``timeout = None``: wait forever + - ``timeout = 0``: non-blocking mode (return immediately on read) + - ``timeout = x``: set timeout to ``x`` seconds (float allowed) + + Note that enabling both flow control methods (*xonxoff* and *rtscts*) + together may not be supported. It is common to use one of the methods + at once, not both. + + .. method:: open() + + Open port. + + .. method:: close() + + Close port immediately. + + + The following methods may raise :exc:`ValueError` when applied to a closed + port. + + .. method:: read(size=1) + + :param size: Number of bytes to read. + :return: Bytes read from the port. + + Read *size* bytes from the serial port. If a timeout is set it may + return less characters as requested. With no timeout it will block + until the requested number of bytes is read. + + .. versionchanged:: 2.5 + Returns an instance of :class:`bytes` when available (Python 2.6 + and newer) and :class:`str` otherwise. + + .. method:: write(data) + + :param data: Data to send. + :return: Number of bytes written. + :exception SerialTimeoutException: + In case a write timeout is configured for the port and the time is + exceeded. + + Write the string *data* to the port. + + .. versionchanged:: 2.5 + Accepts instances of :class:`bytes` and :class:`bytearray` when + available (Python 2.6 and newer) and :class:`str` otherwise. + + .. method:: inWaiting() + + Return the number of chars in the receive buffer. + + .. method:: flush() + + Flush of file like objects. In this case, wait until all data is + written. + + .. method:: flushInput() + + Flush input buffer, discarding all it's contents. + + .. method:: flushOutput() + + Clear output buffer, aborting the current output and + discarding all that is in the buffer. + + .. method:: sendBreak(duration=0.25) + + :param duration: Time (float) to activate the BREAK condition. + + Send break condition. Timed, returns to idle state after given + duration. + + .. method:: setBreak(level=True) + + :param level: when true activate BREAK condition, else disable. + + Set break: Controls TXD. When active, no transmitting is possible. + + .. method:: setRTS(level=True) + + :param level: Set control line to logic level. + + Set RTS line to specified logic level. + + .. method:: setDTR(level=True) + + :param level: Set control line to logic level. + + Set DTR line to specified logic level. + + .. method:: getCTS() + + :return: Current state (boolean) + + Return the state of the CTS line. + + .. method:: getDSR() + + :return: Current state (boolean) + + Return the state of the DSR line. + + .. method:: getRI() + + :return: Current state (boolean) + + Return the state of the RI line. + + .. method:: getCD() + + :return: Current state (boolean) + + Return the state of the CD line + + Read-only attributes: + + .. attribute:: name + + Device name. This is always the device name even if the + port was opened by a number. (Read Only). + + .. versionadded:: 2.5 + + .. attribute:: portstr + + :deprecated: use :attr:`name` instead + + .. attribute:: BAUDRATES + + A list of valid baud rates. The list may be incomplete such that higher + baud rates may be supported by the device and that values in between the + standard baud rates are supported. (Read Only). + + .. attribute:: BYTESIZES + + A list of valid byte sizes for the device (Read Only). + + .. attribute:: PARITIES + + A list of valid parities for the device (Read Only). + + .. attribute:: STOPBITS + + A list of valid stop bit widths for the device (Read Only). + + + New values can be assigned to the following attributes, the port will be + reconfigured, even if it's opened at that time: + + .. attribute:: port + + Port name/number as set by the user. + + .. attribute:: baudrate + + Current baud rate setting. + + .. attribute:: bytesize + + Byte size in bits. + + .. attribute:: parity + + Parity setting. + + .. attribute:: stopbits + + Stop bit with. + + .. attribute:: timeout + + Timeout setting (seconds, float). + + .. attribute:: xonxoff + + If Xon/Xoff flow control is enabled. + + .. attribute:: rtscts + + If hardware flow control is enabled. + + Platform specific methods. + + .. warning:: Programs using the following methods are not portable to other platforms! + + .. method:: nonblocking() + + :platform: Unix + + Configure the device for nonblocking operations. This can be useful if + the port is used with ``select``. + + .. method:: fileno() + + :platform: Unix + :return: File descriptor. + + Return file descriptor number for the port that is opened by this object. + + .. method:: setXON(level=True) + + :platform: Windows + :param level: Set flow control state. + + Set software flow control state. + + +.. class:: SerialBase + + The following attributes are implemented as properties. They work with open + and closed ports. + + .. attribute:: port + + Read or write port. When the port is already open, it will be closed + and reopened with the new setting. + + .. attribute:: baudrate + + Read or write current baud rate setting. + + .. attribute:: bytesize + + Read or write current data byte size setting. + + .. attribute:: parity + + Read or write current parity setting. + + .. attribute:: stopbits + + Read or write current stop bit width setting. + + .. attribute:: timeout + + Read or write current read timeout setting. + + .. attribute:: writeTimeout + + Read or write current write timeout setting. + + .. attribute:: xonxoff + + Read or write current software flow control rate setting. + + .. attribute:: rtscts + + Read or write current hardware flow control setting. + + .. attribute:: dsrdtr + + Read or write current hardware flow control setting. + + .. attribute:: interCharTimeout + + Read or write current inter character timeout setting. + + The following constants are also provided: + + .. attribute:: BAUDRATES + + A tuple of standard baud rate values. The actual device may support more + or less... + + .. attribute:: BYTESIZES + + A tuple of supported byte size values. + + .. attribute:: PARITIES + + A tuple of supported parity settings. + + .. attribute:: STOPBITS + + A tuple of supported stop bit settings. + + .. method:: readline(size=None, eol='\\n') + + :param size: Max number of bytes to read, ``None`` -> no limit. + :param eol: The end of line character. + + Read a line which is terminated with end-of-line (*eol*) character + (``\\n`` by default) or until timeout. + + .. method:: readlines(sizehint=None, eol='\\n') + + :param size: Ignored parameter. + :param eol: The end of line character. + + Read a list of lines, until timeout. *sizehint* is ignored and only + present for API compatibility with built-in File objects. + + .. method:: xreadlines(sizehint=None) + + Just calls :meth:`readlines` - here for compatibility. + + For compatibility with the :mod:`io` library are the following methods. + + .. method:: readable() + + :return: True + + .. versionadded:: 2.5 + + .. method:: writable() + + :return: True + + .. versionadded:: 2.5 + + .. method:: seekable() + + :return: False + + .. versionadded:: 2.5 + + .. method:: readinto(b) + + :param b: bytearray or array instance + :return: Number of byte read + + Read up to len(b) bytes into :class:`bytearray` *b* and return the + number of bytes read. + + .. versionadded:: 2.5 + + .. method:: getSettingsDict() + + :return: a dictionary with current port settings. + + Get a dictionary with port settings. This is useful to backup the + current settings so that a later point in time they can be restored + using :meth:`applySettingsDict`. + + Note that control lines (RTS/DTR) are part of the settings. + + .. versionadded:: 2.5 + + .. method:: applySettingsDict(d) + + :param d: a dictionary with port settings. + + Applies a dictionary that was created by :meth:`getSettingsDict`. Only + changes are applied and when a key is missing it means that the setting + stays unchanged. + + Note that control lines (RTS/DTR) are not changed. + + .. versionadded:: 2.5 + + +.. note:: + + For systems that provide the :mod:`io` library (Python 2.6 and newer), the + class :class:`Serial` will derive from :class:`io.RawIOBase`. For all + others from :class:`FileLike`. + +.. class:: FileLike + + An abstract file like class. It is used as base class for :class:`Serial`. + + This class implements :meth:`readline` and :meth:`readlines` based on read + and :meth:`writelines` based on write. This class is used to provide the + above functions for to Serial port objects. + + Note that when the serial port was opened with no timeout that + :meth:`readline` blocks until it sees a newline (or the specified size is + reached) and that :meth:`readlines` would never return and therefore + refuses to work (it raises an exception in this case)! + + .. method:: writelines(sequence) + + Write a list of strings to the port. + + + The following three methods are overridden in :class:`Serial`. + + .. method:: flush() + + Flush of file like objects. It's a no-op in this class, may be overridden. + + .. method:: read() + + Raises NotImplementedError, needs to be overridden by subclass. + + .. method:: write(data) + + Raises NotImplementedError, needs to be overridden by subclass. + + The following functions are implemented for compatibility with other + file-like objects, however serial ports are not seekable. + + + .. method:: seek(pos, whence=0) + + :exception IOError: always, as method is not supported on serial port + + .. versionadded:: 2.5 + + .. method:: tell() + + :exception IOError: always, as method is not supported on serial port + + .. versionadded:: 2.5 + + .. method:: truncate(self, n=None) + + :exception IOError: always, as method is not supported on serial port + + .. versionadded:: 2.5 + + .. method:: isatty() + + :exception IOError: always, as method is not supported on serial port + + .. versionadded:: 2.5 + + To be able to use the file like object as iterator for e.g. + ``for line in Serial(0): ...`` usage: + + .. method:: next() + + Return the next line by calling :meth:`readline`. + + .. method:: __iter__() + + Returns self. + +:rfc:`2217` Network ports +------------------------- + +.. warning:: This implementation is currently in an experimental state. Use + at your own risk. + +.. class:: rfc2217.Serial + + This implements a :rfc:`2217` compatible client. Port names are URLs_ in the + form: ``rfc2217://:[/