March 23, 2023

Notes on Getting Python to Talk to FTDI FT232 chipset for USB Serial Communication

NOTE: This is incomplete and is nothing more than just notes for myself. It is not yet part of a complete solution and I don't fully understand all the consequences that may be involved. Follow at your own risk.

Notes on Getting Python to Talk to FTDI FT232 chipset for USB Serial Communication — image 1

To get python to talk to FTDI FT232 chip for USB Serial Communication (Windows)

Replace the existing FTDI Driver with libusb-win32 using Zadig (Reference) 

Now the device shows up when searched for using VID and PID:

import usb
import usb.util
print(usb.core.find(idVendor=0x0403, idProduct=0x6001))


It WILL NO LONGER list under:

import serial.tools.list_ports

# List all available COM ports
ports = list(serial.tools.list_ports.comports())

# Print information for each port that is currently in use
for port in ports:
    if port.pid is not None and port.vid is not None:
        print(f"Port: {port.device} - VID: {hex(port.vid)} - PID: {hex(port.pid)} - Description: {port.description}")


but now pyftdi can now connect using VID and PID:

import time
from pyftdi.ftdi import Ftdi, FtdiError

try:
    ftdi = Ftdi()
    ftdi.open(vendor=0x403, product=0x6001)

    while ftdi.is_connected:
        try:
            ftdi.poll_modem_status()
            status = ftdi.modem_status()
            print(status)
        except FtdiError:
            break
        time.sleep(0.1)

finally:
    ftdi.close()