ftdi chip + ctypes + ftd2xx... need help with reading chipid! (now with the right source code!)

Egor Zindy ezindy at gmail.com
Sat Jul 19 06:33:17 EDT 2008


Egor Zindy wrote:
> Dear List,
>
> This one is way beyond my comprehension skills, I just don't 
> understand what I'm doing wrong.
>
> I am trying to read the chipid from an FTDI chip based USB key 
> (DLP-D,  http://www.ftdichip.com/Products/EvaluationKits/DLP-D.htm ), 
> using:
>
> - the ftd2xx module http://pypi.python.org/pypi/ftd2xx/0.1
> - the ftd2xx.dll which comes with the driver install
> - the chipid dll (1.1.0) from here: 
> http://www.ftdichip.com/Projects/FTDIChip-ID.htm
> - a ctypes interface I wrote by hand (only 7 functions to wrap, I 
> thought it'd be easy!)
>
> The ftd2xx is used for testing, to open / close the device.
>
> My Problem is that neither of the following two wrapped functions 
> (with the exact same arguments) return the right result (full 
> chipid.py library attached):
>
>    def FTID_GetDeviceLocationID(DeviceIndex):
>        n = DWORD()
>        status = ftchipid.FTID_GetDeviceLocationID(DeviceIndex, 
> ctypes.byref(n))
>
>        if status != FTID_SUCCESS:
>            raise DeviceError,FTID_GetErrorCodeString("EN",status)
>
>        return n.value
>
>    def FTID_GetDeviceChipID(DeviceIndex):
>        n = DWORD()
>        status = ftchipid.FTID_GetDeviceChipID(DeviceIndex, 
> ctypes.byref(n))
>
>        if status != FTID_SUCCESS:
>            raise DeviceError,FTID_GetErrorCodeString("EN",status)
>
>        return n.value
>
> * On my machine (XP, 32 bits), if I plug two keys in, I can get the 
> device chip id from the device with index=1. The one with index=0 
> always gives the message "Invalid device handle."
> * I get the wrong location id as well, 0 instead of 0x21...
> * the FTID_GetNumDevices function also uses a byref, c_ulong and works.
> * FTDI's win32 console example returns the right results (and uses c 
> unsigned longs) - available from 
> http://www.ftdichip.com/Projects/FTDIChip-ID.htm
>
> Any help appreciated!
>
> Regards,
> Egor
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: chipid.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20080719/a82b5423/attachment-0001.ksh>


More information about the Python-list mailing list