HI
I have made great progress WITH my project. Thanks FOR your help!
I have been testing my code and run into a bit of a problem I am having trouble tracking down. My device has 6 buttons. I am using ReadFile Overlapped plus WaitForSingleObject. Things basically work right but my application stops receiving data from the device even though my Beagle shows valid activity coming from the device. I can cause the problem by pressing the buttons very fast.
This is the basic flow of the ReadFile code:
RESULT = HidD_SetNumInputBuffers(FILE_HANDLE, 512)
DO
RESULT = WaitForSingleObject(MY_OVERLAPPED.hEvent, 3000)
RESULT = ReadFile(BYVAL FILE_HANDLE, READ_BUFFER, MY_InputReportByteLength , BYTES_READ, MY_OVERLAPPED)
Last_Error = GetLastError
WE GET AN ERROR 997 HERE ERROR_IO_PENDING
DO SOMETHING WITH READ_BUFFER HERE.
Result = GetOverlappedResult(BYVAL FILE_HANDLE, MY_OVERLAPPED, BYTES_READ, 0)
Last_Error = GetLastError
WE GET AN ERROR 996 HERE ERROR_IO_INCOMPLETE
HidD_FlushQueue(FILE_HANDLE)
ResetEvent(GLOBAL_EVENT_WAIT_FOR_OVERLAPPED_READ)
LOOP
Is the circular buffer an issue?
I thought error 997 was normal ERROR_IO_PENDING.
Not sure why I am getting error 996 ERROR_IO_INCOMPLETE after reading the data (at least 17 bytes of it) from the circular buffer.
I tried messing around with:
HidD_SetNumInputBuffers(FILE_HANDLE, BYVAL 512)
HidD_SetNumInputBuffers(FILE_HANDLE, BYVAL 65535)
Didn't notice any change.
If I just wait the program returns to being responsive. This loop is in its own thread.
Letting the code cycle through one or two WaitForSingleObject timeout cycle seems to restore operation....
Also, after calling ReadFile(BYVAL FILE_HANDLE, READ_BUFFER, MY_InputReportByteLength , BYTES_READ, MY_OVERLAPPED)
I get 0 in BYTES_READ except after it has hung then I get 17...
Any clues?