1
Discussion - Software / Using FT_SetTimeouts() with FT_Write() for D2XX
« on: October 06, 2022, 03:11:10 pm »
I am using D2XX drivers and FTD2XX_NET v1.1.0 in my C# application to communicate via serial port and toggle GPIO pins.
First I set the timeous using FT.SetTimeouts(5000, 0) and then I send data in loop using FT.Write() function.
I can see that the data received by the computer on the other end is corrupted.
For example, sending an array of bytes [1,2,3,4,5,6,7,8,9,0] using the following function:
void SendData()
{
var byteArray = new byte[] { 1,2,3,4,5,6,7,8,9,0 };
for (int i=0; i<5; i++) {
// purge RX and TX
FT.Purge(FT_PURGE.FT_PURGE_RX | FT_PURGE.FT_PURGE_TX);
// write 10 bytes
FT.Write(byteArray, 10, ref numBytesWritten);
}
}
can result in the following data received on the other end:
[1,2,1,2,1,2,3,1,2,1,2,3,4,5,6,7,8,9,0]
But when I set the TX timeout to 5000 using FT.SetTimeouts(5000, 5000) the data is received properly.
It looks like the TX timeout of 0 causes FT.Write() to return immediately and
the consecutive calls to FT.Write() corrupt the data sent by the previous calls to FT.Write().
My questions:
1. Does TX timeout of 0 mean "infinity" or actual zero?
2. Is there an API that I can use to ensure that the previous transmission finished?
Please help.
First I set the timeous using FT.SetTimeouts(5000, 0) and then I send data in loop using FT.Write() function.
I can see that the data received by the computer on the other end is corrupted.
For example, sending an array of bytes [1,2,3,4,5,6,7,8,9,0] using the following function:
void SendData()
{
var byteArray = new byte[] { 1,2,3,4,5,6,7,8,9,0 };
for (int i=0; i<5; i++) {
// purge RX and TX
FT.Purge(FT_PURGE.FT_PURGE_RX | FT_PURGE.FT_PURGE_TX);
// write 10 bytes
FT.Write(byteArray, 10, ref numBytesWritten);
}
}
can result in the following data received on the other end:
[1,2,1,2,1,2,3,1,2,1,2,3,4,5,6,7,8,9,0]
But when I set the TX timeout to 5000 using FT.SetTimeouts(5000, 5000) the data is received properly.
It looks like the TX timeout of 0 causes FT.Write() to return immediately and
the consecutive calls to FT.Write() corrupt the data sent by the previous calls to FT.Write().
My questions:
1. Does TX timeout of 0 mean "infinity" or actual zero?
2. Is there an API that I can use to ensure that the previous transmission finished?
Please help.