libftdi Archives

Subject: Re: c++ wraper: open(vid,pid) fails for devices with a missing iManufacturer, iProduct or iSerial

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx, Matthias Janke <matthias.janke@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 May 2017 21:26:23 +0200
Hi Matthias,

Am 12.05.2017 um 13:32 schrieb Matthias Janke:
>   I'm using the c++ wrapper of libftdi (git co of yesterday) to
>   communicate with a FT2232HL on a Lattice XO2 Eval board
>   (LCMXO2-7000HE-B-EVN) this board has no programmed in iSerial.
>   
>   A simple c++ program which just opens and closes the device fails with
>   "libusb_get_string_descriptor_ascii() failed" this is also true for
>   the find_all_pp example (find_all, works). This failure originates in
>   the use of the get_strings() function inside all c++ open() functions.
>   This function wants all three iManufractuer, iProduct and iSerial to be
>   present. The C-API allows one to pass NULL to ignore these descriptors.
>   This is currently not possible with the c++ api. To properly fix this I
>   suspect an api break is needed. As temporary ugly workaround I use the
>   appended patch. Are there other ideas to fix this? 

what about this open() function from ftdi.cpp:

int Context::open(int vendor, int product, const std::string&
description, const std::string& serial, unsigned int index)
{
    // translate empty strings to NULL
    // -> do not use them to find the device (vs. require an empty
string to be set in the EEPROM)
    const char* c_description=NULL;
    const char* c_serial=NULL;
    if (!description.empty())
        c_description=description.c_str();
    if (!serial.empty())
        c_serial=serial.c_str();

    int ret = ftdi_usb_open_desc_index(d->ftdi, vendor, product,
c_description, c_serial, index);

    if (ret < 0)
       return ret;

    return get_strings_and_reopen();
}



-> if you pass an empty string for "std::string serial",
it should pass down NULL for the serial parameter of the C API.

What happens if you use this specific open() function?

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread