Hi-
I'm working with an FX2LP EZ-USB development kit. I'm using VS2010 in an MFC C++ project, via cyapi.lib. I have a question about XFerData() on a Bulk Endpoint. I have a tight loop that reads single bytes from an in endpoint. I have set the timeout to '0' and I sometimes get a "false" return code, but the "bufLen" variable shows that data was returned. The lastError value is set to 997 (ERROR_IO_PENDING). My question is "What IO is pending?". I have other things to do in the loop, so I would just like to see if the data is ready to be sent upstream to the PC. I expected either a false with bufLen set to '0', or true with a non-zero bufLen. I don't know how to interpret the mixed case. The buffer I supplied is 512 bytes big, and I set bufLen to 512 before I make the call. Below is a simple portion of the code.
I have not looked at this at a hardware level yet, as it seems like the data does come across. The hardware is set to send up 1 or 2 byte packets.
unsigned char inStatusBuff[512];
...
m_StatusInEndpt->TimeOut = 0;
bool bSuccess = false;
char
while (!m_bClosing) {
...
lCount = 512;
//m_StatusInEndpt is a Bulk In Endpoint
bSuccess = m_StatusInEndpt->XferData(inStatusBuff,lCount);
m_StatusInEndpt->LastError;
if(!bSuccess && lCount != 0)
{
m_ErrorCount++;
CString strError;
strError.Format("Error code: %d\r\n",m_StatusInEndpt->LastError);
m_printf(strError);
}
...
}
|