summaryrefslogtreecommitdiff
path: root/documentation/shortintro.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/shortintro.rst')
-rw-r--r--documentation/shortintro.rst17
1 files changed, 14 insertions, 3 deletions
diff --git a/documentation/shortintro.rst b/documentation/shortintro.rst
index b9230e3..11b2ea0 100644
--- a/documentation/shortintro.rst
+++ b/documentation/shortintro.rst
@@ -53,13 +53,24 @@ Also supported with :ref:`context manager <context-manager>`::
ser.write(b'hello')
+.. _shortintro_readline:
+
Readline
========
+:meth:`readline` reads up to one line, including the `\n` at the end.
Be careful when using :meth:`readline`. Do specify a timeout when opening the
serial port otherwise it could block forever if no newline character is
-received. Also note that :meth:`readlines` only works with a timeout.
-:meth:`readlines` depends on having a timeout and interprets that as EOF (end
-of file). It raises an exception if the port is not opened correctly.
+received. If the `\n` is missing in the return value, it returned on timeout.
+
+:meth:`readlines` tries to read "all" lines which is not well defined for a
+serial port that is still open. Therefore :meth:`readlines` depends on having
+a timeout on the port and interprets that as EOF (end of file). It raises an
+exception if the port is not opened correctly. The returned list of lines do
+not include the `\n`.
+
+Both functions call :meth:`read` to get their data and the serial port timeout
+is acting on this function. Therefore the effective timeout, especially for
+:meth:`readlines`, can be much larger.
Do also have a look at the example files in the examples directory in the
source distribution or online.