>>>>> "Daniel" == Daniel Kirkham <dk2@xxxxxxxxxxxxx> writes:
Daniel> Hi all, I just noticed an inconsistency in the handling of the
Daniel> max_power EEPROM value while writing a short program to
Daniel> reprogram my FT2232.
Daniel> In ftdi_eeprom_build (line 2580 of ftdi.c):
Daniel> output[0x09] = eeprom->max_power>>1;
Daniel> Whereas: in ftdi_eeprom_decode (line 3051 of ftdi.c):
eeprom-> max_power = buf[0x09];
Daniel> and further down in ftdi_eeprom_decode (line 3267):
Daniel> fprintf(stdout, "Bus Powered: %3d mA%s",
Daniel> eeprom->max_power * 2,
Daniel> and ftdi_get_eeprom_value (line 3448)
Daniel> *value = ftdi->eeprom->max_power;
Daniel> and ftdi_set_eeprom_value (line 3635)
ftdi-> eeprom->max_power = value;
Daniel> So, with the exception of line 2580, the value being passed
Daniel> around is the power requirement expressed as half the number of
Daniel> milliamperes (mA) required by the device, and that line 3267
Daniel> correctly translates this for presentation purposes. This is
Daniel> consistent with the way power units are specified within the USB
Daniel> protocols (ie. each unit is 2mA).
Daniel> On this basis, the bit-shift division in line 2580 should be
Daniel> removed: 2580: output[0x09] = eeprom->max_power;
Daniel> Alternatively, if the API defines that max_power should be
Daniel> expressed directly in mA, then lines 3051 and 3267 need to be
Daniel> adjusted to: 3051: eeprom->max_power = buf[0x09] * 2; 3267:
Daniel> fprintf(stdout, "Bus Powered: %3d mA%s", eeprom->max_power,
Daniel> Given these changes may break some usage, perhaps this needs to
Daniel> be discussed before patching the library one way or the other.
Thanks for catching this error. Getting it consistant probably doesn't
break much but mixes more. I propose having eeprom->max_power in mA.
Will you prepare a patch?
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
|