blob: eaba1e8db1cd0c4049f2381094012443a2d8a87f [file] [log] [blame]
cliechti22978142009-07-21 01:58:11 +00001==========
2 Appendix
3==========
4
cliechti86844e82009-08-12 00:05:33 +00005How To
6======
7
8Enable :rfc:`2217` in programs using pySerial.
9 Patch the code where the :class:`serial.Serial` is instantiated. Replace
10 it with::
11
12 try:
13 s = serial.serial_for_url(...)
14 except AttributeError:
15 s = serial.Serial(...)
16
17 Assuming the application already stores port names as strings that's all
18 that is required. The user just needs a way to change the port setting of
19 your application to an ``rfc2217://`` :ref:`URL <URLs>` (e.g. by editing a
20 configuration file, GUI dialog etc.).
21
22 Please note that this enables all :ref:`URL <URLs>` types supported by
23 pySerial and that those involving the network are unencrypted and not
24 protected against eavesdropping.
25
26Test your setup.
27 Is the device not working as expected? Maybe it's time to check the
28 connection before proceeding. :ref:`miniterm` from the :ref:`examples`
29 can be used to open the serial port and do some basic tests.
30
31 To test cables, connecting RX to TX (loop back) and typing some characters
32 in :ref:`miniterm` is a simple test. When the characters are displayed
33 on the screen, then at least RX and TX work (they still could be swapped
34 though).
35
36
cliechtia517f4c2011-03-19 00:57:11 +000037FAQ
38===
cliechti4a63d6b2011-03-19 02:57:51 +000039Example works in :ref:`miniterm` but not in script.
cliechtia517f4c2011-03-19 00:57:11 +000040 The RTS and DTR lines are switched when the port is opened. This may cause
41 some processing or reset on the connected device. In such a cases an
42 immediately following call to :meth:`write` may not be received by the
43 device.
44
45 A delay after opening the port, before the first :meth:`write`, is
46 recommended in this situation. E.g. a ``time.sleep(1)``
47
48
cliechti4a63d6b2011-03-19 02:57:51 +000049Application works when .py file is run, but fails when packaged (py2exe etc.)
50 py2exe and similar packaging programs scan the sources for import
51 statements and create a list of modules that they package. pySerial may
52 create two issues with that:
53
54 - implementations for other modules are found. On Windows, it's safe to
55 exclude 'serialposix', 'serialjava' and 'serialcli' as these are not
56 used.
57
58 - :func:`serial.serial_for_url` does a dynamic lookup of protocol handlers
59 at runtime. If this function is used, the desired handlers have to be
60 included manually (e.g. 'serial.urlhandler.protocol_socket',
61 'serial.urlhandler.protocol_rfc2217', etc.). This can be done either with
62 the "includes" option in ``setup.py`` or by a dummy import in one of the
63 packaged modules.
64
65User supplied URL handlers
66 :func:`serial.serial_for_url` can be used to access "virtual" serial ports
67 identified by an :ref:`URL <URLs>` scheme. E.g. for the :rfc:`2217`:
68 ``rfc2217:://``.
69
70 Custom :ref:`URL <URLs>` handlers can be added by extending the module
71 search path in :data:`serial.protocol_handler_packages`. This is possible
72 starting from pySerial V2.6.
73
74
cliechtibb5c3c52009-07-23 02:29:27 +000075Related software
76================
77
78com0com - http://com0com.sourceforge.net/
79 Provides virtual serial ports for Windows.
80
81
cliechti22978142009-07-21 01:58:11 +000082License
83=======
84
cliechti4cb94662013-10-17 03:17:50 +000085Copyright (C) 2001-2013 Chris Liechti <cliechti(at)gmx.net>;
cliechti22978142009-07-21 01:58:11 +000086All Rights Reserved.
87
cliechti5134aab2009-07-21 19:47:59 +000088This is the Python license. In short, you can use this product in commercial
89and non-commercial applications, modify it, redistribute it. A notification to
90the author when you use and/or modify it is welcome.
cliechti22978142009-07-21 01:58:11 +000091
92
cliechti5134aab2009-07-21 19:47:59 +000093**TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE**
cliechti22978142009-07-21 01:58:11 +000094
cliechti5134aab2009-07-21 19:47:59 +000095*LICENSE AGREEMENT*
cliechti22978142009-07-21 01:58:11 +000096
cliechtibb5c3c52009-07-23 02:29:27 +0000971. This LICENSE AGREEMENT is between the copyright holder of this product, and
98 the Individual or Organization ("Licensee") accessing and otherwise using
99 this product in source or binary form and its associated documentation.
cliechti22978142009-07-21 01:58:11 +0000100
cliechtibb5c3c52009-07-23 02:29:27 +00001012. Subject to the terms and conditions of this License Agreement, the copyright
102 holder hereby grants Licensee a nonexclusive, royalty-free, world-wide
103 license to reproduce, analyze, test, perform and/or display publicly,
104 prepare derivative works, distribute, and otherwise use this product alone
105 or in any derivative version, provided, however, that copyright holders
106 License Agreement and copyright holders notice of copyright are retained in
107 this product alone or in any derivative version prepared by Licensee.
cliechti22978142009-07-21 01:58:11 +0000108
cliechtibb5c3c52009-07-23 02:29:27 +00001093. In the event Licensee prepares a derivative work that is based on or
110 incorporates this product or any part thereof, and wants to make the
cliechti86e87872009-07-21 13:32:45 +0000111 derivative work available to others as provided herein, then Licensee hereby
112 agrees to include in any such work a brief summary of the changes made to
113 this product.
cliechti22978142009-07-21 01:58:11 +0000114
cliechtibb5c3c52009-07-23 02:29:27 +00001154. The copyright holder is making this product available to Licensee on an "AS
116 IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS OR WARRANTIES,
117 EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, THE COPYRIGHT
118 HOLDER MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF
cliechti86e87872009-07-21 13:32:45 +0000119 MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
120 THIS PRODUCT WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
cliechti22978142009-07-21 01:58:11 +0000121
cliechtibb5c3c52009-07-23 02:29:27 +00001225. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF
123 THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
124 AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING THIS PRODUCT, OR
125 ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
cliechti22978142009-07-21 01:58:11 +0000126
cliechtibb5c3c52009-07-23 02:29:27 +00001276. This License Agreement will automatically terminate upon a material breach
128 of its terms and conditions.
cliechti22978142009-07-21 01:58:11 +0000129
cliechtibb5c3c52009-07-23 02:29:27 +00001307. Nothing in this License Agreement shall be deemed to create any relationship
131 of agency, partnership, or joint venture between the copyright holder and
132 Licensee. This License Agreement does not grant permission to use trademarks
133 or trade names from the copyright holder in a trademark sense to endorse or
134 promote products or services of Licensee, or any third party.
cliechti22978142009-07-21 01:58:11 +0000135
cliechtibb5c3c52009-07-23 02:29:27 +00001368. By copying, installing or otherwise using this product, Licensee agrees to
137 be bound by the terms and conditions of this License Agreement.
cliechti22978142009-07-21 01:58:11 +0000138