Distinguishing Different FX3 Devices with Same VID/PID on Host Application – KBA225775

Version 5

    Author: SrinathS_16          Version: **

     

    Translation - Japanese:ホストアプリケーションで同じVID/PIDを持つ異なるFX3デバイスを区別する –  KBA225775 - Community Translated (JA)

     

    Question:

    How can devices with same VID/PID on the host application be distinguished?

     

    Answer:

    When multiple FX3 devices with the same VID/PID are used, the serial number string can be used to identify the devices on the host application. To include serial number for an FX3 device, make the following changes to the firmware:

    1. Modify the device descriptor to include the serial number string index.

    const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) =

    {

        0x12,                           /* Descriptor size */

        CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

        0x10,0x03,                      /* USB 3.1 */

        0x00,                           /* Device class */

        0x00,                           /* Device sub-class */

        0x00,                           /* Device protocol */

        0x09,                           /* Maxpacket size for EP0 : 2^9 */

        0xB4,0x04,                      /* Vendor ID */

        0xF1,0x00,                      /* Product ID */

        0x00,0x00,                      /* Device release number */

        0x01,                           /* Manufacture string index */

        0x02,                           /* Product string index */

        0x03,                           /* Serial number string index */

        0x01                            /* Number of configurations */

    };

     

    2. Add the string descriptor to include the serial number.

    const uint8_t CyFxUSBSerialNumberDscr[] __attribute__ ((aligned (32))) =

    {

        0x08, /* Descriptor size */

        0x03, /* Device descriptor type */

        '0',0x00, /* Serial number added here */

        '0',0x00,                        

        '1',0x00                        

    };

     

         3. Modify the header file to include the below statement.

    extern const uint8_t CyFxUSBSerialNumberDscr[];

     

         4. Modify the firmware to set pointer to the serial number string descriptor.

    apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 3, (uint8_t *)CyFxUSBSerialNumberDscr);

    if (apiRetStatus != CY_U3P_SUCCESS)

    {

      CyU3PDebugPrint (4, "USB set string descriptor failed, Error code = %d\n", apiRetStatus);

      CyFxAppErrorHandler(apiRetStatus);

    }

     

    With these modifications, the device is identified on the host with the device instance path as follows, USB\VID_04B4&PID_00F1\001, the highlighted section indicating the serial number. The host application identifies the devices by reading the device instance path. The SetupAPI.lib (provided by Microsoft) includes the SetupDiGetDeviceInstanceId() API to read the instance path of devices.

     

    Example host application to read the instance path of devices bound to the CyUSB3.SYS driver is attached.