FTDI Community

General Category => Discussion - Software => Topic started by: alexeiko on January 15, 2019, 12:42:48 PM

Title: [FT4232] FT_GetQueueStatus returns non-expected number of bytes in receive queue
Post by: alexeiko on January 15, 2019, 12:42:48 PM
Hi, all!

I'm using FT4232 for JTAG. I'm using opcodes 0x39 and 0x3B for data in.
I'm expecting 9216 bytes (9KB) of data but the number of bytes in receive queue FT_GetQueueStatus gives me varies each time.
Once it's 9100, other time it's 9180 etc. Rarely I get the expected value.

What may be the issue? I tried to use smaller chunks, but still get incorrect values...

Would be glad for any help!

Thanks,
Alexei
Title: Re: [FT4232] FT_GetQueueStatus returns non-expected number of bytes in receive queue
Post by: alexeiko on January 15, 2019, 06:07:36 PM
Hi!

Found a solution by reading the buffer in loop until expected number of bytes is received.


Code: [Select]
while (totbytesread < 1024 * 9) {
do {
ftStatus |= FT_GetQueueStatus(ftHandle_A, &dwNumOfBytestoRead); // get the number of bytes in the device input buffer
} while ((dwNumOfBytestoRead == 0) && (ftStatus == FT_OK));

ftStatus |= FT_Read(ftHandle_A, mf_buff, dwNumOfBytestoRead, &dwNumOfBytesRead);
mf_buff += dwNumOfBytesRead;
totbytesread += dwNumOfBytesRead;
}