libftdi Archives

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

From: Harald Bergmann <harald.bergmann@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 18 Jul 2024 10:52:09 +0200
Hi David,

sorry, I am not too familiar with the driver operation in detail, but I guess this general hint could be useful:
  • The device information, which you like to receive, cannot be generated by the driver. Instead the manufacturer need to provide those in the devices non-volatile memory.
  • A driver acting under those conditions needs always be aware of this fact and needs to provide tests for an „empty“ status.
    • Reaction in case of emptiness could be generation of some standard value like „<undefined>“ or an error status.
  • Without such care, you would receive garbage as shown.
    • In this case your application can do, what the driver missed.
      • Empty condition would likely be defined as returning byte values outside of [0-9a-zA-Z_] in regular _expression_ syntax.

Best regards,
Harald

Am 17.07.2024 um 06:54 schrieb David Walton <dwaltoneng@xxxxxxxxx>:

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





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


Current Thread