You are here

CyUSB DeviceIOControl returns TRUE but incomplete buffer | Cypress Semiconductor

CyUSB DeviceIOControl returns TRUE but incomplete buffer

Summary: 1 Reply, Latest post by aasi on 13 Sep 2012 08:17 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
coppi75's picture
1 post


I am using a Cypress EZ-USB  FX2-LP to continuously transmit data to a PC through bulk data transfer.  At the end of the email the part of the code used to get the data, where BUFFER_SIZE is 65KByte.


The data transmission typically goes fine, but sometimes happen that the despite DeviceIoControl return TRUE and there is no USB error the received data, corresponding to l_ulByteCount, is less than the requested BUFFER_SIZE.

The successive bulk transfer request goes succesfully, by I have lost the data of the previous incomplete buffer.

The problem comes up in one of the following conditions:

1) When I minimize/maximize the application GUI or switch off/on the display
2) Every hour at the same minute the same seconds. The minute and seconds depends on when I turn on the computer.

For what concern the first case, I almost avoided the incomplete buffer issue by minimizing the visual effect of windows, however the error appears regularly when I switch on the display.

For the second case I tried to understand if there is some task, process or service running abnormally at that time instant, but I noted nothing remarkable.

I replicated the same issue running the software both in Windows xp x86 and Windows 7 x86.

Please help ...


unsigned long l_ulByteCount;
BOOL l_bSuccess;

l_pTransfer = (PSINGLE_TRANSFER)p_chBuffer;

l_pTransfer->SetupPacket.bmRequest	= 0;
l_pTransfer->SetupPacket.bRequest	= 0;
l_pTransfer->SetupPacket.ulTimeOut	= 0;
l_pTransfer->SetupPacket.wIndex		= 0;
l_pTransfer->SetupPacket.wLength	= 0;
l_pTransfer->SetupPacket.wValue		= 0;
l_pTransfer->IsoPacketLength		= 0;
l_pTransfer->IsoPacketOffset		= 0;
l_pTransfer->ucEndpointAddress		= ENDPOINT_ADDRESS;
l_pTransfer->BufferOffset		= sizeof(SINGLE_TRANSFER);
l_pTransfer->BufferLength		= BUFFER_SIZE;
l_pTransfer->NtStatus			= 0;
l_pTransfer->UsbdStatus			= 0;

// Bulk transfer request
l_bSuccess = DeviceIoControl( m_hDevice,
			      p_chBuffer, sizeof(SINGLE_TRANSFER) + BUFFER_SIZE, 
			      p_chBuffer, sizeof(SINGLE_TRANSFER) + BUFFER_SIZE, 
			      &l_ulByteCount, NULL);
if (l_bSuccess==TRUE)
	USBStatus = l_pTransfer->UsbdStatus;

		return NO_ERROR;

	        return USB_PENDING;


	return  USB_ERROR;
        return DEVICE_IO_ERROR;


aasi's picture
Cypress Employee
1166 posts
Log in to post new comments.