Dim UsbDevices() As UsbDevice
UsbDevices = manager.GetDevices
If UsbDevices.Length = 0 Then
ToastMessageShow("ERROR no hay dispositivos USB conectados", True)
Else
For z = 0 To UsbDevices.Length - 1
Dim UsbDvc As UsbDevice
UsbDvc = UsbDevices(z)
Log("USBDeviceNr. " & z & " - UsbPid = " & UsbDvc.ProductId & " Devicename:" & UsbDvc.DeviceName)
Log("USBDeviceNr. " & z & " - Vendor id = " & UsbDvc.VendorId & " Device ID: " & UsbDvc.DeviceId )
Log("listado de dispositivos")
Log("Vendor ID")
Log(UsbDvc.VendorId)
If UsbDvc.VendorId == 9025 Then
dispositivo = z
Log( "Este = " & dispositivo)
End If
Next
End If
If manager.GetDevices.Length = 0 Then
Log("No connected usb devices.")
ToastMessageShow("ERROR no hay dispositivos USB conectados", True)
Else
Dim device As UsbDevice = manager.GetDevices(dispositivo)
If manager.HasPermission(device) = False Then
ToastMessageShow("Please allow connection and click again.", True)
manager.RequestPermission(device)
Else
Log("Conectando " )
enchufado = True
usbserial.Initialize("serial", device, -1)
usbserial.BaudRate = 9600
usbserial.DataBits = usbserial.DATA_BITS_8
usbserial.StartReading
Log("Conectado! ")
ToastMessageShow("Connection OK", True)
End If
End If