阅读:1470回复:5
大侠帮帮忙啊!!!用DS生成的USB驱动程序装上之后,运行应用程序,就会重起!!!
哪位大侠帮帮忙啊,我直接用DS生成的USB驱动程序,只是改了INF文件中的设备类,字符串,在应用程序里改成只写一个数据:WRITEFILE。可现在运行应用程序时,提示打开设备成功,可一到写数据部分就重起了,这会是什么原因了。帮帮忙啊!!!!!
|
|
沙发#
发布于:2004-10-18 01:08
检查指针
|
|
板凳#
发布于:2004-10-18 11:31
楼上朋友能给点具体的提示吗,我看不出什么地方有指针啊,我写的地方如下:
NTSTATUS Test2Device::Write(KIrp I) { t << "Entering Test2Device::Write, " << I << EOL; 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; } PUCHAR pBuffer = (PUCHAR)I.BufferedWriteSource(); KMemory Mem(pBuffer, dwTotalSize); Mem.SetPageArray(); // 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); } // 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; } 这段程序哪有问题啊,帮忙看看啊,我真的看不明白啊!!! |
|
地板#
发布于:2004-10-18 11:41
我觉得你是在中断那里出了问题
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 ); 看看BuildBulkTransfer里面的代码有什么问题吧,usb驱动造成重启,很多情况都是读写里面出问题,我也遇到过 |
|
地下室#
发布于:2004-10-19 09:39
我觉得从这段程序来看没有什么问题。你可以看一下固件的程序,我以前出现过类似的问题,后来是我们的硬件工程师改了固件程序排除了故障。他告诉我是一个指针错误了
|
|
5楼#
发布于:2004-10-19 15:10
To marvie:我理解的是,pUrb指向一个USB请求块指针,直接将这个请求传给总线驱动,进行处理,这里怎么会产生中断呢?我对驱动理解的很浅,请你具体解释一下呗!!
To yunhaisoft:我直接用的周立功开发板,只是在进行驱动的编程。而且,我不清楚将USB请求传递给总线驱动后,与设备进行打交道的具体细节。固件的一个指针错误怎么会影响到读写呢?请指点指点吧! 多谢两位朋友的热情支持了!!! |
|