CX3 UVC-CDC - Identifying the CDC COM port

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ajmc_3522501
Level 3
Level 3
5 likes given First like given

Hi,

I'm using the UVC-CDC sample code(Cx3UvcOV5640_UVC_CDC) in CX3. The device enumerates as a video device and a virtual COM port.

I need to identify the virtual COM port created by an automated process. This applies connecting the device to multiple PC's and figuring out the COM ports.

Can i assign a custom name to the CDC device instead of the "USB serial device COMxx" shown in the Device manager?

I know that assignment of COM port number is done from the PC side, so is there any possibility of the CDC device getting a constant COM port on each and every PC connected?

Are there another methods to implement the same.

Thanks in advance

Regards

Ajay

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Ajay,

- Devices can be distinguished based on the device instance path that is allocated by the operating system at the time of enumeration. The device instance path of any device can be found from the device manager.

- In case of Windows, the operating system assigns the device instance path with the VID/PID followed by a random string as in the case below.

USB\VID_04B4&PID_00AB\5&1FC31FA8&0&14

- To avoid the random string and use a defined value, the Serial Number field has to be specified in the descriptors. This can be done by the following modifications.

1. Device Descriptor:

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

{

    0x12,                           /* Descriptor size */

    CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

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

    0x02,                           /* Device class */

    0x00,                           /* Device sub-class */

    0x00,                           /* Device protocol */

    0x09,                           /* Maxpacket size for EP0 */

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

    0xAB,0x00,                      /* Product ID - Using the Cypress USB-UART PID for driver binding */

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

    0x01,                           /* Manufacture string index */

    0x02,                           /* Product string index */

    0x03,                           /* Serial number string index */

    0x01                            /* Number of configurations */

};

/* Standard device descriptor for USB 2.0 */

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

{

    0x12,                           /* Descriptor size */

    CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

    0x10,0x02,                      /* USB 2.10 */

    0x02,                           /* Device class */

    0x00,                           /* Device sub-class */

    0x00,                           /* Device protocol */

    0x40,                           /* Maxpacket size for EP0  */

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

    0xAB,0x00,                      /* Product ID  - Using the Cypress USB-UART PID for driver binding */

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

    0x01,                           /* Manufacture string index */

    0x02,                           /* Product string index */

    0x03,                           /* Serial number string index */

    0x01                            /* Number of configurations */

};

2. String Descriptor:

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

{

    0x04,                           /* Descriptor size */

    0x03,                           /* Device descriptor type */

    'A',0x00                        /* Additional characters can be added.

                                       The descriptor size should be modified accordingly */

};

3. Header File

extern const uint8_t CyFxUSBSerialNumberDscr[];

4. Firmware:

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

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyFxAppErrorHandler(apiRetStatus);

}

- Once these modifications have been performed, the device comes with a device instance path as follows.

USB\VID_04B4&PID_00AB\A

- I have attached the UsbUart project that comes with the FX3 SDK along with these modifications.

- On the host side, to identify the devices based on the device instance, the SetupDiGetDeviceInstanceId() API from the SetupAPI.lib library can be used. I have attached the host application source and binary file which can identify the device instance of a COM port device and compare it with a pre-loaded device instance ID. I have defined the device instance ID as below. This can be modified to use your VID/PID/Serial number.

const TCHAR reqDevInstanceId[] = L"USB\\VID_04B4&PID_00AB\\5&1FC31FA80&14";

- The attached host application only identifies the device based on the instance path and does not create a handle to the device. The process of communicating with the device has not been explained in the host application.

Password for the attachments: cypress

Please get back in case you have further queries.

Best regards,

Srinath S

View solution in original post

3 Replies
lock attach
Attachments are accessible only for community members.
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Ajay,

- Devices can be distinguished based on the device instance path that is allocated by the operating system at the time of enumeration. The device instance path of any device can be found from the device manager.

- In case of Windows, the operating system assigns the device instance path with the VID/PID followed by a random string as in the case below.

USB\VID_04B4&PID_00AB\5&1FC31FA8&0&14

- To avoid the random string and use a defined value, the Serial Number field has to be specified in the descriptors. This can be done by the following modifications.

1. Device Descriptor:

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

{

    0x12,                           /* Descriptor size */

    CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

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

    0x02,                           /* Device class */

    0x00,                           /* Device sub-class */

    0x00,                           /* Device protocol */

    0x09,                           /* Maxpacket size for EP0 */

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

    0xAB,0x00,                      /* Product ID - Using the Cypress USB-UART PID for driver binding */

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

    0x01,                           /* Manufacture string index */

    0x02,                           /* Product string index */

    0x03,                           /* Serial number string index */

    0x01                            /* Number of configurations */

};

/* Standard device descriptor for USB 2.0 */

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

{

    0x12,                           /* Descriptor size */

    CY_U3P_USB_DEVICE_DESCR,        /* Device descriptor type */

    0x10,0x02,                      /* USB 2.10 */

    0x02,                           /* Device class */

    0x00,                           /* Device sub-class */

    0x00,                           /* Device protocol */

    0x40,                           /* Maxpacket size for EP0  */

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

    0xAB,0x00,                      /* Product ID  - Using the Cypress USB-UART PID for driver binding */

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

    0x01,                           /* Manufacture string index */

    0x02,                           /* Product string index */

    0x03,                           /* Serial number string index */

    0x01                            /* Number of configurations */

};

2. String Descriptor:

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

{

    0x04,                           /* Descriptor size */

    0x03,                           /* Device descriptor type */

    'A',0x00                        /* Additional characters can be added.

                                       The descriptor size should be modified accordingly */

};

3. Header File

extern const uint8_t CyFxUSBSerialNumberDscr[];

4. Firmware:

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

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyFxAppErrorHandler(apiRetStatus);

}

- Once these modifications have been performed, the device comes with a device instance path as follows.

USB\VID_04B4&PID_00AB\A

- I have attached the UsbUart project that comes with the FX3 SDK along with these modifications.

- On the host side, to identify the devices based on the device instance, the SetupDiGetDeviceInstanceId() API from the SetupAPI.lib library can be used. I have attached the host application source and binary file which can identify the device instance of a COM port device and compare it with a pre-loaded device instance ID. I have defined the device instance ID as below. This can be modified to use your VID/PID/Serial number.

const TCHAR reqDevInstanceId[] = L"USB\\VID_04B4&PID_00AB\\5&1FC31FA80&14";

- The attached host application only identifies the device based on the instance path and does not create a handle to the device. The process of communicating with the device has not been explained in the host application.

Password for the attachments: cypress

Please get back in case you have further queries.

Best regards,

Srinath S

Hi Srinath,

I modified my code as you mentioned but still the device instance path's random string has not changed.

I have given the string as "TEST" and this is my device's instance path.

USB\VID_04B4&PID_00AB&MI_02\6&3B55A959&0&0002

From the console application i could successfully read the instance path, but i would also like to read the COM port of the device.

Could you please help me on this.

Regards

Ajay

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Ajay,

- To display the device instance path as USB\VID_04B4&PID_00AB\TEST, use the attached descriptor file.

- To view the COM Port number in the host application, use the attached .CPP file.

Best regards,

Srinath S

0 Likes