Page 1 of 1

Defining USB Serial No. Descriptor for USB Serial Component

Posted: Mon Oct 19, 2020 7:11 pm
by Brendan
Hello all.

Quick question (hopefully)...

Just need to ask the easiest/best way to set the USB Serial Number in the descriptors for the USB Serial component?

Thanks,
Brendan

Re: Defining USB Serial No. Descriptor for USB Serial Component

Posted: Mon Oct 19, 2020 10:36 pm
by Benj
Hi Brendan,

Assuming you are using an 8-bit PIC you need to edit the following file.

Paste this address into your File explorer, without the quotes.

"C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\USB"

Then open this file in a text editor.

usb_serial_descriptors.c

This is the line you are looking for, approx line 270 in the file.

//Language code string descriptor
const struct{uint8_t bLength;uint8_t bDscType;uint16_t string[1];}sd000={
sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409}};

I've highlighted the part to change.

Here is some information regarding the serial number....

Serial number string descriptor. If a serial number string is implemented, it should be unique for every single device coming off the production assembly line. Plugging two devices with the same serial number into a computer simultaneously will cause problems (in extreme cases BSOD).
Note: Common OSes put restrictions on the possible values that are allowed.

For best OS compatibility, the serial number string should only consist of UNICODE encoded numbers 0 through 9 and capital letters A through F.
ROM struct{BYTE bLength;BYTE bDscType;WORD string[10];}sd003={sizeof(sd003),USB_DESCRIPTOR_STRING,{'0','1','2','3','4','5','6','7','8','9'}};

Re: Defining USB Serial No. Descriptor for USB Serial Component

Posted: Tue Oct 20, 2020 2:16 am
by Brendan
Hi Ben.

My sincere thanks for your time to kindly provide this information, and a huge help - Thank you!

From the instructions provided, it's clear I should have been a little more specific by saying that I'm coding for both 8-bit and 16-bit PICs requiring unique serials (mostly 16-bit these days), so anticipating the exact same procedure for

usb_serial_descriptors.c
in...
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC16BIT\USB

Thank you again 👍👍👍
Brendan