I have some code to get data from an IN endpoint on the USB
if ( false == ::DeviceIoControl(h, IOCTL_ADAPT_SEND_NON_EP0_DIRECT,
&dwReturnBytes, (LPOVERLAPPED)NULL) )
The problem is for the very last transfer, no data is passed back, and I do not want the DeviceIoControl to capture anything. The above code will block until sometthing is captured, but I want it to abandon the last capture. I could successfully do that with the IOCTL_ADAPT_RESET_PARENT_PORT. However, that will NOT result in an excpetion being through, as no error condition is reported.
I tried using IOCTL_ADAPT_ABORT_PIPE to force the above code to throw an exception, however, that does not seems to work. Here is how I implmented the abort function
if (false == ::DeviceIoControl(h, IOCTL_ADAPT_ABORT_PIPE,
throw std::exception("LowCyUsbDriver::Reset() - Input pipe IO request cannot be aborted.");
Is there another function I can use to force the IOCTL_ADAPT_SEND_NON_EP0_DIRECT to report an error state?
I really need it to report an error state so I know it has returned from the last capture and nothing should be done about the data that was captured.
Marshal.GetLastWin32Error() returns the error code returned by the last unmanaged function that was called. Please have a look at http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getlastwin32error.asp... and also the variuos System error codes at: http://msdn.microsoft.com/en-us/library/ms681381.aspx
Please check and let us know whether this proves useful.