FTDI Community
General Category => Discussion - Software => Topic started by: mosi on November 07, 2018, 08:38:51 pm
-
A question about the FT_Write() function.
FT_STATUS FT_Write (FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpdwBytesWritten)
I wonder about the lpdwBytesWritten.
When will it ever return lpdwBytesWritten < dwBytesToWrite? Would FT_Write return other than FT_OK in that case?
And how much data can I send in one call to FT_Write? What limit has the dwBytesToWrite parameter?
-
Hello,
Please see the D2XX Programmer's Guide (https://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer's_Guide(FT_000071).pdf) for all available information.
dwBytesToWrite is DWORD type. This is an unsigned, 32-bit unit of data. It can contain an integer value in the range 0 through 4,294,967,295.
FT_Write would return with an error code other than FT_OK if it's not completed successfully.
Error codes can be found in Appendix A - Type Definitions.
You may also want to set FT_SetTimeouts which sets the read and write timeouts for the device.
Please also take a look at AN232B-04 Data Throughput, Latency & Handshaking (https://www.ftdichip.com/Support/Documents/AppNotes/AN232B-04_DataLatencyFlow.pdf)which provides additional useful information and applies to all our FTDI USB products.
Best Regards,
FTDI Community