c++interfaceusbwinusb

WINUSB_ControlTransfer can only be used on one of the two interfaces available on the device, but not the other


I am working with the device and it has two interfaces. The lsusb information on the USB device can be found in the link below. https://github.com/zougloub/libseek

The camera has two interfaces, first one is iAP interface and second is com.thermal.pit206 interface. I wrote my application based on the iAP interface because. The reason I went with iAP interface is because everyone else did so on GitHub, so I just followed the suit.

I am able to use Winusb_ControlTrasnfer function with the iAP interface. I can initialise the WinUSB handle and use it to send and get commands as well as read pipe.

However, when I use the com.thermal.pit206 interface, I can still initialise the WinUSB handle but I am unable to send or get commands.

void CommandTransfer(WINUSB_INTERFACE_HANDLE winIHandle, UCHAR requestTypeI, UCHAR requestI, USHORT valueI, USHORT indexI, USHORT lengthI, PUCHAR dataIn)
{
    WINUSB_SETUP_PACKET packet;
    ZeroMemory(&packet, sizeof(WINUSB_SETUP_PACKET));
    packet.RequestType = requestTypeI;
    packet.Request = requestI;
    packet.Value = valueI;
    packet.Index = indexI;
    packet.Length = lengthI;

    ULONG dataLength = 0;

    if (!WinUsb_ControlTransfer(winIHandle, packet, dataIn, lengthI, &dataLength, NULL))
    {
        printf("ERROR: WinUsb_ControlTransfer, Windows Error Code - %d \n", GetLastError());
    }
} 

Above you can see a copy of my code that I use to send commands to the device.

I am confused why I can send commands to the device when I am using the iAP interface but, when I am using the com.thermal.pir206 interface, I am unable to do so.

Thanks! Any helpful link / information is appreciated.


Solution

  • The WinUsb_ControlTransfer() function only works for the default endpoint zero, which is always of control type.

    The endpoints in all other interfaces on the above mentioned lsusb output are of bulk type. These will require the use of WinUsb_ReadPipe() or WinUsb_WritePipe() functions.