summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2003-10-05 12:28:13 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2003-10-05 12:28:13 +0000
commita30a8a052bf77ee8f8d07a7feea89dc5446fe48e (patch)
tree42c8d10c2e2c7c0d28ae5698d7f405d009d05b12
parent4b6cfd5df915144a1227a302b862614fe337c4c8 (diff)
downloadpyserial-git-a30a8a052bf77ee8f8d07a7feea89dc5446fe48e.tar.gz
applied patches and feature requests
-rw-r--r--pyserial/serial/serialposix.py31
-rw-r--r--pyserial/serial/serialwin32.py12
2 files changed, 30 insertions, 13 deletions
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index 1d1c85e..9340f97 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/serial/serialposix.py
@@ -13,7 +13,7 @@
import sys, os, fcntl, termios, struct, select
from serialutil import *
-VERSION = "$Revision: 1.17 $".split()[1] #extract CVS version
+VERSION = "$Revision: 1.18 $".split()[1] #extract CVS version
#Do check the Python version as some constants have moved.
if (sys.hexversion < 0x020100f0):
@@ -289,6 +289,11 @@ class Serial(SerialBase):
d = d[n:]
t = t - n
+ def flush(self):
+ """Flush of file like objects. In this case, wait until all data
+ is written."""
+ self.drainOutput()
+
def flushInput(self):
"""Clear input buffer, discarding all that is in the buffer."""
if not self.fd:
@@ -336,17 +341,6 @@ class Serial(SerialBase):
s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
return struct.unpack('I',s)[0] & TIOCM_DSR != 0
- def drainOutput(self):
- """internal - not portable!"""
- if not self.fd: raise portNotOpenError
- termios.tcdrain(self.fd)
-
- def nonblocking(self):
- """internal - not portable!"""
- if not self.fd:
- raise portNotOpenError
- fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK)
-
def getRI(self):
"""Read terminal status line: Ring Indicator"""
if not self.fd: raise portNotOpenError
@@ -359,6 +353,19 @@ class Serial(SerialBase):
s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
return struct.unpack('I',s)[0] & TIOCM_CD != 0
+ # - - platform specific - - - -
+
+ def drainOutput(self):
+ """internal - not portable!"""
+ if not self.fd: raise portNotOpenError
+ termios.tcdrain(self.fd)
+
+ def nonblocking(self):
+ """internal - not portable!"""
+ if not self.fd:
+ raise portNotOpenError
+ fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK)
+
if __name__ == '__main__':
s = Serial(0,
diff --git a/pyserial/serial/serialwin32.py b/pyserial/serial/serialwin32.py
index ecbe2d7..35245a7 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.26 $".split()[1] #extract CVS version
+VERSION = "$Revision: 1.27 $".split()[1] #extract CVS version
#from winbase.h. these should realy be in win32con
MS_CTS_ON = 16
@@ -260,6 +260,16 @@ class Serial(SerialBase):
if not self.hComPort: raise portNotOpenError
return MS_RLSD_ON & win32file.GetCommModemStatus(self.hComPort) != 0
+ # - - platform specific - - - -
+
+ def setXON(self, level=True):
+ """Platform specific - set flow state."""
+ if not self.hComPort: raise portNotOpenError
+ if level:
+ win32file.EscapeCommFunction(self.hComPort, win32file.SETXON)
+ else:
+ win32file.EscapeCommFunction(self.hComPort, win32file.SETXOFF)
+
#Nur Testfunktion!!
if __name__ == '__main__':
print __name__