eblot / pyftdi

FTDI device driver written in pure Python
Other
509 stars 212 forks source link

0.54.0 FT230x EEPROM API inaccuracies #351

Open timothy-lee2415 opened 1 year ago

timothy-lee2415 commented 1 year ago

Using pyftdi to bitbang on the FT230x CBUS pins. I want to check if CBUS functions are set to GPIO, and if not, set them to GPIO in EEPROM so I can use the cbus gpio APIs. I ran into a number of issues along with some inaccuracies with the APIs: Doing: ` ftdi = Ftdi() ftdi.open_from_url("ftdi://ftdi:ft-x:/1") if ftdi.has_cbus: print("Found CBUS enabled FTDI 230x")

eeprom = FtdiEeprom()
eeprom.connect(ftdi)
eeprom.set_property("cbus_func_0", "GPIO")
eeprom.set_property("cbus_func_1", "GPIO")
eeprom.set_property("cbus_func_2", "GPIO")
eeprom.set_property("cbus_func_3", "GPIO")
print(eeprom.commit(dry_run=False))
eeprom.reset_device()
eeprom.dump_config()`
eblot commented 1 year ago

Yeap, EEPROM support is mostly broken. Patches accepted.

JonathonReinhart commented 1 year ago

I also just noticed that Eeprom.commit() always returns the value of the dry_run argument:

https://github.com/eblot/pyftdi/blob/0d20ccd1ae4542d868a252c492ba6855b4e67906/pyftdi/eeprom.py#L657

Assuming self._ftdi.overwrite_eeprom(self._eeprom, dry_run=dry_run) does the right thing, it seems this should be:

        return not dry_run