Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eeprom: add support to use CBUS IntEnum in _set_cbus_func #364

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

talhaHavadar
Copy link

@talhaHavadar talhaHavadar commented Dec 1, 2023

This commit adds the capability of using FtdiEeprom.CBUS, CBUSH and CBUSX while setting cbus functionality as shown in the example below.

	eeprom = FtdiEeprom()
	eeprom.connect(f) # f is the instance of Ftdi
	eeprom.set_property("cbus_func_0", eeprom.CBUSX.GPIO)

Previously, we had to use the string to set the property for specific CBUS. And when we want to use it like the example above it was giving the following error messages:

Traceback (most recent call last):
  File "/home/talha/projects/pyftdi/test.py", line 45, in <module>
    eeprom.set_property("cbus_func_0", eeprom.CBUSX.GPIO)
  File "/home/talha/projects/pyftdi/pyftdi/eeprom.py", line 490, in set_property
    raise ValueError("'{name}' should be specified as a string")
ValueError: '{name}' should be specified as a string
Traceback (most recent call last):
  File "/home/talha/projects/pyftdi/test.py", line 45, in <module>
    eeprom.set_property("cbus_func_0", eeprom.CBUSX.GPIO)
  File "/home/talha/projects/pyftdi/pyftdi/eeprom.py", line 491, in set_property
    self._set_cbus_func(int(mobj.group(1)), value, out)
  File "/home/talha/projects/pyftdi/pyftdi/eeprom.py", line 896, in _set_cbus_func
    code = cbus[value.upper()].value
AttributeError: 'CBusX' object has no attribute 'upper'

This commit adds the capability of using FtdiEeprom.CBUS, CBUSH and CBUSX
while setting cbus functionality as shown in the example below.
	eeprom = FtdiEeprom()
	eeprom.connect(f) # f is the instance of Ftdi
	eeprom.set_property("cbus_func_0", eeprom.CBUSX.GPIO)

Previously, we had to use the string to set the property for specific CBUS

Signed-off-by: Talha Can Havadar <talha.can.havadar@canonical.com>
pyftdi/eeprom.py Outdated Show resolved Hide resolved
Co-authored-by: Evandro Arruda <ecarruda@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants