Newer
Older
TestStandRepository / Software / Arduino / libraries / pyserial-2.7 / documentation / appendix.rst
  1. ==========
  2. Appendix
  3. ==========
  4.  
  5. How To
  6. ======
  7.  
  8. Enable :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.  
  26. Test 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.  
  37. FAQ
  38. ===
  39. Example works in :ref:`miniterm` but not in script.
  40. 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.  
  49. Application 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.  
  65. User 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.  
  75. Related software
  76. ================
  77.  
  78. com0com - http://com0com.sourceforge.net/
  79. Provides virtual serial ports for Windows.
  80.  
  81.  
  82. License
  83. =======
  84.  
  85. Copyright (C) 2001-2013 Chris Liechti <cliechti(at)gmx.net>;
  86. All Rights Reserved.
  87.  
  88. This is the Python license. In short, you can use this product in commercial
  89. and non-commercial applications, modify it, redistribute it. A notification to
  90. the author when you use and/or modify it is welcome.
  91.  
  92.  
  93. **TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE**
  94.  
  95. *LICENSE AGREEMENT*
  96.  
  97. 1. 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.
  100.  
  101. 2. 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.
  108.  
  109. 3. 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
  111. 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.
  114.  
  115. 4. 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
  119. MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
  120. THIS PRODUCT WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
  121.  
  122. 5. 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.
  126.  
  127. 6. This License Agreement will automatically terminate upon a material breach
  128. of its terms and conditions.
  129.  
  130. 7. 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.
  135.  
  136. 8. By copying, installing or otherwise using this product, Licensee agrees to
  137. be bound by the terms and conditions of this License Agreement.
  138.