summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2010-07-21 01:12:22 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2010-07-21 01:12:22 +0000
commitf7488074d0bd72a59a61d45173845c861ec600a4 (patch)
treeeced49816f1cb1e3c55d4ab8dbd7ab2c3e478f38
parent962ed060d1cd4ac893ec405bc2dcad74d6033e84 (diff)
downloadpyserial-f7488074d0bd72a59a61d45173845c861ec600a4.tar.gz
- improved xreadlines (now a generator)
- version for release git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@366 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r--CHANGES.txt3
-rw-r--r--serial/__init__.py2
-rw-r--r--serial/serialutil.py14
3 files changed, 13 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 5b54653..6706f70 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -377,6 +377,9 @@ New Features:
setting) to ``False``. This means ``rtscts=True`` enables hardware flow
control on RTS/CTS but no longer also on DTR/DSR. This change mostly
affects Win32 as on other platforms, that setting was ignored anyway.
+- Improved xreadlines, it is now a generator function that yields lines as they
+ are received (previously it called readlines which would only return all
+ lines read after a read-timeout).
Bugfixes:
diff --git a/serial/__init__.py b/serial/__init__.py
index d46e717..2c49007 100644
--- a/serial/__init__.py
+++ b/serial/__init__.py
@@ -6,7 +6,7 @@
# (C) 2001-2010 Chris Liechti <cliechti@gmx.net>
# this is distributed under a free software license, see license.txt
-VERSION = '2.5-rc2'
+VERSION = '2.5'
import sys
diff --git a/serial/serialutil.py b/serial/serialutil.py
index a6a716d..7654fdf 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -440,7 +440,7 @@ class SerialBase(object):
def readline(self, size=None, eol='\n'):
"""read a line which is terminated with end-of-line (eol) character
- ('\n' by default) or until timeout"""
+ ('\n' by default) or until timeout."""
line = bytearray()
while 1:
c = self.read(1)
@@ -455,8 +455,8 @@ class SerialBase(object):
return bytes(line)
def readlines(self, sizehint=None, eol='\n'):
- """read a list of lines, until timeout
- sizehint is ignored"""
+ """read a list of lines, until timeout.
+ sizehint is ignored."""
if self.timeout is None:
raise ValueError("Serial port MUST have enabled timeout for this function!")
lines = []
@@ -471,8 +471,12 @@ class SerialBase(object):
return lines
def xreadlines(self, sizehint=None):
- """just call readlines - here for compatibility"""
- return self.readlines()
+ """Read lines, implemented as generator. It will raise StopIteration on
+ timeout (empty read). sizehint is ignored."""
+ while True:
+ line = self.readline()
+ if not line: break
+ yield line
# - - - - - - - - - - - - - - - - - - - - - - - -
# compatibility with io library