summaryrefslogtreecommitdiffstatshomepage
path: root/docs/library/pyb.USB_VCP.rst
blob: 7330640728a9789c04cd94b5e786b3e0f47e2b99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class USB_VCP -- USB virtual comm port
======================================

The USB_VCP class allows creation of an object representing the USB
virtual comm port.  It can be used to read and write data over USB to
the connected host.


Constructors
------------

.. class:: pyb.USB_VCP()

   Create a new USB_VCP object.


Methods
-------

.. method:: usb_vcp.any()

   Return ``True`` if any characters waiting, else ``False``.

.. method:: usb_vcp.close()


.. method:: usb_vcp.read([nbytes])


.. method:: usb_vcp.readall()


.. method:: usb_vcp.readline()


.. method:: usb_vcp.recv(data, \*, timeout=5000)

   Receive data on the bus:
   
     - ``data`` can be an integer, which is the number of bytes to receive,
       or a mutable buffer, which will be filled with received bytes.
     - ``timeout`` is the timeout in milliseconds to wait for the receive.
   
   Return value: if ``data`` is an integer then a new buffer of the bytes received,
   otherwise the number of bytes read into ``data`` is returned.

.. method:: usb_vcp.send(data, \*, timeout=5000)

   Send data over the USB VCP:
   
     - ``data`` is the data to send (an integer to send, or a buffer object).
     - ``timeout`` is the timeout in milliseconds to wait for the send.
   
   Return value: number of bytes sent.

.. method:: usb_vcp.write(buf)