diff options
-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 |