EEVblog® Electronics Community Forum

Electronics => Microcontrollers => Topic started by: blackberryer on February 03, 2020, 09:42:23 am

Title: python connection FT2232D problem
Post by: blackberryer on February 03, 2020, 09:42:23 am
I connected the FT2232D with python and can detect the device ID, but the problem of open failure occurs.
Channel A of FT2232D is used for JATG to download the program to FPGA, and channel B is used for 245 FIFO mode to communicate with FPGA.
The driver settings are shown in the screenshot(driver-set.png) below.
(http://[attach=1])
The python test code is as follows(result is test_connect.png):
(http://[attach=2])
Code: [Select]
from pylibftdi import Driver, Device

dev_list  = Driver().list_devices()
if len(dev_list) != 0:
print "Following devices found:"
for device_ in dev_list:
print device_
# Create Device instance: Channel B in binary mode
dev = Device(mode='b', interface_select=2)

# Open the instantiated device
dev.open()

# Write value 16 to FTDI over USB, returns number of bytes written
dev.write(bytearray([16,]))

# Read one byte
rx_data =  bytearray(dev.read(1))

# Print the byte received. Should be 16+1 i.e, 17
print rx_data[0]

# Close device after use
dev.close()