Skip to content

iserial for USB device #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hexxter opened this issue Mar 13, 2025 · 2 comments
Open

iserial for USB device #347

hexxter opened this issue Mar 13, 2025 · 2 comments

Comments

@hexxter
Copy link

hexxter commented Mar 13, 2025

is it possible to set an unique iserial ?
then i can use a udev rule to bind fix multible devices without any problems

@ceres-c
Copy link
Contributor

ceres-c commented Mar 13, 2025

USB is handled by LUFA iirc, so you better check if the lib is configurable in this regard

@hexxter
Copy link
Author

hexxter commented Mar 17, 2025

I think you should build this in an if anyone need it then a different version could be easy compiled

diff --git a/firmware/src/Descriptors.c b/firmware/src/Descriptors.c
index 1234567..89abcde 100644
--- a/firmware/src/Descriptors.c
+++ b/firmware/src/Descriptors.c
@@
 /* Device Descriptor Structure */
 const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
 {
     .Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
     .USBSpecification       = VERSION_BCD(2,0,0),
     .Class                  = USB_CSCP_NoDeviceClass,
     .SubClass               = USB_CSCP_NoDeviceSubclass,
     .Protocol               = USB_CSCP_NoDeviceProtocol,
     .Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,
 
     /* Vendor and Product ID */
     .VendorID               = 0x03EB,
     .ProductID              = 0x204F,
     .ReleaseNumber          = VERSION_BCD(0,0,1),
 
-    .ManufacturerStrIndex   = STRING_ID_Manufacturer,
-    .ProductStrIndex        = STRING_ID_Product,
-    .SerialNumStrIndex      = 0,
+    .ManufacturerStrIndex   = STRING_ID_Manufacturer,
+    .ProductStrIndex        = STRING_ID_Product,
+    .SerialNumStrIndex      = STRING_ID_Serial,
 
     .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
 };
@@
 /* String Descriptor Definitions */
 
 // Manufacturer and Product string descriptors are already defined above
 
+// New Serial Number string descriptor
+// Adjust the serial string (or generate dynamically) as needed.
+const USB_Descriptor_String_t PROGMEM SerialString =
+{
+    .Header                 = {.Size = USB_STRING_LEN(12), .Type = DTYPE_String},
+    .UnicodeString          = L"CHAM-123456"
+};
+
 /* A lookup table for the string descriptors. */
 const USB_Descriptor_String_t* const StringDescriptors[] =
 {
     [STRING_ID_Language]      = &LanguageString,
     [STRING_ID_Manufacturer]  = &ManufacturerString,
     [STRING_ID_Product]       = &ProductString,
+    [STRING_ID_Serial]        = &SerialString,
 };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants