ms520sxl
驱动牛犊
驱动牛犊
  • 注册日期2004-03-17
  • 最后登录2005-01-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1134回复:0

USB驱动写数据运行到status = m_Endpoint2OUT.SubmitUrb(I, pUrb, LinkTo(WriteComplete), pCompInfo, 0)重起!!!

楼主#
更多 发布于:2004-10-27 20:20
直接用DS生成的USB驱动,在往批量管道写一个数据时就重起了,具体跟踪了一下,是在
status = m_Endpoint2OUT.SubmitUrb(I, pUrb, LinkTo(WriteComplete), pCompInfo, 0);重起的
可能的原因会是什么呢,拜托各位朋友帮忙看看!!!!!!

而且这个驱动在偶然的一次写数据时没重起,可接着又恢复重起的状态了?????

具体的写进程如下:
NTSTATUS Test1Device::Write(KIrp I)
{
t << "Entering Test1Device::Write, " << I << EOL;

// 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 the total requested read size is greater than the Maximum Transfer
// Size for the Pipe, request to read only the Maximum Transfer Size since
// the bus driver will fail an URB with a TransferBufferLength of greater
// than the Maximum Transfer Size.
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);
}

// TODO: Select the correct pipe to write to

// Create an URB to do actual Bulk write to the pipe
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;
}

各位朋友帮忙指点指点吧!!!
游客

返回顶部