USB Device ID

16 Oct 2012

Hi, I have prototyped several USBMIDI devices and was wondering if there's any way to change the Device ID. I want to change the midi port name that appears on the host pc when one of my devices is connected. Many thanks, James Spadavecchia

16 Oct 2012

Hello James, if You mean name of device and interface, open Your project, select USBdevice library, open it, open USBMIDI, select USBMIDI.cpp file and scroll down when You will see:


uint8_t * USBMIDI::stringIinterfaceDesc() {
    static uint8_t stringIinterfaceDescriptor[] = {
        0x0c,                           //bLength
        STRING_DESCRIPTOR,              //bDescriptorType 0x03
        'A',0,'u',0,'d',0,'i',0,'o',0   //bString iInterface - Audio
    };
    return stringIinterfaceDescriptor;
}

uint8_t * USBMIDI::stringIproductDesc() {
    static uint8_t stringIproductDescriptor[] = {
        0x16,                                                       //bLength
        STRING_DESCRIPTOR,                                          //bDescriptorType 0x03
        'M',0,'b',0,'e',0,'d',0,' ',0,'A',0,'u',0,'d',0,'i',0,'o',0 //bString iProduct - Mbed Audio
    };
    return stringIproductDescriptor;
}

First is name of interface, second is name of device itself.

You must keep the same format as above so every letter or space must be followed by 0. Then You have to change value named bLength (first value of each of this descriptors) to match new length. It is computed as bLength itself is one byte + descriptor type is one byte + number of letters and zeros in name.

So above You can see interface name is Audio. So bLength value will be 5 bytes for letters + 5 bytes for zeros + 2 bytes for blength + descriptor type. So it is 12 and 0x0C in hex.

16 Oct 2012

Hi, that's exactly what I'm looking for. Thank you!