libftdi Archives

Subject: Re: [bug] ftdi c++ bindings broken?

From: David Kuehling <dvdkhlng@xxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 24 Oct 2011 12:03:05 +0200
>>>>> "Uwe" == Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

>>>>> "David" == David Kuehling <dvdkhlng@xxxxxx> writes:
>>>>> "Uwe" == Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
>>>>> "David" == David Kuehling <dvdkhlng@xxxxxx> writes:
David> hi, just tried to make the ftdipp library from git head work, but
David> my test program already fails in Context::open(vendor,product).
David> The other libftdi programs supplied in the example/ directory
David> seem to work.

David> open(vendor,product) calls ftdi_usb_open(), which succeeds, then
David> calls get_strings_and_reopen(), which calls get_strings(), which
David> calls ftdi_usb_get_strings(), which fails, as it passes in d->dev
David> which hasn't been set yet.

David> Maybe the correct fix is to set d->dev to d->ftdi->dev after
David> ftdi_usb_open()?

>>> Perhaps create a small example program in the example directory that
>>> shows the error. Then create a patch to fix that error and send the
>>> patches...

David> I'm just using libftdi for the first time, and wasn't prepared to
David> debug that problem in-depth.  That's why my bug report is a
David> little shallow and doesn't provide a working patch.

> I requested more the program or better a stripped down version of that
> program. That way, other may reproduce the bug and look for a fix.

Try this program:

--8<--
#include <stdio.h>
#include <assert.h>
#include <ftdi.hpp>

int main()
{
    Ftdi::Context ctx;
    int result;
    const unsigned vendor = 0x0403;
    const unsigned device = 0x6010;

    result = ctx.set_interface(INTERFACE_A);
    assert(result == 0);
    result = ctx.open(vendor, device);
    if (result)
    {
        fprintf(stderr, "open(): %s\n", ctx.error_string());
        return 1;
    }
    
    return 0;
}
--8<--

compiles via (when saved as 'ftdibug.cpp'):

make CXXFLAGS='-I/usr/local/include/libftdi -I/usr/include/libusb-1.0 -lftdipp 
-lftdi -lusb-1.0' ftdibug

This outputs:

open(): all fine

i.e. open() returns nonzero, but there's no corresponding error message.

cheers,

David
-- 
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40

Attachment: pgp80lvyNwxVa.pgp
Description: PGP signature

Current Thread