libftdi Archives

Subject: Using cpp, how do you get the eeprom strings from an already open device?

From: David Walton <dwaltoneng@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 17 Jul 2024 14:54:39 +1000
Test code:

#include <ftdi.hpp>
#include <string>
#include <fmt/core.h>

int main(int argc, char **argv)
{
    int vid = 0x0403, pid = 0x6010;

    Ftdi::Context ftdi_context;
    std::string ftdi_description("Lattice FTUSB Interface Cable");
    if (ftdi_context.open(vid, pid, ftdi_description) != 0)
    {
        fmt::print("Failed to open \"{:s}\" \"{:s}\"\n", ftdi_description, ftdi_context.error_string());
    }
    else
    {
        auto vendor = ftdi_context.vendor();
        auto description = ftdi_context.description();
        auto serial = ftdi_context.serial();
        fmt::print("Vendor \"{:s}\", Description \"{:s}\", Serial \"{:s}\"\n", vendor, description, serial);
    }

    return EXIT_SUCCESS;
}

I was hoping that my test code would return the following:
Vendor "Lattice", Description "Lattice FTUSB Interface Cable", Serial ""

Instead I get the following:
Vendor "�U���", Description "Lattice FTUSB Interface Cable", Serial "@"

Is there something else that needs to be done for ftdi_context.vendor() and ftdi_context.serial() to be populated?




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


Current Thread