Skip to content
Snippets Groups Projects
Commit ea894b1e authored by Cristian Maglie's avatar Cristian Maglie Committed by Sandeep Mistry
Browse files

Fixed USB sendStringDescriptor

parent fe4747b0
No related branches found
No related tags found
No related merge requests found
......@@ -90,18 +90,18 @@ bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint8_t maxlen)
if (maxlen < 2)
return false;
uint16_t buff[maxlen/2];
int l = 1;
uint8_t buffer[maxlen];
buffer[0] = 0x03;
buffer[1] = strlen(string) * 2 + 2;
maxlen -= 2;
while (*string && maxlen>0)
{
buff[l++] = (uint8_t)(*string++);
maxlen -= 2;
uint8_t i;
for (i = 2; i < maxlen && *string; i++) {
buffer[i++] = *string++;
if (i == maxlen) break;
buffer[i] = 0;
}
buff[0] = (3<<8) | (l*2);
return USBDevice.sendControl((uint8_t*)buff, l*2);
return USBDevice.sendControl(buffer, i);
}
bool _dry_run = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment