This command opens a USB serial device for communication.
The USB connection number to be opened. Up to 10 connections may be open at any time. The connection number identifies which USB device is being accessed. The connection number ranges from 1 to 10.
The name of the device to be opened as returned by UsbGetDevices$() or UsbGetFirstDevice$().
The data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates.
May be 5, 6, 7 or 8. Usually 8 bits are used.
1 = 1 stop bit, 2 = 2 stop bits, 3 = 1.5 stop bits. Usually set to 1 stop bit.
0 = None, 1 = Odd, 2 = Even, 3 = Mark, 4 = Space. Usually set to None.
This is an optional parameter which specifies the timeout for all read/write commands. If not specified it defaults to 10 seconds. For infinite timeout set this value to 0.
' Open a USB serial device.
device$ = UsbGetFirstDevice$()
UsbOpen 1, device$, 9600, 8, 1, 0
Print "State: "; UsbGetState(1)
Print "error: "; UsbGetError$(1)
if UsbGetState(1) <> 1 then
Print "Connection failed"
After a UsbOpen it is important to check if the open succeeded. All communications connections are subject to interruption at any time so check the UsbGetState(1) and UsbGetError$(n) after each USB command you execute.