This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to transfer data in two VCPs with DUAL CDC composite device

I have emulated two VCPs with only one USB Device. I can send data in one VCP that has the following Endpoint Address.

#define CDC_IN_EP                                   0x81  /* EP1 for data IN */
#define CDC_OUT_EP                                  0x01  /* EP1 for data OUT */
#define CDC_CMD_EP                                  0x82  /* EP2 for CDC commands */

I would like to know if it's possible to send data in the other VCP with other Endpoint Address like :

#define CDC_IN_EP3                                   0x83  /* EP3 for data IN */
#define CDC_OUT_EP3                                  0x03  /* EP3 for data OUT */
#define CDC_CMD_EP4                                  0x84  /* EP4 for CDC commands */

My problem is that addresses others than 0x81 don't allow me to send data over the second VCP. I'm using two CDC interfaces Full-Speed (Dual CDC Composite Device). Normally we can use 7 endpoints with CDC_FS and that's what I'm trying to do.. I have 6 Endpoints: 3 for each VCP and the seventh is Endpoint 0 for configuration.

Have I missed something in the Endpoints Configuration or in the Composite Device Descriptors ?

/* USB CDC device Configuration Descriptor */
__ALIGN_BEGIN uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
{
  /*Configuration Descriptor*/
  0x09,   /* bLength: Configuration Descriptor size */
  USB_DESC_TYPE_CONFIGURATION,      /* bDescriptorType: Configuration */
  USB_CDC_CONFIG_DESC_SIZ,                /* wTotalLength:no of returned bytes */
  0x00,
  0x04,   /* bNumInterfaces: 4 interface */
  0x01,   /* bConfigurationValue: Configuration value */
  0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
  0xC0,   /* bmAttributes: self powered */
  0x32,   /* MaxPower 100 mA */

  /*---------------------------------------------------------------------------*/

                // IAD0
        0x08,   // bLength: Interface Descriptor size
        0x0B,   // bDescriptorType: IAD
        0x00,   // bFirstInterface    OR 0x02 for the second IAD
        0x02,   // bInterfaceCount
        0x02,   // bFunctionClass: CDC
        0x02,   // bFunctionSubClass
        0x01,   // bFunctionProtocol
        0x02,   // iFunction

  /*Interface0 Descriptor */
  0x09,   /* bLength: Interface Descriptor size */
  USB_DESC_TYPE_INTERFACE,  /* bDescriptorType: Interface */
  /* Interface descriptor type */
  0x00,   /* bInterfaceNumber: Number of Interface */
  0x00,   /* bAlternateSetting: Alternate setting */     OR 0x02 for the second IAD
  0x01,   /* bNumEndpoints: One endpoints used */
  0x02,   /* bInterfaceClass: Communication Interface Class */
  0x02,   /* bInterfaceSubClass: Abstract Control Model */
  0x01,   /* bInterfaceProtocol: Common AT commands */
  0x00,   /* iInterface: */

  /*Header Functional Descriptor*/
  0x05,   /* bLength: Endpoint Descriptor size */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x00,   /* bDescriptorSubtype: Header Func Desc */
  0x10,   /* bcdCDC: spec release number */
  0x01,

  /*Call Management Functional Descriptor*/
  0x05,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  0x03,   /* bmCapabilities: D0+D1 */
  0x01,   /* bDataInterface: 1 */

  /*ACM Functional Descriptor*/
  0x04,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  0x02,   /* bmCapabilities */

  /*Union Functional Descriptor*/
  0x05,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x06,   /* bDescriptorSubtype: Union func desc */
  0x00,   /* bMasterInterface: Communication class interface */
  0x01,   /* bSlaveInterface0: Data Class Interface */


  /*Endpoint 2 Descriptor*/
  0x07,                           /* bLength: Endpoint Descriptor size */
  USB_DESC_TYPE_ENDPOINT,   /* bDescriptorType: Endpoint */
  CDC_CMD_EP,                     /* bEndpointAddress */   OR  CDC_CMD_EP4 for the second IAD
  0x03,                           /* bmAttributes: Interrupt */
  LOBYTE(CDC_CMD_PACKET_SIZE),     /* wMaxPacketSize: */
  HIBYTE(CDC_CMD_PACKET_SIZE),
  0xFF,                           /* bInterval: */
  /*---------------------------------------------------------------------------*/

  /*Data class interface descriptor*/
  0x09,   /* bLength: Endpoint Descriptor size */
  USB_DESC_TYPE_INTERFACE,  /* bDescriptorType: */
  0x01,   /* bInterfaceNumber: Number of Interface */   OR 0x03 for the second IAD
  0x00,   /* bAlternateSetting: Alternate setting */
  0x02,   /* bNumEndpoints: Two endpoints used */
  0x0A,   /* bInterfaceClass: CDC */
  0x00,   /* bInterfaceSubClass: */
  0x00,   /* bInterfaceProtocol: */
  0x00,   /* iInterface: */

  /*Endpoint OUT Descriptor*/
  0x07,   /* bLength: Endpoint Descriptor size */
  USB_DESC_TYPE_ENDPOINT,      /* bDescriptorType: Endpoint */
  CDC_OUT_EP,                  /* bEndpointAddress */   OR CDC_OUT_EP3 for the second IAD
  0x02,                              /* bmAttributes: Bulk */
  LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
  0x00,                              /* bInterval: ignore for Bulk transfer */

  /*Endpoint IN Descriptor*/
  0x07,   /* bLength: Endpoint Descriptor size */
  USB_DESC_TYPE_ENDPOINT,      /* bDescriptorType: Endpoint */
  CDC_IN_EP,                 /* bEndpointAddress */   OR CDC_OUT_EP3 for the second IAD
  0x02,                              /* bmAttributes: Bulk */
  LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
  0x00,                               /* bInterval: ignore for Bulk transfer */

} ;


Thank you guys.

  • Hi, I am having a similar issue. I am trying to find the cause of this problem but still no luck. Did you find a solution?

    Normally I can receive data from both interfaces (VCP1 & VCP2), and can transmit data on VCP1 interface. When i try to send something on VCP2 port, no data comes out to PC (teraterm) and usb stalls. If I swap the endpoint numbers, this time VCP2 works but VCP1 stops. Just like the case you mentioned.

    I tried to adjust TX FIFO sizes and still out of luck.

    Regards

  • Hi, I am facing a similar issue, Did you find any solution?

    We acquired the data from both virtual com ports, We are trying to transmit the data to both ports, but the single port(VCP1) is only working?

    Regards,

    naren

  • Have you guys seen this project?

    https://github.com/r2axz/bluepill-serial-monster

    bluepill-serial-monster is a firmware for STM32 Blue Pill that turns it into a 3 Port USB-to-Serial adapter. The firmware implements a USB 2.0 full-speed composite device that consists of 3 USB CDC devices.