|
40 | 40 | //|
|
41 | 41 | //| def __init__(self) -> None:
|
42 | 42 | //| """You cannot create an instance of `usb_cdc.Serial`.
|
43 |
| -//| |
44 |
| -//| Serial objects are pre-constructed for each CDC device in the USB |
45 |
| -//| descriptor and added to the ``usb_cdc.ports`` tuple.""" |
| 43 | +//| The available instances are in the ``usb_cdc.serials`` tuple.""" |
46 | 44 | //| ...
|
47 | 45 | //|
|
48 |
| - |
49 | 46 | //| def read(self, size: int = 1) -> bytes:
|
50 | 47 | //| """Read at most ``size`` bytes. If ``size`` exceeds the internal buffer size
|
51 | 48 | //| only the bytes in the buffer will be read. If `timeout` is > 0 or ``None``,
|
|
64 | 61 | //| :rtype: bytes"""
|
65 | 62 | //| ...
|
66 | 63 | //|
|
| 64 | +//| def readline(self, size: int = -1) -> Optional[bytes]: |
| 65 | +//| r"""Read a line ending in a newline character ("\\n"), including the newline. |
| 66 | +//| Return everything readable if no newline is found and ``timeout`` is 0. |
| 67 | +//| Return ``None`` in case of error. |
| 68 | +//| |
| 69 | +//| This is a binary stream: the newline character "\\n" cannot be changed. |
| 70 | +//| If the host computer transmits "\\r" it will also be included as part of the line. |
| 71 | +//| |
| 72 | +//| :param int size: maximum number of characters to read. ``-1`` means as many as possible. |
| 73 | +//| :return: the line read |
| 74 | +//| :rtype: bytes or None""" |
| 75 | +//| ... |
| 76 | +//| |
| 77 | +//| def readlines(self) -> List[Optional[bytes]]: |
| 78 | +//| """Read multiple lines as a list, using `readline()`. |
| 79 | +//| |
| 80 | +//| .. warning:: If ``timeout`` is ``None``, |
| 81 | +//| `readlines()` will never return, because there is no way to indicate end of stream. |
| 82 | +//| |
| 83 | +//| :return: a list of the line read |
| 84 | +//| :rtype: list""" |
| 85 | +//| ... |
| 86 | +//| |
67 | 87 | //| def write(self, buf: ReadableBuffer) -> int:
|
68 | 88 | //| """Write as many bytes as possible from the buffer of bytes.
|
69 | 89 | //|
|
@@ -124,7 +144,12 @@ STATIC mp_uint_t usb_cdc_serial_ioctl_stream(mp_obj_t self_in, mp_uint_t request
|
124 | 144 | }
|
125 | 145 |
|
126 | 146 | //| connected: bool
|
127 |
| -//| """True if this Serial is connected to a host. (read-only)""" |
| 147 | +//| """True if this Serial is connected to a host. (read-only) |
| 148 | +//| |
| 149 | +//| .. note:: The host is considered to be connected if it is asserting DTR (Data Terminal Ready). |
| 150 | +//| Most terminal programs and ``pyserial`` assert DTR when opening a serial connection. |
| 151 | +//| However, the C# ``SerialPort`` API does not. You must set ``SerialPort.DtrEnable``. |
| 152 | +//| """ |
128 | 153 | //|
|
129 | 154 | STATIC mp_obj_t usb_cdc_serial_get_connected(mp_obj_t self_in) {
|
130 | 155 | usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
|
0 commit comments