Skip to content

Commit f2c276d

Browse files
authored
Merge pull request hathach#1372 from tannewt/fix_string_desc
Fix string descriptor fetch
2 parents 144ce09 + f291243 commit f2c276d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/host/usbh.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ bool tuh_descriptor_string_manufacturer_get(uint8_t daddr, uint16_t language_id,
333333
{
334334
TU_VERIFY(tuh_mounted(daddr));
335335
usbh_device_t const* dev = get_device(daddr);
336+
if (dev->i_manufacturer == 0) {
337+
return false;
338+
}
336339
return tuh_descriptor_string_get(daddr, language_id, dev->i_manufacturer, buffer, len, complete_cb);
337340
}
338341

@@ -341,6 +344,9 @@ bool tuh_descriptor_string_product_get(uint8_t daddr, uint16_t language_id, void
341344
{
342345
TU_VERIFY(tuh_mounted(daddr));
343346
usbh_device_t const* dev = get_device(daddr);
347+
if (dev->i_product == 0) {
348+
return false;
349+
}
344350
return tuh_descriptor_string_get(daddr, language_id, dev->i_product, buffer, len, complete_cb);
345351
}
346352

@@ -349,6 +355,9 @@ bool tuh_descriptor_string_serial_get(uint8_t daddr, uint16_t language_id, void*
349355
{
350356
TU_VERIFY(tuh_mounted(daddr));
351357
usbh_device_t const* dev = get_device(daddr);
358+
if (dev->i_serial == 0) {
359+
return false;
360+
}
352361
return tuh_descriptor_string_get(daddr, language_id, dev->i_serial, buffer, len, complete_cb);
353362
}
354363

@@ -960,9 +969,9 @@ static bool enum_get_device_desc_complete(uint8_t dev_addr, tusb_control_request
960969

961970
dev->vid = desc_device->idVendor;
962971
dev->pid = desc_device->idProduct;
963-
// dev->i_manufacturer = desc_device->iManufacturer;
964-
// dev->i_product = desc_device->iProduct;
965-
// dev->i_serial = desc_device->iSerialNumber;
972+
dev->i_manufacturer = desc_device->iManufacturer;
973+
dev->i_product = desc_device->iProduct;
974+
dev->i_serial = desc_device->iSerialNumber;
966975

967976
// if (tuh_attach_cb) tuh_attach_cb((tusb_desc_device_t*) _usbh_ctrl_buf);
968977

0 commit comments

Comments
 (0)