C
CSSemily
Guest
I'd like to get data from my USB device by following interfaces:
#define IOCTL_OREXSCANNER_GET_IMAGE_BLOCK CTL_CODE(OREXSCANNER_DEVICE_TYPE, 0x803, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
res = DeviceIoControl(m_hDevice, IOCTL_OREXSCANNER_GET_IMAGE_BLOCK,
NULL, 0, m_pNextFreeBlock, blockSize, NULL, &m_Requests);
DWORD err = GetLastError();
if (res || err != ERROR_IO_PENDING)
{
WriteToLogFile("GetLogThread 1. WM_DEVICE_EVENT_DETACHED (DeviceIoControl - IOCTL_OREXSCANNER_GET_IMAGE_BLOCK failed), Error Code: %d", err);
return -1;
}
HANDLE events[1];
events[0] = m_Requests.hEvent;
ret = WaitForMultipleObjects(1, events, FALSE, dwdWait);
if (ret != WAIT_OBJECT_0)
{
WriteToLogFile("Get log loop: ERROR !!!: ret != WAIT_OBJECT_0 !!! Total received %d, Next free block %d END_OF_GETLOG",
m_dwTotalReceived,
m_pNextFreeBlock
);
if (ret == (WAIT_OBJECT_0 + 1))
{
iFlagBreak = 100;
}
else if (ret == WAIT_TIMEOUT)
{
iFlagBreak = 201;
}
else
{
iFlagBreak = 300;
}
}
else if (iFlagBreak == 0)
{
if (!GetOverlappedResult(m_hDevice, &m_Requests[index], &ret, FALSE))
{
WriteToLogFile("GetLogThread 2. WM_DEVICE_EVENT_DETACHED (GetOverlappedResult failed)");
iFlagBreak = 400;
}
}
if (iFlagBreak == 0 && ret)
{
WriteToLogFile("Saving data, count: %d", count);
pwdTempBuffer = m_pImageBuf;
pwdTempBuffer += (m_dwTotalReceived >> 1);
AddBufferToLogFile(pwdTempBuffer, (ret >> 1), m_strLogFile);
}
m_dwTotalReceived += ret;
WriteToLogFile("Saving data, received: %d, total received: %d", ret, m_dwTotalReceived);
if (ret != blockSize)
{
iFlagBreak = 200;
}
the BlockSize i want to get is 128 KB but sometimes the returned size of GetOverlappedResult is less than 128 KB which cause
iFlagBreak is set to 200.
but all the associated functions such as DeviceIoControl/WaitForMultipleObjects/GetOverlappedResult don't report any error .
in which case GetOverlappedResult will not return expected size but donn't report error?
i have no idea.
please help me for this issue.
i appriciate for your kindly help....
Continue reading...
#define IOCTL_OREXSCANNER_GET_IMAGE_BLOCK CTL_CODE(OREXSCANNER_DEVICE_TYPE, 0x803, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
res = DeviceIoControl(m_hDevice, IOCTL_OREXSCANNER_GET_IMAGE_BLOCK,
NULL, 0, m_pNextFreeBlock, blockSize, NULL, &m_Requests);
DWORD err = GetLastError();
if (res || err != ERROR_IO_PENDING)
{
WriteToLogFile("GetLogThread 1. WM_DEVICE_EVENT_DETACHED (DeviceIoControl - IOCTL_OREXSCANNER_GET_IMAGE_BLOCK failed), Error Code: %d", err);
return -1;
}
HANDLE events[1];
events[0] = m_Requests.hEvent;
ret = WaitForMultipleObjects(1, events, FALSE, dwdWait);
if (ret != WAIT_OBJECT_0)
{
WriteToLogFile("Get log loop: ERROR !!!: ret != WAIT_OBJECT_0 !!! Total received %d, Next free block %d END_OF_GETLOG",
m_dwTotalReceived,
m_pNextFreeBlock
);
if (ret == (WAIT_OBJECT_0 + 1))
{
iFlagBreak = 100;
}
else if (ret == WAIT_TIMEOUT)
{
iFlagBreak = 201;
}
else
{
iFlagBreak = 300;
}
}
else if (iFlagBreak == 0)
{
if (!GetOverlappedResult(m_hDevice, &m_Requests[index], &ret, FALSE))
{
WriteToLogFile("GetLogThread 2. WM_DEVICE_EVENT_DETACHED (GetOverlappedResult failed)");
iFlagBreak = 400;
}
}
if (iFlagBreak == 0 && ret)
{
WriteToLogFile("Saving data, count: %d", count);
pwdTempBuffer = m_pImageBuf;
pwdTempBuffer += (m_dwTotalReceived >> 1);
AddBufferToLogFile(pwdTempBuffer, (ret >> 1), m_strLogFile);
}
m_dwTotalReceived += ret;
WriteToLogFile("Saving data, received: %d, total received: %d", ret, m_dwTotalReceived);
if (ret != blockSize)
{
iFlagBreak = 200;
}
the BlockSize i want to get is 128 KB but sometimes the returned size of GetOverlappedResult is less than 128 KB which cause
iFlagBreak is set to 200.
but all the associated functions such as DeviceIoControl/WaitForMultipleObjects/GetOverlappedResult don't report any error .
in which case GetOverlappedResult will not return expected size but donn't report error?
i have no idea.
please help me for this issue.
i appriciate for your kindly help....
Continue reading...