Defining USB Serial No. Descriptor for USB Serial Component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Defining USB Serial No. Descriptor for USB Serial Component

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post 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'}};

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

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

Post 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

Post Reply