Why is WinUsb_WritePipe returning error 997 With asynchronous winusb io?

127 Views Asked by At

If I use WinUsb_WritePipe with a LPOVERLAPPED entry, and use WinUsb_GetOverlappedResult to wait on the results, I have an error where WinUsb_WritePipe always returns false, and GetLastError returns error 997.

    OVERLAPPED ovr = { 0 };
    ovr.hEvent = CreateEvent(NULL, TRUE, FALSE, "USBWrite");
...
    while( ... )
    {
        // If waiting...
        WinUsb_GetOverlappedResult( winusbhandle, &ovr, &NumberOfBytesTransferred, 1);
        // Always,
        WinUsb_WritePipe(winusbhandle, 0x01, usb_out_buffer, sizeof(usb_out_buffer), &bytesWritten, &ovr);
        // This returns as a failure and GetLastError() == 997 
    }
}
1

There are 1 best solutions below

0
Charles Lohr On

There is no issue. The error code should be checked, but, error 997 just means that "Yes, we have queued your data, it is now in progress. Nothing is wrong."

So, you should detect this error, and ignore it. Other errors are real.