Sub btnOpen_Click
Dim device As UsbDevice
Dim usbInterface As UsbInterface
Dim usbconnection As UsbDeviceConnection
device = usbManager.GetDevices(1)
usbInterface = device.GetInterface(1)
usbManager.RequestPermission(device)
If (usbManager.HasPermission(device)) Then
MsgboxAsync(device.GetInterface(1),"Interface Number")
usbconnection = usbManager.OpenDevice(device,usbInterface,True)
usbconnection.StartListening("astreams")
Else
usbManager.RequestPermission(device)
End If
End Sub
Sub btnOpen2_Click
If usb.UsbPresent(1) = usb.USB_NONE Then
Log("Msgbox - no device")
MsgboxAsync("No USB device or accessory detected!", "Error")
Log("Msgbox - returned")
Return
End If
Log("Checking permission")
If (usb.HasPermission(1)) Then
MsgboxAsync(usb.DeviceInfo(1), "Device Information")
Dim dev As Int
dev = usb.Open(9600,1)
If dev <> usb.USB_NONE Then
Log("Connected successfully!")
btnOpen2.Enabled = False
btnClose2.Enabled = True
btnSend.Enabled= True
btnSend2.Enabled = True
astreams.Initialize(Me,"astreams",usb.GetInputStream,usb.GetOutputStream)
Else
Log("Error opening USB port")
End If
Else
usb.RequestPermission(1)
End If
End Sub