libftdi Archives

Subject: Re: Decode/Encode use_usb_version on BM and 2232C

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 4 Oct 2010 11:42:36 +0200
>>>>> "Thomas" == Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> writes:

    Thomas> Hello Uwe, On Saturday, 2. October 2010 17:34:16 Uwe Bonnes
    Thomas> wrote:
    >> index e33572b..0b19838 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@
    >> -2490,6 +2490,11 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
    >> case TYPE_BM: output[0x0C] = eeprom->usb_version & 0xff; output[0x0D]
    >> = (eeprom->usb_version>>8) & 0xff; + if (eeprom->use_usb_version ==
    >> USE_USB_VERSION_BIT) + output[0x0A] |= USE_USB_VERSION_BIT; + else +
    >> output[0x0A] &= ~USE_USB_VERSION_BIT; + break; case TYPE_2232C:

    Thomas> Thanks for your patch(es)!

    Thomas> One thing I noticed: The "use_usb_version" field and
    Thomas> "use_serial" fields contain either zero or f.e. 0x10. Without
    Thomas> taking a close look at the API implementation, I would expect
    Thomas> them to be zero or one.

    Thomas> That's also the way the previous eeprom code handled the
    Thomas> use_serial field.  Could we change that to the old behavior?

So you mean
> +        if (eeprom->use_usb_version != 0)
> +            output[0x0A] |= USE_USB_VERSION_BIT;
> +        else
> +            output[0x0A] &= ~USE_USB_VERSION_BIT;
> +

Where a value is a single bit, I decided to set the appropriate bit in the
decoded structure. I think, this is some protection against nonsense values,
set unintentionally. But I can change back to a test for non-zero or one if
you think this is better.

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