diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2011-08-05 02:53:24 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2011-08-05 02:53:24 +0000 |
commit | 3da62c4274dac5f6bc426988b8033c1329b9acc3 (patch) | |
tree | 782d589739bb13ab75046b4344290c8e448eff44 | |
parent | e4a7cd2440527c01dce438492ff3af7ebfcbe14b (diff) | |
download | pyserial-3da62c4274dac5f6bc426988b8033c1329b9acc3.tar.gz |
implement patch 3054352 (with changes to the original patch)
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@406 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r-- | CHANGES.txt | 11 | ||||
-rw-r--r-- | serial/serialwin32.py | 23 | ||||
-rw-r--r-- | serial/win32.py | 1 |
3 files changed, 28 insertions, 7 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index a83f498..82c3605 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -411,14 +411,15 @@ New Features: Bugfixes: -- [SF 3093882] calling open() on an already open port now raises an exception -- [SF 3245627] connection-lost let rfc2217 hangs in closed loop +- [Bug 3093882] calling open() on an already open port now raises an exception +- [Bug 3245627] connection-lost let rfc2217 hangs in closed loop Bugfixes (posix): -- [SF 3316943] Avoid unneeded termios.tcsetattr calls in serialposix.py +- [Patch 3316943] Avoid unneeded termios.tcsetattr calls in serialposix.py Bugfixes (win32): -- [SF 3057499] writeTimeoutError when write Timeout is 0 -- [SF 3036175] Windows 98 Support fix +- [Bug 3057499] writeTimeoutError when write Timeout is 0 +- [Patch 3036175] Windows 98 Support fix +- [Patch 3054352] RTS automatic toggle, for RS485 functionality. diff --git a/serial/serialwin32.py b/serial/serialwin32.py index c510478..42aa0c4 100644 --- a/serial/serialwin32.py +++ b/serial/serialwin32.py @@ -3,7 +3,7 @@ # serial driver for win32 # see __init__.py # -# (C) 2001-2009 Chris Liechti <cliechti@gmx.net> +# (C) 2001-2011 Chris Liechti <cliechti@gmx.net> # this is distributed under a free software license, see license.txt # # Initial patch to use ctypes by Giovanni Bajo <rasky@develer.com> @@ -27,6 +27,7 @@ class Win32Serial(SerialBase): def __init__(self, *args, **kwargs): self.hComPort = None + self._rtsToggle = False SerialBase.__init__(self, *args, **kwargs) def open(self): @@ -159,13 +160,19 @@ class Win32Serial(SerialBase): # Char. w/ Parity-Err are replaced with 0xff (if fErrorChar is set to TRUE) if self._rtscts: comDCB.fRtsControl = win32.RTS_CONTROL_HANDSHAKE + elif self._rtsToggle: + comDCB.fRtsControl = win32.RTS_CONTROL_TOGGLE else: comDCB.fRtsControl = self._rtsState if self._dsrdtr: comDCB.fDtrControl = win32.DTR_CONTROL_HANDSHAKE else: comDCB.fDtrControl = self._dtrState - comDCB.fOutxCtsFlow = self._rtscts + + if self._rtsToggle: + comDCB.fOutxCtsFlow = 0 + else: + comDCB.fOutxCtsFlow = self._rtscts comDCB.fOutxDsrFlow = self._dsrdtr comDCB.fOutX = self._xonxoff comDCB.fInX = self._xonxoff @@ -356,6 +363,18 @@ class Win32Serial(SerialBase): raise SerialException('call to ClearCommError failed') return comstat.cbOutQue + # functions useful for RS-485 adapters + def setRtsToggle(self, rtsToggle): + """Change RTS toggle control setting.""" + self._rtsToggle = rtsToggle + if self._isOpen: self._reconfigurePort() + + def getRtsToggle(self): + """Get the current RTS toggle control setting.""" + return self._rtsToggle + + rtsToggle = property(getRtsToggle, setRtsToggle, doc="RTS toggle control setting") + # assemble Serial class with the platform specific implementation and the base # for file-like behavior. for Python 2.6 and newer, that provide the new I/O diff --git a/serial/win32.py b/serial/win32.py index ca6c635..0634c77 100644 --- a/serial/win32.py +++ b/serial/win32.py @@ -157,6 +157,7 @@ SPACEPARITY = 4 RTS_CONTROL_HANDSHAKE = 2 # Variable c_int RTS_CONTROL_DISABLE = 0 # Variable c_int RTS_CONTROL_ENABLE = 1 # Variable c_int +RTS_CONTROL_TOGGLE = 3 # Variable c_int SETRTS = 3 CLRRTS = 4 |