mollyzhang
驱动牛犊
驱动牛犊
  • 注册日期2005-05-11
  • 最后登录2006-09-24
  • 粉丝0
  • 关注0
  • 积分304分
  • 威望52点
  • 贡献值0点
  • 好评度7点
  • 原创分0分
  • 专家分0分
阅读:1059回复:0

在驱程里怎样实现中断传输的连续多字节传输呢?看看下面的代码吧!

楼主#
更多 发布于:2005-07-20 22:08
  在驱程里这样写: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;
}
游客

返回顶部