OpenNuvoton / M031BSP

BSP for M031 Series MCU
Apache License 2.0
15 stars 16 forks source link

USB Device unique name #8

Closed jeromeDms closed 2 years ago

jeromeDms commented 2 years ago

Hi I'm trying to make multiple identical devices appearing with different names on Windows/Mac. For instance, connecting 2 identical USB Devices appear as follow on the host side :

MyDevice In
MyDevice In

MyDevice Out
MyDevice Out

It seems the host can distinguish between devices if the USB descriptors implement unique "iSerialNumber" strings in the Device descriptor. The above should result in :

MyDevice In
2- MyDevice In

MyDevice Out
2- MyDevice Out

This could help customers to distinguish between the different USB connected devices. To make this possible, I can add an index to iSerialNumber in the device descriptor, but is there a way to make the string "dynamic" rather than defining as follow :

const uint8_t gu8StringSerial[] =
{
    4,             // bLength
    DESC_STRING,   // bDescriptorType
    '1', 0
};

Ideally if we could use FMC_ReadUID() and report the device ID in this gu8StringSerial that would be perfect. Thanks for any tips. Jerome

jeromeDms commented 2 years ago

Ok just forget my question, I found a way to build the gu8StringSerial[] at startup and use it as a non-constant string in descriptors :-)