Page 1 of 1

When using CDC-ACM Host class driver, how to access device-descriptor and config-descriptor of connected USB device?

Posted: Fri Mar 14, 2025 7:07 pm
by greengnu
I'm using the CDC-ACM Host component like in https://github.com/espressif/esp-idf/tr ... c_acm_host

I can output a printed version of the connected device-descriptor and config descriptor using

Code: Select all

cdc_acm_host_desc_print(cdc_dev);
Internally that function calls

Code: Select all

    const usb_device_desc_t *device_desc;
    const usb_config_desc_t *config_desc;
    ESP_ERROR_CHECK_WITHOUT_ABORT(usb_host_get_device_descriptor(cdc_dev->dev_hdl, &device_desc));
    ESP_ERROR_CHECK_WITHOUT_ABORT(usb_host_get_active_config_descriptor(cdc_dev->dev_hdl, &config_desc));
I would however like to call the usb_host_get_device_descriptor and usb_host_get_active_config_descriptor functions directly to get the device and config descriptors rather than just printing them out, the problem is that I only have a cdc_dev reference of type cdc_acm_dev_hdl_t. To be able to access dev_hdl I would have to cast it to type (cdc_dev_t*), which cdc_acm_dev_hdl_t is a typedef of through some forward declaration. The struct cdc_dev_t itself is defined in cdc_host_types.h, which is a 'private_include' in the esprif__usb_host_cdc_acm component.

What options do I have to get access to the device descriptor and config descriptor?