We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d01a44 commit fff8541Copy full SHA for fff8541
hardware/arduino/avr/cores/arduino/PluggableUSB.cpp
@@ -50,16 +50,15 @@ int PluggableUSB_::getDescriptor(USBSetup& setup)
50
return 0;
51
}
52
53
-char* PluggableUSB_::getShortName(void)
+uint8_t PluggableUSB_::getShortName(char* _iSerialNum, uint8_t max_len)
54
{
55
- char* ret = 0;
56
- memset(_iSerialNum, 0, sizeof(_iSerialNum));
+ uint8_t ret = 0;
+ memset(_iSerialNum, 0, max_len);
57
PluggableUSBModule* node;
58
- for (node = rootNode; node; node = node->next) {
59
- ret = node->getShortName();
60
- memcpy(&_iSerialNum[strlen(_iSerialNum)], ret, strlen(ret));
+ for (node = rootNode; node && ret < max_len; node = node->next) {
+ ret += node->getShortName(&_iSerialNum[ret]);
61
62
- return _iSerialNum;
+ return ret;
63
64
65
bool PluggableUSB_::setup(USBSetup& setup)
hardware/arduino/avr/cores/arduino/PluggableUSB.h
@@ -35,7 +35,7 @@ class PluggableUSBModule {
35
virtual bool setup(USBSetup& setup) = 0;
36
virtual int getInterface(uint8_t* interfaceCount) = 0;
37
virtual int getDescriptor(USBSetup& setup) = 0;
38
- virtual char* getShortName(void) = 0;
+ virtual uint8_t getShortName(char* name) { name[0] = 'A'+pluggedInterface; return1; }
39
40
uint8_t pluggedInterface;
41
uint8_t pluggedEndpoint;
@@ -56,12 +56,11 @@ class PluggableUSB_ {
int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup);
bool setup(USBSetup& setup);
- char* getShortName(void);
+ uint8_t getShortName(char* _iSerialNum, uint8_t max_len);
private:
uint8_t lastIf;
uint8_t lastEp;
- char _iSerialNum[20] = {0};
PluggableUSBModule* rootNode;
66
};
67
hardware/arduino/avr/cores/arduino/USBCore.cpp
@@ -504,7 +504,8 @@ bool SendDescriptor(USBSetup& setup)
504
505
else if (setup.wValueL == ISERIAL) {
506
#ifdef PLUGGABLE_USB_ENABLED
507
- char* name = PluggableUSB().getShortName();
+ char name[ISERIAL_MAX_LEN];
508
+ PluggableUSB().getShortName(name, sizeof(name));
509
return USB_SendStringDescriptor((uint8_t*)name, strlen(name), 0);
510
#endif
511
hardware/arduino/avr/cores/arduino/USBDesc.h
@@ -24,6 +24,8 @@
24
#define USB_ENDPOINTS 5 // AtMegaxxU2
25
26
27
+#define ISERIAL_MAX_LEN 20
28
+
29
#define CDC_INTERFACE_COUNT 2
30
#define CDC_ENPOINT_COUNT 3
31
hardware/arduino/avr/libraries/HID/HID.cpp
@@ -57,14 +57,13 @@ int HID_::getDescriptor(USBSetup& setup)
return total;
-char* HID_::getShortName()
+uint8_t HID_::getShortName(char* name)
- static char name[7] = {0};
char num[3];
memcpy(name, "HID", 3);
itoa(descriptorSize, num, 10);
memcpy(&name[3], num, 3);
- return name;
+ return strlen(name);
68
69
70
void HID_::AppendDescriptor(HIDSubDescriptor *node)
hardware/arduino/avr/libraries/HID/HID.h
@@ -96,7 +96,7 @@ class HID_ : public PluggableUSBModule
96
97
98
99
+ uint8_t getShortName(char* name);
100
101
102
uint8_t epType[1];
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments