Proton BASIC Compiler - Re: How to add change CDC Descriptor serial number string


  • PicŪ Basic


  • How to add change CDC Descriptor serial number string

    All credit goes to Harm (had215 on forum). He pointed me to the solution. Thanks Harm!

    Adding a serial number to a USB/Serial Device has the advantage that the device will retain the same COM port number on all the USB ports of the PC. Otherwise, when you plug to different USB sockets you will get different COM port numbers. To modify the CDC Descriptor and add a serial number:

    Step #1: Under Desc_DeviceDescriptor table change the 13th item to:
    Code:
    Dt 0x03     ' Device serial number string index
    Step #2: Modify the String pointer table to add item for index 3:
    Code:
    Desc_USB_SD_Ptr:
    Desc_Strings:
        CData As Dword Desc_String0, Desc_String1, Desc_String2, Desc_String3
    Step #3: under Product string descriptor change to add item for index 3 (the serial number string)
    Code:
    ' Product string descriptor
    '
    Desc_String2:-
    dt (Desc_String3 - Desc_String2) / 2 ' Size of this descriptor (in bytes)
    dt cUSB_DESCRIPTOR_STRING ' String descriptor type
    CData As Dword "CDC RS-232 Emulation Demo" 
    '
    ' Serial number string descriptor
    '
    Desc_String3:-
    dt (_DescriptorMain_ - Desc_String3) / 2 ' Size of this descriptor (in bytes)
    dt cUSB_DESCRIPTOR_STRING ' String descriptor type
    CData As Dword "1234"
     
    _DescriptorMain_:
    $endif ' _CDC_DESC_INC_
    This article was originally published in forum thread: How to add change CDC Descriptor serial number string started by barak View original post