This function returns the state of any USB connection. UsbGetState(n) is mainly used to determine if the USB connection was made successfully and if connection was lost after a write operation.

The following values are returned by this function:

0 - Connection closed.
1 - Connection open.
2 - Connection failed.
3 - Connection lost.

States 1 and 2 occur directly after an USBOpen command and require a USBClose to clear. State 3 may occur after a USBWrite command.

USB Serial Communication

Become a Patron