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
Sub btnOpen_Action
sp.Open(cmbPort.Value)
sp.SetParams (9600,8,1,0)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
'astream.InitializePrefix(sp.GetInputStream, True, sp.GetOutputStream, "astream")
End Sub
You have reduced the waiting interval in the YYY Library. And can you make it as small as possible? I will be very grateful...The reading is done with a background thread that polls the buffer for new data. I've decreased the thread waiting interval.
Yes!The interval is set to 10ms. It should be fast enough. Are you testing it in release mode?
sp.Open(cmbPort.Value)
sp.SetParams (115200,8,1,0)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
Sub AStream_NewData (Buffer() As Byte)
If Buffer.Length=1024 Then
...
End If
End Sub
Sub Mytest
For temp=0 To 1023
DataTest(temp)=Rnd(0,512)
Next
...
End Sub