Skip to content

Commit 890bc61

Browse files
committed
Added serial number digits to usb itf strings
1 parent 8187c04 commit 890bc61

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
### Changes this version:
2+
- Added part of unique serial number to usb interface names for easier identification of multiple devices
3+
4+
### Changes in 1.12.x:
25
- Added support for Simplemotion V2 (Ioni/Argon motor drivers)

Firmware/FFBoard/Inc/USBdevice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
* This class defines a usb device and implements callbacks for getting the basic
2222
* usb descriptors for tinyusb.
2323
* Different usb configurations are predefined in usb_descriptors.c
24+
* appendSerial: adds the last n chars of the serial number to the interface strings
2425
*/
2526
class USBdevice : public cpp_freertos::Thread {
2627
public:
27-
USBdevice(const tusb_desc_device_t* deviceDesc,const uint8_t (*confDesc),const usb_string_desc_t* strings);
28+
USBdevice(const tusb_desc_device_t* deviceDesc,const uint8_t (*confDesc),const usb_string_desc_t* strings,uint8_t appendSerial = 4);
2829
virtual ~USBdevice();
2930
void Run(); // Thread loop
3031
void virtual registerUsb();
@@ -38,6 +39,7 @@ class USBdevice : public cpp_freertos::Thread {
3839
const tusb_desc_device_t* desc_device;
3940
const uint8_t* desc_conf; // Device configuration descriptor
4041
const usb_string_desc_t* string_desc;
42+
uint8_t appendSerial;
4143
};
4244

4345
#endif /* USB_SRC_USBDEVICE_H_ */

Firmware/FFBoard/Inc/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* For more settings see target_constants.h in a target specific folder
99
*/
1010

11-
static const uint8_t SW_VERSION_INT[3] = {1,12,0}; // Version as array. 8 bit each!
11+
static const uint8_t SW_VERSION_INT[3] = {1,12,1}; // Version as array. 8 bit each!
1212
#define MAX_AXIS 2 // ONLY USE 2 for now else screws HID Reports
1313
#define FLASH_VERSION 0 // Counter to increase whenever a full flash erase is required.
1414

Firmware/FFBoard/Src/USBdevice.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
uint16_t _desc_str[USB_STRING_DESC_BUF_SIZE]; // String buffer
1212

13-
USBdevice::USBdevice(const tusb_desc_device_t* deviceDesc,const uint8_t (*confDesc),const usb_string_desc_t* strings) :
14-
Thread("USB", 256, 40), desc_device(deviceDesc), desc_conf(confDesc), string_desc(strings) {
13+
USBdevice::USBdevice(const tusb_desc_device_t* deviceDesc,const uint8_t (*confDesc),const usb_string_desc_t* strings, uint8_t appendSerial) :
14+
Thread("USB", 256, 40), desc_device(deviceDesc), desc_conf(confDesc), string_desc(strings),appendSerial(appendSerial) {
1515

1616
}
1717

@@ -75,6 +75,11 @@ uint16_t* USBdevice::getUsbStringDesc(uint8_t index,uint16_t langid){
7575
field = string_desc->manufacturer;
7676
}else if(index > 3 && ((index - 4) < (int)string_desc->interfaces.size())){
7777
field = string_desc->interfaces[index-4];
78+
if(appendSerial){
79+
field += "(";
80+
field.append(getUsbSerial().substr(0, appendSerial));
81+
field += ")";
82+
}
7883
}else{
7984
return NULL;
8085
}

0 commit comments

Comments
 (0)