If usb.UsbPresent(1) = usb.USB_NONE Then
Log("Msgbox - no device")
Msgbox("No USB device or accessory detected!", "Error")
Log("Msgbox - returned")
Return
End If
Log("Checking permission")
If (usb.HasPermission(1)) Then
'Msgbox(usb.DeviceInfo(1), "Device Information")
Dim dev As Int
dev = usb.Open(115200, 1)
If dev <> usb.USB_NONE Then
Log("Connected successfully!")
AStreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "Astreams")
Else
Log("Error opening USB port")
End If
Else
usb.RequestPermission(1)
End If