FTDI Community

General Category => Discussion - Drivers => Topic started by: MauroDiamantino on August 21, 2019, 08:32:06 PM

Title: Errors with functions FT_GetQueueStatus() and FT_Read() of D2XX
Post by: MauroDiamantino on August 21, 2019, 08:32:06 PM
Hello people, I'm working with a USB device which incorporates a FT232R chip. I'm using the D2XX library to communicate with the device from a custom C++ software. The data is read as 17 bytes at a time, and to ensure the reading doesn't fail it is queried the number of available bytes inside a loop until this number is greater or equal to 17. The number of available bytes is got with the function FT_GetQueueStatus(). After of facing many errors, I discovered it was necessary to put a delay of 70ms approximately between the calling of FT_GetQueueStatus() which states that the necessary number of bytes are available and the calling of FT_Read(), to avoid reading errors.
Why did I have to put that delay? Isn't it supposed if the needed bytes are available, the reading operation shouldn't fail? Is it the same to use FT_GetQueueStatus() or FT_GetStatus() to get the number of available bytes in the receive queue?
Title: Re: Errors with functions FT_GetQueueStatus() and FT_Read() of D2XX
Post by: FTDI Community on August 23, 2019, 11:05:22 AM
Hello,

There should not be a need to add a delay. If FT_GetQueueStatus returns a value, that value should be able to be read straight away.

What are the fail codes that you are seeing, returned by the function calls?

See the D2XX Programmer's Guide (https://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer's_Guide(FT_000071).pdf) for more information and software examples.

If you want to send your code for review, see Contact Us (https://www.ftdichip.com/FTContact.htm) for your local support office.

Best Regards,
FTDI Community