libftdi Archives

Subject: Re: libusb_init and libusb_exit in libftdi-1.0

From: David Wiberg <dwiberg@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 15 Jun 2011 22:34:36 +0200
Hello,

2011/6/14 Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>:
> Hello David,
>
> On Sunday, 22. May 2011 12:32:27 David Wiberg wrote:
>> I'm a new user of the libftdi-1.0 library and I have stumbled upon a
>> problem. I have a small test application which does a ftdi_init and
>> then a ftdi_deinit and the second call causes a segfault. The reason
>> seems to be that libusb_exit is called in ftdi_deinit but libusb_init
>> is only called in ftdi_usb_open_desc_index and ftdi_usb_find_all.
>>
>> My naive suggestion is to initialize libusb in ftdi_init but I don't
>> know if this causes other problems.
>
> Could you please be so nice and post
> your small test application?
>

I'm not sure if you want the code posted on the list or some pastebin
but since it's quite small I'll post it here this time. It's the
simple.c example modified to only perform init and deinit of the
library.

#include <stdio.h>
#include <stdlib.h>
#include <ftdi.h>

int main(void)
{
    int ret;
    struct ftdi_context ftdic;
    if (ftdi_init(&ftdic) < 0)
    {
        fprintf(stderr, "ftdi_init failed\n");
        return EXIT_FAILURE;
    }

    ftdi_deinit(&ftdic);

    return EXIT_SUCCESS;
}

Regards
David

> Thank you,
> Thomas
>
> --
> 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