阅读:976回复:0
请教usb一个bulk类型的错误
我用的是pd12,中断类型的端点1的读和写都没有问题,可是bulk类型的端点2的读和写都是submiturb返回一个错误的值,不是成功也不是suspending,我的代码就是按照driverstudio自动生成的改的,如下:
请大虾指点哪里有问题 NTSTATUS UsbTestD12LytDevice::Write(KIrp I) { int i; t << \"Entering UsbTestD12LytDevice::Write, \" << I << EOL; // TODO: Check the incoming request. Replace \"FALSE\" in the following // line with a check that returns TRUE if the request is not valid. if (FALSE) { // Invalid parameter in the Write request I.Information() = 0; return I.PnpComplete(this, STATUS_INVALID_PARAMETER); } // Always ok to write 0 elements. if (I.WriteSize() == 0) { I.Information() = 0; return I.PnpComplete(this, STATUS_SUCCESS); } ULONG dwTotalSize = I.WriteSize(CURRENT); ULONG dwMaxSize = m_Endpoint2OUT.MaximumTransferSize(); if (dwTotalSize > dwMaxSize) { ASSERT(dwMaxSize); dwTotalSize = dwMaxSize; } // Declare a memory object KMemory Mem(I.Mdl()); // Allocate a new context structure for Irp completion USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO; if (pCompInfo == NULL) { I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } PURB pUrb = m_Endpoint2OUT.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to read? FALSE, // direction (FALSE = OUT) NULL // Link to next URB ); if (pUrb == NULL) { delete pCompInfo; I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } // Initialize context structure pCompInfo->m_pClass = this; pCompInfo->m_pUrb = pUrb; // Submit the URB to our USB device NTSTATUS status; status = m_Endpoint2OUT.SubmitUrb(I, pUrb, LinkTo(WriteComplete), pCompInfo, 0); return status; //这里status总是返回错误的值,不知为什么 } |
|