阅读:1602回复:4
ez-usb 的VB应用程序问题请教
看下面的代码,EZ-USB提供的EP_PAIR的WINDOWS应用程序VB读写控制函数源代码,该程序实现在EP2通道的读写控制。我的问题是,在下边的代码中,那句决定了向目标那个通道读数据或是写数据,如果我想增加一个IN通道,来读入数据,我应该做怎样的修改呢?才能使程序正常工作的(底下的程序已经没有问题,用它提供的控制面板可以正确读写数据)望各位大虾指点一二。 [有在用VB作这方面的开发的朋友嘛?交流一下?zhe_ye@sina.com]
Function DoBulkXfer(strDriver As String, pipe As Integer, ByRef buffer() As Byte, ByRef dataLen As Long) As Long \' transfers a block of bytes to or from EZ-USB device using Bulk Transfer \' \' IN strDriver symbolic link name assigned to device driver, e.g. \"Ezusb-0\" \' IN pipe numeric pipe id \' I/O buffer byte array for data \' I/O dataLen integer variable containing number of valid data bytes in buffer \' \' returns: 1 = successful transfer \' 0 = unsuccessful transfer; caller should call EZGetLastError function \' -1 = bad parameter \' -2 = bad driver \' -3 = bad pipe number Dim hDriverHandle As Long Dim result As Long Dim btc As BulkTransferControlType Dim pi As USBDInterfaceInformationType Dim usbDD As USBDeviceDescriptorType Dim lBytesReturned As Long \' get a handle to the requested driver hDriverHandle = OpenDriver(strDriver) \' If hDriverHandle > 0 Then \' is ep_pair.hex loaded into the EZ-USB firmware? result = DeviceIoControl(hDriverHandle, IOCTL_Ezusb_GET_DEVICE_DESCRIPTOR, usbDD, Len(usbDD), usbDD, Len(usbDD), lBytesReturned, 0) If result = 0 Then: DoBulkXfer = result \' VID 0x547 and PID 0x1002 set up by ep_pair.hex download If usbDD.iVendorID <> &H547 And usbDD.iProductID <> &H1002 Then DoBulkXfer = eBadPipe Exit Function End If \' get data about caller\'s pipe result = GetPipeInfo(strDriver, pi) If result = 0 Then DoBulkXfer = result Exit Function End If \' is caller\'s pipe legal? If pi.lNumberOfPipes <= pipe Then DoBulkXfer = eBadPipe Exit Function Else \' put the pipe id into the BulkTransferControl structure btc.lPipeNum = pipe End If \' determine the endpoint direction and do the device call If (pi.Pipes(pipe).bEndpointAddress > 128) Then result = DeviceIoControl(hDriverHandle, IOCTL_EZUSB_BULK_READ, btc, Len(btc), buffer(0), dataLen, dataLen, 0) Else result = DeviceIoControl(hDriverHandle, IOCTL_EZUSB_BULK_WRITE, btc, Len(btc), buffer(0), dataLen, dataLen, 0) End If \' close the driver CloseHandle (hDriverHandle) DoBulkXfer = result Else DoBulkXfer = eBadDriver End If End Function |
|
最新喜欢:![]() |
沙发#
发布于:2002-10-25 17:25
哈哈,搞定了,跟踪了几次,终于明白是如何的工作的了,真开心。 :P
|
|
板凳#
发布于:2002-10-29 17:05
有空指教一下,我是新手!qq:18060672,e_mail是jipeifeng@sian.com
|
|
地板#
发布于:2002-11-04 11:24
我是初学USB,能不能给我1份USB的VB程序,非常感谢!
我的E-MAIL:wsjljh2002@yahoo.com.cn |
|
地下室#
发布于:2002-11-04 12:51
程序是EZ开发板自带的例子程序的
|
|