libftdi Archives

Subject: Re: Re: Bug in libftdipp Context::open()

From: Peter Schneider <pitpompej@xxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 11 Feb 2011 10:41:53 +0100 (CET)
 Hi Thomas,

You are right. I also think a redesign  of the cpp-wrapper would be the way to 
go.
I was curiouse about the get_string() function and their behaviour of closing 
the device after
retreiving the device-strings. So far I guess your points are a good way.

I'll take a look at some points but I suspect I won't be able to implement any 
big stuff in the next 
2 month (have a little crunch time at work). But I'll stay tuned on this.

Greets
pit


----- Original Nachricht ----
Von:     Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
An:      libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Datum:   05.02.2011 18:34
Betreff: Re: Bug in libftdipp Context::open()

> Hello pit,
> 
> On 01/20/2011 01:27 PM, pitpompej@xxxxxxxx wrote:
> > I found a bug in the cpp-wrapper for the ftdi-lib that concerns nearly all
> open() functions of the Context-Class. All open-functions except the one
> with the usb_device parameter return with -1 (and error string "all fine")
> even if opening the device should be posssible (the ftdi-c version can open
> the same device). The reason for that behavior is, that they all use for the
> first connect to the device the correct ftdi-c-function concerning to the
> given parameters (open(vendor,pid) uses ftdi_usb_open(ftdi, vendor,
> product), open(description) uses ftdi_usb_open_string(ftdi,
> description.c_str()) and so on) but after the first connect they all use the
> ftdi_usb_get_strings function that needs as one parameter the usb_device.
> this has not been set before when using these special open-functions so it
> returns with an error and the open-function failes.
> > I have already implemented a fix in my sources by adding to further
> functions in the ftdi-c-lib that returns by reference the usb_device ande
> changed the concerning calls in the cpp-wrapper. That all works fine for me
> now.
> > But is a problem in the ftdi-cpp-wrapper worth a change in the
> ftdi-c-lib?
> > I will try to commit it if possible today, otherwise next week.
> 
> Thanks for the report and your patch!
> 
> Looking at the C++ wrapper three years later,
> I don't like the fact that I keeps an own "libusb_device *dev"
> pointer -and- a pointer to the ftdi_context. 
> 
> I think it can be improved without bloating the open()
> function of the C API. Something like this:
> 
> - Remove the libusb_device pointer in the C++ wrapper
> 
> - Provide a function in the C API to get the strings without
>   closing the device. Thinking about it some more, the C API
>   could do this by default, "wasting" some bytes for an
>   already open device is a non-issue.
> 
> - Kill the get_strings_and_reopen() function
> 
> - Implement is_open() in the C API and kill the
>   "open" flag, too.
> 
> What do you think?
> 
> Cheers,
> 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