用DS3.2做的USB驱动,插上设备瞬间用BUSHOUND看到的通讯数据正常,设备也能枚举也可以成功打开和关闭,但用WriteFile和ReadFile对设备进行写操作时,BUSHOUND没有看到任何数据。驱动中IRP_MJ_READ对应BULK模式的端点1的IN。IRP_MJ_WRITE对应BULK的端点2的OUT。Queue Type为Queue,Buffer Access为Direct。 我用的是异步方式,应用程序的WriteFile后面代码如下: if (!WriteFile( g_hDevice, InBuffer, 64, &nBytes, &(ioItem.IoOverlapped))) { if(GetLastError()!=ERROR_IO_PENDING) MessageBox("WriteError"); } switch(WaitForSingleObject(ioItem.IoOverlapped.hEvent,1000))//等待1000ms { case WAIT_OBJECT_0: if(!::GetOverlappedResult(g_hDevice,&ioItem.IoOverlapped,&nBytes,TRUE)) MessageBox("Write Error"); else { CString ks; ks.Format("%d Bytes Writed",nBytes); MessageBox(ks); } break; case WAIT_TIMEOUT://超时错误 MessageBox("Write Over Time"); break; default: MessageBox("Write Error"); break; } WriteFile返回ERROR_IO_PENDING正常,执行WaitForSingleObject后返回WAIT_OBJECT_0也正常,但用GetOverlappedResult获取到的写入字节数量一直是0。关键是BUSHOUND看不到WriteFile所执行的任何数据流,不解? |