Merge pull request #342 from mghicho/buffer_size_fixed
Fixed the docstring for the set_buffer_size function.
diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst
index 2045244..d9dcb32 100644
--- a/documentation/pyserial_api.rst
+++ b/documentation/pyserial_api.rst
@@ -157,6 +157,22 @@
Returns an instance of :class:`bytes` when available (Python 2.6
and newer) and :class:`str` otherwise.
+ .. method:: read_until(expected=LF, size=None)
+
+ :param expected: The byte string to search for.
+ :param size: Number of bytes to read.
+ :return: Bytes read from the port.
+ :rtype: bytes
+
+ Read until an expected sequence is found ('\\n' by default), the size
+ is exceeded or until timeout occurs. If a timeout is set it may
+ return less characters as requested. With no timeout it will block
+ until the requested number of bytes is read.
+
+ .. versionchanged:: 2.5
+ Returns an instance of :class:`bytes` when available (Python 2.6
+ and newer) and :class:`str` otherwise.
+
.. method:: write(data)
:param data: Data to send.
diff --git a/serial/serialutil.py b/serial/serialutil.py
index e847a6a..2cce816 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -649,19 +649,19 @@
"""
return self.read(self.in_waiting)
- def read_until(self, terminator=LF, size=None):
+ def read_until(self, expected=LF, size=None):
"""\
- Read until a termination sequence is found ('\n' by default), the size
+ Read until an expected sequence is found ('\n' by default), the size
is exceeded or until timeout occurs.
"""
- lenterm = len(terminator)
+ lenterm = len(expected)
line = bytearray()
timeout = Timeout(self._timeout)
while True:
c = self.read(1)
if c:
line += c
- if line[-lenterm:] == terminator:
+ if line[-lenterm:] == expected:
break
if size is not None and len(line) >= size:
break
diff --git a/serial/tools/list_ports_common.py b/serial/tools/list_ports_common.py
index 8a1b625..617f3dc 100644
--- a/serial/tools/list_ports_common.py
+++ b/serial/tools/list_ports_common.py
@@ -77,6 +77,9 @@
def __eq__(self, other):
return isinstance(other, ListPortInfo) and self.device == other.device
+ def __hash__(self):
+ return hash(self.device)
+
def __lt__(self, other):
if not isinstance(other, ListPortInfo):
raise TypeError('unorderable types: {}() and {}()'.format(