There are two ways to open a connection to an Ftdi object.
The recommended way to open a connection is to specify connection details using a URL. The URL scheme is defined as:
vendor: the USB vendor ID of the manufacturer
product: the USB product ID of the device
Supported product IDs:
Supported product aliases:
ftprefix for all aliases is also accepted, as for example
serial: the serial number as a string. This is the preferred method to uniquely identify a specific FTDI device. However, some FTDI device are not fitted with an EEPROM, or the EEPROM is either corrupted or erased. In this case, FTDI devices report no serial number
bus:addess: it is possible to select a FTDI device through a bus:address pair, specified as hexadecimal integer values.
(0x)10= 16 (decimal) and address
(0x)22= 34 (decimal)
index: an integer - not particularly useful, as it depends on the enumeration order on the USB buses, and may vary from on session to another.
interface: the interface of FTDI device, starting from 1
1for 230x and 232* devices,
2for 2232* devices,
4for 4232* devices
All parameters but the interface are optional, PyFtdi tries to find the best
match. Therefore, if you have a single FTDI device connected to your system,
ftdi:///1 should be enough.
You can also ask PyFtdi to enumerate all the compatible devices with the
ftdi:///? syntax. This syntax is useful to retrieve the available
FTDI URLs with serial number and/or bus:address selectors.
Note that if there’s only one FTDI device connected to the host, the FTDI URL
can be as simple as
ftdi:///n, where n is the FTDI port to use, starting
URL-based methods to open a connection¶
open_from_url() open_mpsse_from_url() open_bitbang_from_url()
Device-based methods to open a connection¶
You may also open an Ftdi device from an existing PyUSB device, with the help
open_from_device() helper method.
open_from_device() open_mpsse_from_device() open_bitbang_from_device()
Legacy methods to open a connection¶
The old, deprecated method to open a connection is to use the
methods without the
_from_url suffix, which accept VID, PID, and serial
parameters (among others).
open() open_mpsse() open_bitbang()
bin/ directory contains a tiny script
ftdu_urls.py to list the
available FTDIs connected to the host, and the URLs than can be used to open a
Fdti() instance with the
Supporting custom USB vendor and product IDs¶
PyFtdi only recognizes FTDI official vendor and product IDs.
If you have an FTDI device with an EEPROM with customized IDs, you need to tell PyFtdi to support those custom USB identifiers.
To support a custom product ID (16-bit integer) with the official FTDI ID, add
the following code before any call to an FTDI
from pyftdi.ftdi import Ftdi Ftdi.add_custom_product(Ftdi.DEFAULT_VENDOR, product_id)
To support a custom vendor ID and product ID (16-bit integers), add the
following code before any call to an FTDI
from pyftdi.ftdi import Ftdi Ftdi.add_custom_vendor(vendor_id) Ftdi.add_custom_product(vendor_id, product_id)
You may also specify an arbitrary string to each method if you want to specify a URL by custom vendor and product names instead of their numerical values:
from pyftdi.ftdi import Ftdi Ftdi.add_custom_vendor(0x1234, 'myvendor') Ftdi.add_custom_product(0x1234, 0x5678, 'myproduct') f1 = Ftdi.create_from_url('ftdi://0x1234:0x5678/1') f2 = Ftdi.create_from_url('ftdi://myvendor:myproduct/2')