Sub btnOpen_Click
Dim UsbDevices() As UsbDevice
UsbDevices = manager.GetDevices
If UsbDevices.Length = 0 Then
ToastMessageShow("No device", True)
Else
For z = 0 To UsbDevices.Length - 1
Dim UsbDvc As UsbDevice
UsbDvc = UsbDevices(z)
If (UsbDvc.ProductId = s_id) And (UsbDvc.VendorId = s_vd) Then
If manager.HasPermission(UsbDvc) = False Then
manager.RequestPermission(UsbDvc)
Else
usb2.Initialize2 ( "Fel" , UsbDvc, - 1 , "CDCSerialDevice" )
usb2.BaudRate = 9600
usb2.DataBits = usb.DATA_BITS_8
usb2.StartReading
usb2.Write(Array As Byte(addr,0x05,ForCRC(Bit.Xor(0x05,ForCRC(Bit.Xor(0,addr))))))
End If
End If
Next
End If
End Sub