summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2006-10-20 00:09:07 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2006-10-20 00:09:07 +0000
commitb2f5fc8e5566f8309480567b1c9c7ca3445ccd53 (patch)
treec273a951248d493ddcb730f2ec039fd4c1fc6bc1
parent93db61bdd93c542ad1593016863e498e61927f94 (diff)
downloadpyserial-git-b2f5fc8e5566f8309480567b1c9c7ca3445ccd53.tar.gz
[Bug 1451535], [Bug 1554183], [Bug 1513653], [Bug 1520357]
-rw-r--r--pyserial/CHANGES.txt13
-rw-r--r--pyserial/examples/tcp_serial_redirect.py2
-rw-r--r--pyserial/serial/serialposix.py17
-rw-r--r--pyserial/serial/serialwin32.py6
4 files changed, 29 insertions, 9 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt
index 5163aa9..c08852f 100644
--- a/pyserial/CHANGES.txt
+++ b/pyserial/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/pyserial/examples/tcp_serial_redirect.py b/pyserial/examples/tcp_serial_redirect.py
index c4c8aa9..0777af2 100644
--- a/pyserial/examples/tcp_serial_redirect.py
+++ b/pyserial/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/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index d0e23bd..f9353c9 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/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/pyserial/serial/serialwin32.py b/pyserial/serial/serialwin32.py
index 7e95c80..0a9d526 100644
--- a/pyserial/serial/serialwin32.py
+++ b/pyserial/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: