驱动牛犊
|
阅读:1524回复:5
driver studio3. 开发 usb的问题
driver studio 3.2开发 usb,我的usb设备共有四个端点:
pipe1_In ( 0x81,bulk),pipe2_in(0x82,bulk), pipe3_Out(0x3,bulk),pipe4_Out(0x4,bulk) 我在driverstudio中也配置了这样四个端点,安装驱动后, 枚举,加载驱动都没问题。通过端点pipe3_out写没有问题,可是通过pipe1_In就是读不到数据。也就是只能写,不能读。 我更换了usb Id号后,利用其他的驱动程序就可以读写。 有没有利用driverstudio3.2开发的朋友遇到过这样的问题?不知道是dirverstudio3.2本身的问题,还是有些地方没有配置好? |
|
驱动牛犊
|
沙发#
发布于:2007-12-21 11:56
期待解答'''''''
|
|
板凳#
发布于:2007-12-21 15:50
我的usb设备用到一下端点:
pipe1_In ( 0x81,interrupt),pipe1_out(0x01,interrupt), 我遇到的问题是读得到数据,但不能把数据写到芯片中。 能不能麻烦您把您写的代码贴出来让我看看,谢谢。 |
|
|
驱动牛犊
|
地板#
发布于:2007-12-21 16:07
读代码如下:
/////////////////////////////////////////////////////////////////////////////////////////////////// // USB4Device::Read // Dispatch routine for IRP_MJ_READ requests. // // Arguments: // IN I // the read IRP // // Return Value: // NTSTATUS // NTSTATUS USB4Device::Read(KIrp I) { T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I); DbgPrint("### 4 read"); NTSTATUS status = STATUS_SUCCESS; // TODO: Validate the parameters of the IRP. Replace "FALSE" // in the following line with error checking code that // evaulates to TRUE if the request is not valid. /* if (FALSE) { status = STATUS_INVALID_PARAMETER; I.Information() = 0; I.PnpComplete(status); T.Trace(TraceWarning, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; }*/ // Always ok to read 0 elements if (I.ReadSize() == 0) { I.Information() = 0; I.PnpComplete(this, status); T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; } KMemory Mem(I.Mdl()); // Declare a memory object // Get a pointer to the caller's buffer. Note that this // routine is safe on all platforms. PUCHAR pBuffer = (PUCHAR) Mem.MapToSystemSpace(); ULONG dwTotalSize = I.ReadSize(); ULONG dwMaxSize= Pipe1_In.MaximumTransferSize(); ULONG dwBytesRead = 0; if ( dwTotalSize > dwMaxSize ) { ASSERT(dwMaxSize); dwTotalSize = dwMaxSize; } // TODO: At this point, perform any processing for IRP_MJ_READ // To satisfy the read now, transfer data from the driver // to the caller's buffer at "pBuffer". Then, indicate // how much data was transferred: // Create an URB to do actual Bulk read from Pipe0 PURB pUrb = Pipe1_In.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to read? TRUE, // direction (TRUE = IN) NULL, // Link to next URB TRUE, NULL ); if ( pUrb != NULL) // Submit the URB to our USB device, synchronously - say less is OK { pUrb->UrbBulkOrInterruptTransfer.TransferFlags = (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK); status = Pipe1_In.SubmitUrb(pUrb, NULL, NULL); if ( NT_SUCCESS(status) ) { dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength; if (dwBytesRead > 0) DbgPrint("### read %d bytes\n",dwBytesRead); else DbgPrint("### read 0 bytes\n"); } delete pUrb; } I.Information() =dwBytesRead; I.PnpComplete(this, status); T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; } |
|
驱动牛犊
|
地下室#
发布于:2007-12-21 16:08
写代码:
/////////////////////////////////////////////////////////////////////////////////////////////////// // USB4Device::Write // Dispatch routine for IRP_MJ_WRITE requests. // // Arguments: // IN I // the write IRP // // Return Value: // NTSTATUS // NTSTATUS USB4Device::Write(KIrp I) { T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I); DbgPrint("### 1 write"); NTSTATUS status = STATUS_SUCCESS; // TODO: Validate the parameters of the IRP. Replace "FALSE" // in the following line with error checking code that // evaulates to TRUE if the request is not valid. /* if (FALSE) { status = STATUS_INVALID_PARAMETER; I.Information() = 0; I.PnpComplete(status); T.Trace(TraceWarning, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; }*/ // Always ok to write 0 elements if (I.WriteSize() == 0) { I.Information() = 0; I.PnpComplete(this, status); T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; } KMemory Mem(I.Mdl()); // Declare a memory object // Get a pointer to the caller's buffer. Note that this routine is safe on all platforms. PUCHAR pBuffer = (PUCHAR) Mem.MapToSystemSpace(); ULONG bytesSent = 0; // TODO: At this point, perform any processing for IRP_MJ_WRITE // To satisfy the write now, transfer data to the driver // from the caller's buffer at "pBuffer". Then, indicate // how much data was transferred: ULONG dwTotalSize = I.WriteSize(CURRENT); ULONG dwMaxSize = Pipe3_Out.MaximumTransferSize(); if ( dwTotalSize > dwMaxSize ) { ASSERT(dwMaxSize); dwTotalSize = dwMaxSize; } ULONG dwBytesSent = 0; PURB pUrb = Pipe3_Out.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to write? FALSE, // direction (FALSE = OUT) NULL, // Link to next URB TRUE, NULL ); if (pUrb != NULL) // Submit the URB to our USB device, synchronously { status = Pipe3_Out.SubmitUrb(pUrb, NULL, NULL); if ( NT_SUCCESS(status) ) { dwBytesSent = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength; // Tracer << "Write() posted " << dwTotalSize << " bytes to USB\n"; } delete pUrb; } I.Information() = bytesSent; I.PnpComplete(this, status); T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status); return status; } |
|
5楼#
发布于:2007-12-26 09:15
谢谢回复,这两部分代码可以由向导自动生成吗?
|
|
|