summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-07-23 02:29:27 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-07-23 02:29:27 +0000
commitbb5c3c59043cad4063f5c26b7b427d8cfd7408d9 (patch)
treebd618e6561008247f11366ab8dec89604f43664b
parent6d1e9d18533cc3f71ce7d6fce21adb2342d68f7a (diff)
downloadpyserial-git-bb5c3c59043cad4063f5c26b7b427d8cfd7408d9.tar.gz
- doc updates
- one more example
-rw-r--r--documentation/appendix.rst72
-rw-r--r--documentation/examples.rst53
-rw-r--r--documentation/pyserial_api.rst48
3 files changed, 121 insertions, 52 deletions
diff --git a/documentation/appendix.rst b/documentation/appendix.rst
index 3a4a766..001c6e5 100644
--- a/documentation/appendix.rst
+++ b/documentation/appendix.rst
@@ -2,6 +2,13 @@
Appendix
==========
+Related software
+================
+
+com0com - http://com0com.sourceforge.net/
+ Provides virtual serial ports for Windows.
+
+
License
=======
@@ -17,48 +24,45 @@ the author when you use and/or modify it is welcome.
*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
+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
+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.
+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.
+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.
+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.
+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/examples.rst b/documentation/examples.rst
index 7b8b826..e0181bb 100644
--- a/documentation/examples.rst
+++ b/documentation/examples.rst
@@ -151,6 +151,51 @@ tcp_serial_redirect.py_
.. _tcp_serial_redirect.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/tcp_serial_redirect.py
+Multi-port TCP/IP - serial bridge
+=================================
+This example implements a TCP/IP to serial port service that works with
+multiple ports at once. It uses select, no threads, and runs on POSIX systems
+only.
+
+- Check existence of ``/tty/USB0...9``.
+- Ports are periodically checked using ``os.path.exists``.
+- Send Zeroconfig announcements when port appears or disappears (uses
+ python-avahi and dbus).
+- Single process for all ports (not per port).
+- All published services are kept in a dictionary that maps device->publisher
+ object.
+- A delay of 5 seconds slows down the poll loop to a reasonable period.
+- The script implements a daemon that logs to the syslog, unless specified
+ otherwise on the command line.
+
+
+Requirements
+------------
+- python (>2.4)
+- python-avahi
+- python-dbus
+- python-serial
+
+
+Installation
+------------
+- 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.
+
+
+port_publisher.py_
+ Multi-port TCP/IP-serial converter 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
@@ -219,12 +264,12 @@ need a loop back connector. The scripts itself contain more information.
test.py_
Basic tests.
-test_high_load.py_
- Tests involving sending a lot of data.
-
test_advanced.py_
Test more advanced features.
+test_high_load.py_
+ Tests involving sending a lot of data.
+
.. _test.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test.py
-.. _test_high_load.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test_high_load.py
.. _test_advanced.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test_advanced.py
+.. _test_high_load.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test_high_load.py
diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst
index 622e214..9df35c6 100644
--- a/documentation/pyserial_api.rst
+++ b/documentation/pyserial_api.rst
@@ -45,11 +45,11 @@ Classes
- Device name: depending on operating system. e.g. ``/dev/ttyUSB0``
on GNU/Linux or ``COM3`` on Windows.
- Possible values for the parameter ``timeout``::
+ 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)
+ - ``timeout = None``: wait forever
+ - ``timeout = 0``: non-blocking mode (return immediately on read)
+ - ``timeout = x``: set timeout to x seconds (float allowed)
.. method:: open()
@@ -70,13 +70,18 @@ Classes
.. method:: read(size=1)
- 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.
+ :param size: Number of bytes to read.
+ :return: Bytes read from the port.
- .. method:: write(s)
+ 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.
- Write the string `s` to the port.
+ .. method:: write(data)
+
+ :param data: Data to send.
+
+ Write the string ``data`` to the port.
.. method:: flush():
@@ -94,35 +99,51 @@ Classes
.. 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:
@@ -199,21 +220,20 @@ Classes
.. method:: fileno()
:platform: Unix
+ :return: File descriptor.
- Return file descriptor number.
-
+ 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:: FileLike
- .. method:: readline()
-
An abstract file like class. It is used as base class for :class:`Serial`.
This class implements readline and readlines based on read and
@@ -258,7 +278,7 @@ Classes
Raises NotImplementedError, needs to be overridden by subclass.
- .. method:: write()
+ .. method:: write(data)
Raises NotImplementedError, needs to be overridden by subclass.