阅读:1534回复:1
wince5下的DeviceIoControl与CTLCODE_SCSI_PASSTHROUGH的问题
具体是这样的,
我们自己开发了一个usb设备,仿真成U盘接口的。 在xp平台下可以直接使用DeviceIoControl,CTLCODE_SCSI_PASS_THROUGH来收发数据, 现在正在把程序移植到CE5平台下,但在CE5平台下却一直不能正常工作,总是发送超时,而且收不到任何数据。 现在手边没有程序,所以只能大概写一下,朋友们帮忙看看,出出主意,应该怎么解决这个问题 TRANSPORT_COMMAND command; TRANSPORT_DATA data; //填写command与data DeviceIoControl( m_hDevice, CTLCODE_SCSI_PASS_THROUGH, &command, sizeof(command), &data, sizeof(data), NULL); 大概类似如此,明天去公司把完整代码贴出来。 请大家看看啦,有这方面的例程更好:) |
|
沙发#
发布于:2008-04-18 11:02
完整代码
DWORD dwResult = -1; TRANSPORT_COMMAND ptcCommand; TRANSPORT_DATA ptdData; UCHAR bCDB[MAX_CDB]; ZeroMemory(&ptcCommand, sizeof(TRANSPORT_COMMAND)); ZeroMemory(&ptdData, sizeof(TRANSPORT_DATA)); ptcCommand.Length = 10; ptcCommand.Flags = DATA_OUT; ptcCommand.dwLun = 0; ptcCommand.Timeout = 200; ptcCommand.CommandBlock = bCDB; memset ( bCDB, 0x00, sizeof ( bCDB ) ); bCDB[0] = CMD_WRITE; bCDB[1] = 0; bCDB[7] = (UCHAR)(dwLength&0xff); bCDB[8] = (UCHAR)(dwLength>>8); /* bCDB[7] = (UCHAR)((dwLength>>8)&0x0FF); bCDB[8] = (UCHAR)(dwLength&0x0FF); // 24 */ ptdData.DataBlock = lpData; ptdData.RequestLength = dwLength; ptdData.TransferLength = 0; DWORD dwBytesReturned; BOOL fResult = FALSE; DWORD dwIoControlCode = IOCTL_SCSI_PASSTHROUGH;// : IOCTL_DISK_WRITE; fResult = DeviceIoControl( m_hDevice, dwIoControlCode, &ptcCommand, sizeof(ptcCommand), &ptdData, sizeof ( ptdData), &dwBytesReturned, NULL); if (fResult) { ShowError1 ( L"\t\tSend::DeviceIoControl ok", GetLastError() ); } else { ShowError1 ( L"\t\tSend::DeviceIoControl error", GetLastError() ); goto EXIT; } dwResult = 0; EXIT:; return dwResult; |
|