PORTS Forum
Ports and Interfaces => USB => Topic started by: lcpoon on October 28, 2014, 04:42:10 am
-
My device has 2 interrupt transfer endpoints. How to use the WinUSB VB program to read from different endpoint?
-
WinUsb_ReadPipe accepts a PipeID that identifies the endpoint address.
-
/* Endpoint Descriptor */
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP01_OUT, //EndpointAddress
_BULK, //Attributes
USBGEN_EP_SIZE,0x00, //size
1, //Interval
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP01_IN, //EndpointAddress
_BULK, //Attributes
USBGEN_EP_SIZE,0x00, //size
1, //Interval
/* Endpoint Descriptor */
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP02_OUT, //EndpointAddress
_INT, //Attributes
INT1_OUT_EP_SIZE,0x00, //size
1, //Interval
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP02_IN, //EndpointAddress
_INT, //Attributes
INT1_IN_EP_SIZE,0x00, //size
1, //Interval
/* Endpoint Descriptor */
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP03_OUT, //EndpointAddress
_INT, //Attributes
INT2_OUT_EP_SIZE,0x00, //size
1, //Interval
0x07, /*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
_EP03_IN, //EndpointAddress
_INT, //Attributes
INT2_IN_EP_SIZE,0x00, //size
1
Please let me know how to modify this code to read EndpointID: 3 only?
Private Sub ReadDataViaInterruptTransfer()
Dim ar As IAsyncResult
Dim bytesToRead As UInt32 = 32
Dim buffer(CInt(bytesToRead - 1)) As Byte
Dim bytesRead As UInt32
Dim success As Boolean
Dim MyReadFromDeviceDelegate As New ReadFromDeviceDelegate(AddressOf myWinUsbDevice.ReadViaInterruptTransfer)
Data_Rd_Successful = False
Try
ar = MyReadFromDeviceDelegate.BeginInvoke(myWinUsbDevice.myDevInfo.interruptInPipe, bytesToRead, buffer, bytesRead, success, New AsyncCallback(AddressOf GetReceivedInterruptData), MyReadFromDeviceDelegate)
Catch ex As Exception
Throw
End Try
End Sub
-
Your code should include
WinUsb_ReadPipe
The second parameter passed to it is the endpoint address. Endpoint 3 IN is 0x83.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff540297%28v=vs.85%29.aspx