src/app/host-serial/libftdi/ftdi.c
int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct libusb_device * dev,
                         char * manufacturer, int mnf_len, char * description, int desc_len, char * serial, int serial_len)
{
    struct libusb_device_descriptor desc;

    if ((ftdi==NULL) || (dev==NULL))
        return -1;

    if (ftdi->usb_dev == NULL && libusb_open(dev, &ftdi->usb_dev) < 0)
            ftdi_error_return(-4, "libusb_open() failed");

    if (libusb_get_device_descriptor(dev, &desc) < 0)
        ftdi_error_return(-11, "libusb_get_device_descriptor() failed");

    if (manufacturer != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iManufacturer, (unsigned char *)manufacturer, mnf_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-7, "libusb_get_string_descriptor_ascii() failed");
        }
    }

    if (description != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iProduct, (unsigned char *)description, desc_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-8, "libusb_get_string_descriptor_ascii() failed");
        }
    }

    if (serial != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iSerialNumber, (unsigned char *)serial, serial_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-9, "libusb_get_string_descriptor_ascii() failed");
        }
    }

    ftdi_usb_close_internal (ftdi);

    return 0;
}
/**
    Return device ID strings from the usb device.

    The parameters manufacturer, description and serial may be NULL
    or pointer to buffers to store the fetched strings.

    \note Use this function only in combination with ftdi_usb_find_all()
          as it closes the internal "usb_dev" after use.

    \param ftdi pointer to ftdi_context
    \param dev libusb usb_dev to use
    \param manufacturer Store manufacturer string here if not NULL
    \param mnf_len Buffer size of manufacturer string
    \param description Store product description string here if not NULL
    \param desc_len Buffer size of product description string
    \param serial Store serial string here if not NULL
    \param serial_len Buffer size of serial string

    \retval   0: all fine
    \retval  -1: wrong arguments
    \retval  -4: unable to open device
    \retval  -7: get product manufacturer failed
    \retval  -8: get product description failed
    \retval  -9: get serial number failed
    \retval -11: libusb_get_device_descriptor() failed
*/
Return device ID strings from the usb device.
The parameters manufacturer, description and serial may be NULL
or pointer to buffers to store the fetched strings.

\note Use this function only in combination with ftdi_usb_find_all()
as it closes the internal "usb_dev" after use.




Return device ID strings from the usb device . The parameters manufacturer description and serial may be NULL or pointer to buffers to store the fetched strings . \ note Use this function only in combination with ftdi_usb_find_all () as it closes the internal " usb_dev " after use .
int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct libusb_device * dev,
                         char * manufacturer, int mnf_len, char * description, int desc_len, char * serial, int serial_len)
{
    struct libusb_device_descriptor desc;
    if ((ftdi==NULL) || (dev==NULL))
        return -1;
    if (ftdi->usb_dev == NULL && libusb_open(dev, &ftdi->usb_dev) < 0)
            ftdi_error_return(-4, "libusb_open() failed");
    if (libusb_get_device_descriptor(dev, &desc) < 0)
        ftdi_error_return(-11, "libusb_get_device_descriptor() failed");
    if (manufacturer != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iManufacturer, (unsigned char *)manufacturer, mnf_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-7, "libusb_get_string_descriptor_ascii() failed");
        }
    }
    if (description != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iProduct, (unsigned char *)description, desc_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-8, "libusb_get_string_descriptor_ascii() failed");
        }
    }
    if (serial != NULL)
    {
        if (libusb_get_string_descriptor_ascii(ftdi->usb_dev, desc.iSerialNumber, (unsigned char *)serial, serial_len) < 0)
        {
            ftdi_usb_close_internal (ftdi);
            ftdi_error_return(-9, "libusb_get_string_descriptor_ascii() failed");
        }
    }
    ftdi_usb_close_internal (ftdi);
    return 0;
}
int ftdi_usb_get_strings ( struct ftdi_context * ftdi , struct libusb_device * dev , char * manufacturer , int mnf_len , char * description , int desc_len , char * serial , int serial_len ) { struct libusb_device_descriptor desc ; if ( ( ftdi == NULL ) || ( dev == NULL ) ) return -1 ; if ( ftdi -> usb_dev == NULL && libusb_open ( dev , & ftdi -> usb_dev ) < 0 ) ftdi_error_return ( -4 , " " ) ; if ( libusb_get_device_descriptor ( dev , & desc ) < 0 ) ftdi_error_return ( -11 , " " ) ; if ( manufacturer != NULL ) { if ( libusb_get_string_descriptor_ascii ( ftdi -> usb_dev , desc . iManufacturer , ( unsigned char * ) manufacturer , mnf_len ) < 0 ) { ftdi_usb_close_internal ( ftdi ) ; ftdi_error_return ( -7 , " " ) ; } } if ( description != NULL ) { if ( libusb_get_string_descriptor_ascii ( ftdi -> usb_dev , desc . iProduct , ( unsigned char * ) description , desc_len ) < 0 ) { ftdi_usb_close_internal ( ftdi ) ; ftdi_error_return ( -8 , " " ) ; } } if ( serial != NULL ) { if ( libusb_get_string_descriptor_ascii ( ftdi -> usb_dev , desc . iSerialNumber , ( unsigned char * ) serial , serial_len ) < 0 ) { ftdi_usb_close_internal ( ftdi ) ; ftdi_error_return ( -9 , " " ) ; } } ftdi_usb_close_internal ( ftdi ) ; return 0 ; }
Return device ID strings from the usb device.
Return device ID strings from the usb device .