阅读:1059回复:0
在驱程里怎样实现中断传输的连续多字节传输呢?看看下面的代码吧!
在驱程里这样写:NTSTATUS D12_DriverDevice::D12_DRIVER_READ_Handler(KIrp I)
{ PURB pUrb; NTSTATUS status; t << "Entering D12_DriverDevice::D12_DRIVER_READ_Handler, " << I << EOL; if (I.IoctlOutputBufferSize() == 0) { I.Information() = 0; return I.PnpComplete(this, STATUS_SUCCESS); } ULONG dwTotalSize = I.IoctlInputBufferSize(CURRENT); ASSERT(dwTotalSize); ULONG dwBytesRead = 0; pUrb = m_Endpoint1In.BuildInterruptTransfer( (unsigned char *)I.IoctlBuffer(), // transfer buffer I.IoctlInputBufferSize(), // transfer buffer size TRUE, // Short Ok NULL, // link urb NULL // new urb ); if ( pUrb != NULL) { status = m_Endpoint1In.SubmitUrb(pUrb, NULL, NULL,300); if ( NT_SUCCESS(status) ) { dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength; if (dwBytesRead > 0) t << "Read got " << dwTotalSize << " bytes from USB\n"; } delete pUrb; } else { status=STATUS_INSUFFICIENT_RESOURCES; } I.Information() = dwBytesRead; return status; } |
|