2022-03-21 07:46 AM
USBD_FS_InterfaceStrDescriptor() is not called.
I fix it by changing iInterface by 5. To match this define:
#define USBD_IDX_INTERFACE_STR 0x05U
/* Data class interface descriptor */
0x09, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
0x01, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol */
0x05, /* iInterface */
Since it is erase by generate, I guess I'm doing something wrong to do it correcly. What should I do?
2022-03-28 02:09 AM
Hello @GerHebert
Be sure to write your code in the User Section so that it will not be deleted after the re-generation with CubeMX.
I hope this helps you.
BeST Regards,
Walid
2022-03-28 07:32 AM
Hi,
And how I do that for this descriptor in particular? Since it is static, I can't access it. Over that, usbd_cdc.c do not have any User Section.
And I think it should be set to 5 by default when generating the code and the field INTERFACE_STRING is fill-in into the IOC. No?
Germain
2022-03-28 08:47 AM
Hello @GerHebert
In order to allow a better analysis of your problem, could you please give us the .ioc file that you are used to reproduce this issue, so that we can give you an answer.
BeST Regards,
Walid
2022-03-28 09:43 AM
Hi Walid,
Here is the IOC.
Since the, I saw the new version of USB device 2.40 state it support composite descriptor. I didn't figure out how to use it yet. I don't see any options in IOC to do so. So I'm looking for the recipe to use with IOC if it is possible.
I was wondering if it is possible to do multiple CDC with new composite feature?
Thanks,
2022-03-28 10:02 AM
Maybe the host is not interested in the interface name at all.
Have you seen requests to this string before? maybe on other host OS?
2022-03-28 10:24 AM
Hi Pavel,
Yes I did, on linux and windows. I was using the GetUserStrDescriptor and patching the descriptor. But now, with the new release, it is supported but it isn't working. It is just missing a small fix to tell the description on which index the interface name is.
Germain
2022-03-30 02:22 AM
Hello @GerHebert
The USB Device library v2.10.0 supports new class drivers and composite device.
Unfortunately, we haven't provided yet any examples for this new USB device class driver.
Otherwise, you can find a short description in the driver files which may help you.
BeST Regards,
Walid
2022-03-31 12:52 PM
Walid,
Sorry, yes 2.10.0. I will get it without example. But I have question of how to do it with user section.
Example:
void MX_USB_DEVICE_Init(void)
{
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
USBD_CDC.GetUsrStrDescriptor = USBD_CDC_InterfaceStrDescriptor;
/* USER CODE END USB_DEVICE_Init_PreTreatment */
/* Init Device Library, add supported class and start the library. */
if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
{
Error_Handler();
}
if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
HAL_PWREx_EnableUSBVoltageDetector();
/* USER CODE END USB_DEVICE_Init_PostTreatment */
}
I can change stuff before and after. But I think I must call USBD_RegisterClassComposite() instead of USBD_RegisterClass(). How do I do that?
Same for USBD_CDC_RegisterInterface(), I'm quite sure it must be set before USBD_Start().
Do you have any hint for me.
Thanks,