[edit 2013-11-25: note that recent versions of pylibftdi have deprecated and then removed the ability to use 'Driver' in this way; replace Driver
and BitBangDriver
with Device
and BitBangDevice
in the code below]
The playing-around I've done with FTDI devices seemed like a good opportunity to actually release something as open source, and so I present 'pylibftdi'. Undoubtedly not the greatest, but right now most likely the latest FTDI-Python bridge in the rather large open source field.
There are a few features I know I want to add to it (primarily support for multiple devices), but for a flavour of things:
Toggling an LED or other device from pin D0
from pylibftdi import BitBangDriver
import time
with BitBangDriver() as bb:
while True:
bb.port ^= 1
time.sleep(0.5)
Sending a string to a serial terminal
from pylibftdi import Driver
with Driver() as drv:
drv.baudrate = 19200
drv.write('Hello World!')
It's been tested on Linux (Ubuntu 10.10) and Mac OS X (10.6), with libftdi 0.17 and 0.18, but doesn't have any intended platform specific requirements other than having the libftdi library installed.
The following goals for this project differentiate it from similar projects:
- Fully supported on Linux and Mac OS X, using Intra2net's open source libftdi driver.
- Simple things are very simple, as the example above shows. The basic functionality is made as simple as possible to use, with properties and context managers used where it makes sense. Most other FTDI Python wrappers are 'just' low level bindings of the underlying API.
- There will be an increasing library of examples showing interaction with various protocols and devices - note this is a goal, not yet an accomplishment, though there is an LCD example there.
pylibftdi is easy_installable (or equivalent) from PyPI, and the
code is developed on bitbucket, where you can also raise tickets for problems and feature requests.
For reference, other similar projects include PyUSB, pyftdi, python-ftdi, and ftd2xx. There are probably others...