ftd2xx

raw JSON →
1.3.8 verified Mon Apr 27 auth: no python

A Python interface to FTDI's D2XX driver (ftd2xx.dll on Windows, libftd2xx on Linux/macOS) using ctypes. Currently at v1.3.8, with a relatively stable release cadence. Compatible with Python >=3.8.

pip install ftd2xx
error ftd2xx.DeviceError: FT_Open failed
cause Device not found or driver not installed.
fix
Check device is connected and driver (ftd2xx.dll/libftd2xx) is installed. On Linux, add udev rule.
error AttributeError: module 'ftd2xx' has no attribute 'open'
cause Trying to use old d2xx import pattern like 'from d2xx import open'.
fix
Use 'import ftd2xx' then 'ftd2xx.open()'.
error OSError: [WinError 193] %1 is not a valid Win32 application
cause Using 32-bit ftd2xx.dll with 64-bit Python, or vice versa.
fix
Match bitness of ftd2xx.dll with Python interpreter.
gotcha open() and openEx() by default call createDeviceInfoList which can be slow on some systems. Use update=False to avoid this when you don't need device info.
fix dev = ftd2xx.open(0, update=False)
gotcha On Linux, you may need to install libftd2xx separately and configure udev rules for non-root access. Otherwise you'll get a 'Failed to open device' error.
fix Install libftd2xx from FTDI's website and add udev rule: SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", MODE="0666"
deprecated The older d2xx library (by Pablo Bleyer) was renamed to ftd2xx. Importing from d2xx is deprecated and will break.
fix Use 'import ftd2xx' instead of 'import d2xx'

Basic usage: list, open, reset, read/write, and close a device.

import ftd2xx

# List connected devices
device_count = ftd2xx.createDeviceInfoList()
print(f"Found {device_count} device(s)")

# Open first device by serial number (or index)
try:
    dev = ftd2xx.open(0)
    print(f"Opened device: {dev.description}")
    # Reset and set bit mode to reset default
    dev.reset()
    dev.setBitMode(0, 0)
    # Write data
    dev.write(b"Hello FTDI")
    # Read data
    data = dev.read(100)
    print(f"Read: {data}")
    dev.close()
except ftd2xx.DeviceError as e:
    print(f"Error: {e}")