diff options
-rw-r--r-- | CHANGES.txt | 13 | ||||
-rw-r--r-- | examples/tcp_serial_redirect.py | 2 | ||||
-rw-r--r-- | serial/serialposix.py | 17 | ||||
-rw-r--r-- | serial/serialwin32.py | 6 |
4 files changed, 29 insertions, 9 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 5163aa9..c08852f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -243,3 +243,16 @@ New Features: Sugested by Bernhard Bender - ``sendBreak()`` accepts a ``duration`` argument. Default duration increased. + +Bugfixes: + +- [Bug 1451535] TCP/serial redirect example "--help" + +Bugfixes (posix): + +- [Bug 1554183] setRTS/setDTR refrence to nonexisting local "on" +- [Bug 1513653] file descriptor not closed when exception is thrown + +Bugfixes (win32): + +- [Bug 1520357] Handle leak diff --git a/examples/tcp_serial_redirect.py b/examples/tcp_serial_redirect.py index c4c8aa9..0777af2 100644 --- a/examples/tcp_serial_redirect.py +++ b/examples/tcp_serial_redirect.py @@ -101,7 +101,7 @@ if __name__ == '__main__': localport = 7777 for o, a in opts: if o in ("-h", "--help"): #help text - usage() + print __doc__ # XXX is optimzed away with python -o ... sys.exit() elif o in ("-p", "--port"): #specified port try: diff --git a/serial/serialposix.py b/serial/serialposix.py index d0e23bd..f9353c9 100644 --- a/serial/serialposix.py +++ b/serial/serialposix.py @@ -13,7 +13,7 @@ import sys, os, fcntl, termios, struct, select, errno from serialutil import * -VERSION = "$Revision: 1.31 $".split()[1] #extract CVS version +VERSION = "$Revision: 1.32 $".split()[1] #extract CVS version #Do check the Python version as some constants have moved. if (sys.hexversion < 0x020100f0): @@ -141,13 +141,18 @@ class Serial(SerialBase): raise SerialException("could not open port %s: %s" % (self._port, msg)) #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0) #set blocking - self._reconfigurePort() - self._isOpen = True + try: + self._reconfigurePort() + except: + os.close(self.fd) + self.fd = None + else: + self._isOpen = True #~ self.flushInput() def _reconfigurePort(self): - """Set commuication parameters on opened port.""" + """Set communication parameters on opened port.""" if self.fd is None: raise SerialException("Can only operate on a valid port handle") @@ -330,7 +335,7 @@ class Serial(SerialBase): def setRTS(self, level=1): """Set terminal status line: Request To Send""" if self.fd is None: raise portNotOpenError - if on: + if level: fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_RTS_str) else: fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_RTS_str) @@ -338,7 +343,7 @@ class Serial(SerialBase): def setDTR(self, level=1): """Set terminal status line: Data Terminal Ready""" if self.fd is None: raise portNotOpenError - if on: + if level: fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str) else: fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str) diff --git a/serial/serialwin32.py b/serial/serialwin32.py index 7e95c80..0a9d526 100644 --- a/serial/serialwin32.py +++ b/serial/serialwin32.py @@ -11,7 +11,7 @@ import win32event # We use events and the WaitFor[Single|Multiple]Objects functi import win32con # constants. from serialutil import * -VERSION = "$Revision: 1.33 $".split()[1] #extract CVS version +VERSION = "$Revision: 1.34 $".split()[1] #extract CVS version #from winbase.h. these should realy be in win32con MS_CTS_ON = 16 @@ -174,6 +174,8 @@ class Serial(SerialBase): win32file.SetCommTimeouts(self.hComPort, self._orgTimeouts) #Close COM-Port: win32file.CloseHandle(self.hComPort) + win32file.CloseHandle(self._overlappedRead.hEvent) + win32file.CloseHandle(self._overlappedWrite.hEvent) self.hComPort = None self._isOpen = False @@ -215,7 +217,7 @@ class Serial(SerialBase): """Output the given string over the serial port.""" if not self.hComPort: raise portNotOpenError #print repr(s), - if s: + if data: #~ win32event.ResetEvent(self._overlappedWrite.hEvent) err, n = win32file.WriteFile(self.hComPort, data, self._overlappedWrite) if err: #will be ERROR_IO_PENDING: |