1

Hello I tried to program EEPROM FTDI with using a FTDI library -> https://github.com/snmishra/ftd2xx/blob/master/ftd2xx/ftd2xx.py and D2XX FTDI Programming Guide

def eeProgram(self, progdata=None, *args, **kwds):
    if progdata is None:
       progdata = _ft.ft_program_data(**kwds)
    progdata.Signature1 = _ft.DWORD(0)
    progdata.Signature2 = _ft.DWORD(0xffffffff)
    progdata.Version = _ft.DWORD(2)
    call_ft(_ft.FT_EE_Program, self.handle, progdata)
    return None

I created instance to FTD2XX(Object)

handler = _ft.FT_HANDLE()
call_ft(_ft.FT_Open, 0, c.byref(handler))
device = FTD2XX(handler)

And call a function eeProgram

 device.eeProgram(0,0xffffffff,2,"FTDI","FT")
 device.close()

After that i got error:

Traceback (most recent call last):
  File "ftd2xx.py", line 678, in <module>    
    device.eeProgram(0,0xffffffff,2,"FTDI","FT")
  File "ftd2xx.py", line 573, in eeProgram
    progdata.Signature1 = _ft.DWORD(0)
AttributeError: 'int' object has no attribute 'Signature1'

I can connect and communicate with device via python but that function doesn't work. Anyone know what I should do to program a device with that function?

6
  • What do you get when you print progdata Commented Dec 12, 2017 at 8:17
  • Please fix the indentation! Commented Dec 12, 2017 at 8:18
  • i got 0 when i call print before init progdata.Signature1, @mrCarnivore, fixed now Commented Dec 12, 2017 at 8:22
  • @pazucj: See my answer. Everything fits together... Commented Dec 12, 2017 at 8:25
  • What do you actually want these arguments to represent? We can't tell from your non-working code what the working code should do. Commented Dec 12, 2017 at 8:51

1 Answer 1

2

As the error message shows: progdata is an int.

device.eeProgram(0,0xffffffff,2,"FTDI","FT")

First argument of eeProgram is progdata and it clearly is an int and not a class that might have a method or attribute Signature.

Caveat: The first argument is the 0, since device is the self? argument from the function definition. So you need to change the 0 to a class instance of whatever class eeProgram is a method of.

Sign up to request clarification or add additional context in comments.

17 Comments

Maybe point out even more explicitly that the first argument 0 is what gets bound to the progdata keyword in the method call.
When I call device.eeProgram(None,0,0xffffffff,2,"FTDI","FT") i got function error after call_ft
I don't have idea how I could call function succesfully :(
@tripleee: Thanks for the hint I have extended my answer.
eeProgram is a function of class FTD2XX(object) , I called that function device.eeProgram, u write that I should call like this ? device.eeProgram(device,0,0xffffffff,2,"FTDI","FT") When I compile a program, the error isn't show but when I try to catch exception when it fails it shows me that function fails
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.