summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2011-12-28 22:10:00 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2011-12-28 22:10:00 +0000
commit8252ce2a8a2de245eab529d6cc7f9904bb10b2a6 (patch)
treed419f2e1ea4ae4358644180b1fb2e19605d01b9f
parent7bf24a25e8d754bcbd5f1946d5c4b36db7945ea6 (diff)
downloadpyserial-8252ce2a8a2de245eab529d6cc7f9904bb10b2a6.tar.gz
rename flowControl to setXON to be similar to the win32 implementation and add flowControlOut, doc updates
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@444 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r--documentation/pyserial_api.rst20
-rw-r--r--serial/serialposix.py30
-rw-r--r--serial/serialwin32.py6
3 files changed, 47 insertions, 9 deletions
diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst
index f0a0cb1..809841e 100644
--- a/documentation/pyserial_api.rst
+++ b/documentation/pyserial_api.rst
@@ -388,9 +388,27 @@ Native ports
.. method:: setXON(level=True)
:platform: Windows
+ :platform: Posix
:param level: Set flow control state.
- Set software flow control state.
+ Manually control flow - when software flow control is enabled.
+
+ This will send XON (true) and XOFF (false) to the other device.
+
+ .. versionchanged:: 2.7 (renamed on Posix, function was called ``flowControl``)
+
+ .. method:: flowControlOut(enable)
+
+ :platform: Posix
+ :param enable: Set flow control state.
+
+ Manually control flow of outgoing data - when hardware or software flow
+ control is enabled.
+
+ Sending will be suspended when called with ``False`` and enabled when
+ called with ``True``.
+
+ .. versionadded:: 2.7 (Posix support added)
.. note::
diff --git a/serial/serialposix.py b/serial/serialposix.py
index eccd782..4438a46 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -581,20 +581,36 @@ class PosixSerial(SerialBase):
fcntl.fcntl(self.fd, FCNTL.F_SETFL, os.O_NONBLOCK)
def fileno(self):
- """For easier use of the serial port instance with select.
- WARNING: this function is not portable to different platforms!"""
+ """\
+ For easier use of the serial port instance with select.
+ WARNING: this function is not portable to different platforms!
+ """
if not self._isOpen: raise portNotOpenError
return self.fd
- def flowControl(self, enable):
- """manually control flow - when hardware or software flow control is
- enabled"""
- if not self._isOpen: raise portNotOpenError
- if enable:
+ def setXON(self, level=True):
+ """\
+ Manually control flow - when software flow control is enabled.
+ This will send XON (true) and XOFF (false) to the other device.
+ WARNING: this function is not portable to different platforms!
+ """
+ if not self.hComPort: raise portNotOpenError
termios.tcflow(self.fd, TERMIOS.TCION)
else:
termios.tcflow(self.fd, TERMIOS.TCIOFF)
+ def flowControlOut(self, enable):
+ """\
+ Manually control flow of outgoing data - when hardware or software flow
+ control is enabled.
+ WARNING: this function is not portable to different platforms!
+ """
+ if not self._isOpen: raise portNotOpenError
+ if enable:
+ termios.tcflow(self.fd, TERMIOS.TCOON)
+ else:
+ termios.tcflow(self.fd, TERMIOS.TCOOFF)
+
# assemble Serial class with the platform specifc implementation and the base
# for file-like behavior. for Python 2.6 and newer, that provide the new I/O
diff --git a/serial/serialwin32.py b/serial/serialwin32.py
index bb1a15f..9a62fa0 100644
--- a/serial/serialwin32.py
+++ b/serial/serialwin32.py
@@ -356,7 +356,11 @@ class Win32Serial(SerialBase):
win32.SetupComm(self.hComPort, rx_size, tx_size)
def setXON(self, level=True):
- """Platform specific - set flow state."""
+ """\
+ Manually control flow - when software flow control is enabled.
+ This will send XON (true) and XOFF (false) to the other device.
+ WARNING: this function is not portable to different platforms!
+ """
if not self.hComPort: raise portNotOpenError
if level:
win32.EscapeCommFunction(self.hComPort, win32.SETXON)