From 84d5c59dfea53258f3032c6f8d7c4d8e30248264 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Sun, 1 May 2022 17:09:53 +0200 Subject: [PATCH] ftdipp_mpsse: don't throw exception when iProduct is empty: display warn and use empty string --- src/ftdipp_mpsse.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index b870653..1eab50f 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -74,10 +74,16 @@ FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev, ret = (libusb_error)libusb_get_string_descriptor_ascii(_ftdi->usb_dev, usb_desc.iProduct, _iproduct, 200); + /* when FTDI device has no iProduct, libusb return an error + * but there is no distinction between + * real error and empty field + */ if (ret < 0) { - snprintf(err, sizeof(err), "unable to get string descriptor: %d %s %s", - ret, libusb_error_name(ret), libusb_strerror(ret)); - throw std::runtime_error(err); + snprintf(err, sizeof(err), + "Can't read iProduct field from FTDI: " + "considered as empty string"); + printWarn(err); + memset(_iproduct,'\0', 200); } }