Morning,
Can someone please help me out here - The code below will not find any usb devices. I'm trying to find an FTDI serial board, but even a pen drive is not detected.
Many thanks in advance.
Can someone please help me out here - The code below will not find any usb devices. I'm trying to find an FTDI serial board, but even a pen drive is not detected.
Many thanks in advance.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim usbserial As felUsbSerial
Dim manager As UsbManager
Dim bc As ByteConverter
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("SLR_capture1")
Activity.AddMenuItem("Exit", "mnuexit")
Activity.AddMenuItem("Connect Tablet to Game", "mnuConnect")
manager.Initialize
End Sub
Sub mnuConnect_click
If manager.GetDevices.Length = 0 Then
ToastMessageShow ("No connected usb devices."& manager.GetDevices.Length,True)
Else
Dim device As UsbDevice = manager.GetDevices(0) 'assuming that there is exactly one device
If manager.HasPermission(device) = False Then
ToastMessageShow("Please connect and click again.", True)
manager.RequestPermission(device)
Else
usbserial.Initialize("serial", device, -1)
usbserial.BaudRate = 9600
usbserial.DataBits = usbserial.DATA_BITS_8
usbserial.StartReading
ToastMessageShow ("connection sucessful",True)
End If
End If
End Sub
Private Sub serial_DataAvailable (Buffer() As Byte)
Log("New data: " & bc.HexFromBytes(Buffer))
End Sub