Hi Jan,
I added GetPipePolicy function to the project and checked the POLICY_TYPE.PIPE_TRANSFER_TIMEOUT value in different places in the code.
In _myWinUs Communications.Initialize Device after SetPipePolicy I call to GetPipePolicy, the function returned with success result and I get the same TimeOut value, as I set in previous function.
But in ReceiveDataViaBulkTransfer function GetPipePolicy returns with true and the POLICY_TYPE.PIPE_TRANSFER_TIMEOUT value was 0!
This code return after timeout expired:
if (!(winUsbHandle.IsInvalid))
{
// while (success)
// {
byte timeout = 0x01;
bool result = GetPipePolicy
(winUsbHandle,
myDeviceInfo.BulkInPipe,
Convert.ToUInt32(NativeMethods.POLICY_TYPE.PIPE_TRANSFER_TIMEOUT),
timeout); // timeout=0 !
const uint pipeTimeout = 1000;
result = SetPipePolicy
(winUsbHandle,
myDeviceInfo.BulkInPipe,
Convert.ToUInt32(NativeMethods.POLICY_TYPE.PIPE_TRANSFER_TIMEOUT),
pipeTimeout);
while (success)
{
success = NativeMethods.WinUsb_ReadPipe
(winUsbHandle,
myDeviceInfo.BulkInPipe,
dataBuffer,
bytesToRead,
ref bytesRead,
IntPtr.Zero);
circle++;
}
error = Marshal.GetLastWin32Error();
Any ideas why it happens?