Hi,
I have the following code -
What I want it to do is wait for a usb in packet, and use it. that is pretty clear. I want it to timeout if no data shows up. This wont work because the WaitForSingleObject is called after the clocking ReadFile.
Is there a better wqay to do this? Maybe not read file? Of a simpler timeout? I cannot use doevents to run my own time out because the ReadFile is blocking.
Thanks,
Martin
Security.lpSecurityDescriptor = 0
Security.bInheritHandle = CInt(True)
Security.nLength = Len(Security)
EventObject = CreateEvent(Security, CInt(False), CInt(True), "rdUsb")
HIDOverlapped.Offset = 0
HIDOverlapped.OffsetHigh = 0
HIDOverlapped.hEvent = EventObject
'Do
DoEvents
RecBuffer(4) = 0
RecBuffer(5) = 0
Result = ReadFile _
(HIDHandle, _
RecBuffer(0), _
CLng(Capabilities.InputReportByteLength), _
rdNum, _
HIDOverlapped)
Result = WaitForSingleObject(EventObject, 500)
Select Case Result
Case WAIT_OBJECT_0
' Success
' Use the report data.
rdNum = (RecBuffer(4) + 5)
...
..
.