Home > Software engineering >  DeviceIoControl ERROR_CRC error code
DeviceIoControl ERROR_CRC error code

Time:09-18

The code is as follows:
BOOL OpenUSBPort ()
{
If (m_hDevice!=INVALID_HANDLE_VALUE)
return true;
M_hDevice=CreateFile (
M_DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
Return m_hDevice!=INVALID_HANDLE_VALUE;
}

BOOL Control_Info (HANDLE hDevice, dwords cntrlCode LPTSTR buff, dwords & amp; Len)
{
BOOL retFlag;
DWORD retLen;
DWORD waitTimes=0;
OVERLAPPED OVERLAPPED;
Memset (& amp; Overlapped, 0, sizeof (overlapped));
Overlapped. HEvent=CreateEvent (NULL, FALSE, FALSE, NULL);

RetFlag=DeviceIoControl (
HDevice,//HANDLE hDevice,
CntrlCode,//DWORD cntrlCode,
NULL,//LPVOID lpInBuffer,
0,//dwords nInBufferSize,
Buff,//LPVOID lpOutBuffer,
Len,//DWORD nOutBufferSize,
& RetLen,//LPDWORD lpBytesReturned,
& Overlapped//LPOVERLAPPED LPOVERLAPPED
);
WaitForSingleObject (overlapped. HEvent, 2000);
Len=retLen;

Return retFlag;
}

Each time you perform error code are ERROR_CRC, supposedly should be: ERROR_IO_PENDING, please which ace to give directions, thank you

CodePudding user response:

CntrlCode=IOCTL_USBPRINT_GET_1284_ID
  • Related