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 ...
Regards
Francesco
unsigned long l_ulByteCount;
PSINGLE_TRANSFER l_pTransfer;
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,
IOCTL_ADAPT_SEND_NON_EP0_TRANSFER,
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;
if (USBD_SUCCESS(USBStatus))
return NO_ERROR;
if (USBD_PENDING(USBStatus))
return USB_PENDING;
if (USBStatus == USBD_STATUS_CANCELED)
return TRANSFER_ABORTED;
return USB_ERROR;
}
else
{
return DEVICE_IO_ERROR;
}
|