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.
Methods¶
-
usb_vcp.any()¶ Return
Trueif any characters waiting, elseFalse.
-
usb_vcp.close()¶
-
usb_vcp.read([nbytes])¶
-
usb_vcp.readall()¶
-
usb_vcp.readline()¶
-
usb_vcp.recv(data, *, timeout=5000)¶ Receive data on the bus:
datacan be an integer, which is the number of bytes to receive, or a mutable buffer, which will be filled with received bytes.timeoutis the timeout in milliseconds to wait for the receive.
Return value: if
datais an integer then a new buffer of the bytes received, otherwise the number of bytes read intodatais returned.
-
usb_vcp.send(data, *, timeout=5000)¶ Send data over the USB VCP:
datais the data to send (an integer to send, or a buffer object).timeoutis the timeout in milliseconds to wait for the send.
Return value: number of bytes sent.
-
usb_vcp.write(buf)¶