diff options
author | Damien George <damien.p.george@gmail.com> | 2015-05-13 20:42:12 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-13 20:42:12 +0100 |
commit | 0bfc57022dc6922d1f480ca58cc3d6e3b8c92288 (patch) | |
tree | 40fe26dd64da0f0c8c11dc6b6171cf11ee7418fc /docs/library | |
parent | 1511dd4f84da036a738e217420d2b1685b5eb823 (diff) | |
download | micropython-0bfc57022dc6922d1f480ca58cc3d6e3b8c92288.tar.gz micropython-0bfc57022dc6922d1f480ca58cc3d6e3b8c92288.zip |
docs: Document USB_VCP file-like methods.
Diffstat (limited to 'docs/library')
-rw-r--r-- | docs/library/pyb.USB_VCP.rst | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/docs/library/pyb.USB_VCP.rst b/docs/library/pyb.USB_VCP.rst index be1316432c..07122bed3c 100644 --- a/docs/library/pyb.USB_VCP.rst +++ b/docs/library/pyb.USB_VCP.rst @@ -36,15 +36,49 @@ Methods .. method:: usb_vcp.close() + This method does nothing. It exists so the USB_VCP object can act as + a file. .. method:: usb_vcp.read([nbytes]) + Read at most ``nbytes`` from the serial device and return them as a + bytes object. If ``nbytes`` is not specified then the method acts as + ``readall()``. .. method:: usb_vcp.readall() + Read all available bytes from the serial device and return them as + a bytes object. + +.. method:: usb_vcp.readinto(buf, [maxlen]) + + Read bytes from the serial device and store them into ``buf``, which + should be a buffer-like object. At most ``len(buf)`` bytes are read. + If ``maxlen`` is given and then at most ``min(maxlen, len(buf))`` bytes + are read. + + Returns the number of bytes read and stored into ``buf``. .. method:: usb_vcp.readline() + Read a whole line from the serial device. + + Returns a bytes object containing the data, including the trailing + newline character. + +.. method:: usb_vcp.readlines() + + Read as much data as possible from the serial device, breaking it into + lines. + + Returns a list of bytes objects, each object being one of the lines. + Each line will include the newline character. + +.. method:: usb_vcp.write(buf) + + Write the bytes from ``buf`` to the serial device. + + Returns the number of bytes written. .. method:: usb_vcp.recv(data, \*, timeout=5000) @@ -65,6 +99,3 @@ Methods - ``timeout`` is the timeout in milliseconds to wait for the send. Return value: number of bytes sent. - -.. method:: usb_vcp.write(buf) - |