libftdi Archives

Subject: Re: Understanding the jtag/mpsse example

From: Emmanuel Blot <>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 30 Jul 2010 12:53:10 +0200
> I am attempting to do some implementation using ctypes, I was
> wondering how you declared ftdi_context in your code?

As the exact C structure:

class FtdiContext(Structure):
    """Libftdi context, as a Python ctypes structure"""
    _fields_ = [# USB specific
                ('usb_dev', POINTER(UsbDevice)),
                ('usb_read_timeout', c_int),
                ('usb_write_timeout', c_int),
                # FTDI specific
                ('type', c_int),
                ('baudrate', c_int),
                ('bitbang_enabled', c_ubyte),
                ('readbuffer', POINTER(c_ubyte)),
                ('readbuffer_offset', c_uint),
                ('readbuffer_remaining', c_uint),
                ('readbuffer_chunksize', c_uint),
                ('writebuffer_chunksize', c_uint),
                # FTDI FT2232C
                ('interface', c_int),
                ('index', c_int),
                # Endpoints
                ('in_ep', c_int),
                ('out_ep', c_int),
                ('bitbang_mode', c_ubyte),
                ('eeprom_size', c_int),
                ('error_str', POINTER(c_char)),
                ('async_usb_buffer', POINTER(c_char)),
                ('async_usb_buffer_size', c_uint)]

> This makes sense I think, but declaring ftdi_context as a struct in
> ctypes seems difficult.

Not really difficult per se.
It's just annoying to declare the USB structures (I've done it to
perform some debug tasks), but it's quite easy to write.


libftdi - see for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread