Author Topic: ReadDataViaInterruptTransfer() from different endpoints  (Read 6230 times)

lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
ReadDataViaInterruptTransfer() from different endpoints
« 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?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: ReadDataViaInterruptTransfer() from different endpoints
« Reply #1 on: October 28, 2014, 02:03:58 pm »
WinUsb_ReadPipe accepts a PipeID that identifies the endpoint address.

lcpoon

  • Frequent Contributor
  • ****
  • Posts: 58
Re: ReadDataViaInterruptTransfer() from different endpoints
« Reply #2 on: October 29, 2014, 12:05:56 am »
    /* 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

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: ReadDataViaInterruptTransfer() from different endpoints
« Reply #3 on: October 29, 2014, 09:51:07 am »
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