From a6cb7d7069351264096432d12f8b2ab1014a5140 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 7 Mar 2021 15:34:07 -0500 Subject: Document readline() and readlines() --- shared-bindings/usb_cdc/Serial.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 4913ac85a..0f2f76a17 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -45,7 +45,6 @@ //| descriptor and are included in the ``usb_cdc.serials`` tuple.""" //| ... //| - //| def read(self, size: int = 1) -> bytes: //| """Read at most ``size`` bytes. If ``size`` exceeds the internal buffer size //| only the bytes in the buffer will be read. If `timeout` is > 0 or ``None``, @@ -64,6 +63,28 @@ //| :rtype: bytes""" //| ... //| +//| def readline(self, size=-1) -> Optional[bytes]: +//| r"""Read a line, ending in a newline character ("\\n"), or +//| return everything readable if no newline is found and ``timeout`` is 0. +//| Return ``None`` in case of error. +//| +//| This is a binary stream: the newline character cannot be changed. +//| +//| :param int size: maximum number of characters to read. ``-1`` means as many as possible. +//| :return: the line read +//| :rtype: bytes or None""" +//| ... +//| +//| def readlines(self) -> list: +//| """Read multiple lines as a list, using `readline()` +//| +//| .. warning:: If ``timeout`` is ``None``, +//| `readlines()` will never return, because there is no way to indicate end of stream. +//| +//| :return: a list of the line read +//| :rtype: list""" +//| ... +//| //| def write(self, buf: ReadableBuffer) -> int: //| """Write as many bytes as possible from the buffer of bytes. //| -- cgit v1.2.3