FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:



Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


Author Topic: Reading data from FT232h via FT2XX driver - data loss on Raspberry Pi  (Read 93 times)

Miriam

  • Newbie
  • *
  • Posts: 3
    • View Profile

Hi there,

I am new to this community so I hope I chose the right subforum to post.

I have an FTDI USB device that sends a huge amount of (known) data via the FTD2XX driver in 245-FIFO-mode. I wrote a little C code that reads the data and checks it for correctness. With every call of FT_Read(), an array of 256 bytes is processed.

When I run this code on my Windows desktop, it works fine. However, when I cross compile and run the executable on a Raspberry Pi, it results in data loss. I built a delay of 2 seconds in my code after the device starts sending data and before the first call of FT_Read(). Since that, the fault in the read data always occurs at the same byte.

What is the reason of this data loss (buffer overflow?) and how can I prevent it?

I use a Raspberry Pi 3 with the latest version of Raspbian OS Lite. The code is cross compiled on a Windows 32bit workstation with GCC. The libraries used are those packed with the libftd2xx-arm-v6-hf-1.4.6 driver I downloaded from the official FTDI website.

Thank you for any ideas.
Logged

FTDI Community

  • Global Moderator
  • Newbie
  • *****
  • Posts: 22
    • View Profile
Re: Reading data from FT232h via FT2XX driver - data loss on Raspberry Pi
« Reply #1 on: December 05, 2017, 01:57:37 PM »

Hello,

Thank you for your post.

The following application note covers FIFO Basics and should be of use to you:
http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_167_FIFO_Basics.pdf

Have you included the Buffer Flags in your hardware design? These should help to mitigate data loss.

Does the behaviour change if you remove the 2 second delay or compile the code natively on the Raspberry Pi?

Best Regards,

FTDI Community
Logged

Miriam

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Reading data from FT232h via FT2XX driver - data loss on Raspberry Pi
« Reply #2 on: December 05, 2017, 03:38:02 PM »

Thanks for your answer.

Yes, the device uses buffer flags for control issues. Proof of that is that I can run the same C code on Windows with the very same device connected to the Windows PC (or almost the same code, as FT_SetVIDPID() is neither defined nor necessary).

The 2 seconds delay is just to grant that the fault occurs at the same byte. Before I implemented this, the error started somewhere between the 1500th and 2100th call of FT_Read, i.e. some time after 1500*256 and before 2100*256 bytes are read.

I did not compile on the Pi before posting here. Now I did and it shows the same result  :(

Any other ideas? I also can post code if this helps.
Logged

Miriam

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Reading data from FT232h via FT2XX driver - data loss on Raspberry Pi
« Reply #3 on: December 11, 2017, 03:51:57 PM »

Still no solution found...

Is there a way to check if buffer flags are activated in the D2XX ARM driver? The hardware design obviously supports these (as mentioned before, the test runs on a Windows workstation).

Or shall I contact FTDI support via E-Mail?
Logged

FTDI Community

  • Global Moderator
  • Newbie
  • *****
  • Posts: 22
    • View Profile
Re: Reading data from FT232h via FT2XX driver - data loss on Raspberry Pi
« Reply #4 on: December 11, 2017, 04:57:33 PM »

Hello,

I believe that the Buffer Flags are set internally by the IC and thus cannot be queried by the driver.
It would be best to check these with an oscilloscope, its worth noting the RD# or WR# strobe inputs must be throttled when the TXE# or RXF# buffer flags stay high for over 400 nSec.

Does you code implement the FT_GetQueueStatus function before performing the FT_Read's? An example of this can be found in the D2XX Programmers Guide:
http://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer's_Guide(FT_000071).pdf

Best Regards,

FTDI Community.
Logged