libftdi Archives

Subject: Re: [Resent/Corrected] Interface can not be changed on an already open device

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 4 Oct 2011 18:49:26 +0200
>>>>> "Thomas" == Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> writes:

    Thomas> Uwe, On Tuesday, 4. October 2011 14:37:48 Uwe Bonnes wrote:
    >> + if (ftdi->usb_dev != NULL) + { + if ((ftdi->index != interface) &&
    >> ((ftdi->index == INTERFACE_A) && (interface != INTERFACE_ANY))) + +
    >> ftdi_error_return(-3, "Interface can not be changed on an already
    >> open device"); + }

    Thomas> Hmm, what about this:

    Thomas> - ftdi_set_interface(INTERFACE_B); - ftdi_usb_open() -
    Thomas> ftdi_set_interface(INTERFACE_A);

    Thomas> That won't be caught by the code above.

    Thomas> What about simplifying it to:

    Thomas> "if (ftdi->usb_dev && ftdi->index != interface)"

    Thomas> or does that break a valid use case?

The (not important) use-case I had in mind was opening with INTERFACE_ANY
and then changing to INTERFACE_A. But you are right, my logic is still
wrong.

Please use "if (ftdi->usb_dev && ftdi->index != interface)" for the sake of
simplicity.

Bye

-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread