I have a simple binary byte array that I need to send to USB serial port using ftd2xx library in Python.
import ftd2xx as ft
import time
message = [86, 0xff, 0xff, 0, 0, 72, 40 ]
def openPort(index):
s = r'\000' * 64
port = ft.open(index, False) # open port
port.setUSBParameters(25600, 1024) # setup necessary parameters
port.setBaudRate(2000000)
port.setDataCharacteristics(8, 0, 0)
port.setTimeouts(16, 500)
port.clrRts() # power reset for attached hardware
time.sleep(3)
port.setRts()
time.sleep(0.1)
return port
cp = openPort(0)
cp.write(message)
In this case cp.write(message)
throws WrongType exception.
If I try to replace the array with message = b'V\xFF\xFF\x00\x00\x48\x28'
, it raises the same exception. In documentation I cannot see any hint what is in fact expected here. The original, underlying function in FTD2XX (FT_Write) will accept any byte buffer up to a certain size.