libftdi Archives

Subject: Question about stream_test.c / ftdi_stream.c

From: Dave Harper <dave@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 26 Feb 2018 17:00:30 -0600
I am in the process of trying to get up to speed on using libFTDI in a Raspberry Pi data logging application.  I have a logger board that writes the data to an FT232H in asynchronous 245 FIFO mode, sends it on to the Pi which then processes it and stores it to files on an attached USB hard drive. I had been using the FTDI D2XX library but, after experincing a lot of dropped data and posting on their help forum, they indicated the Linux version of D2XX had problems and there is no intent to fix them.  They suggested libFTDI, which I was unaware of at the time. So I dug into the documentation and examples and was quickly able to come up with a modified version of my application (using the ftdi_read_data() call) that showed major improvement but was still dropping chunks of data - hundreds of bytes every 40MB or so.  Since the data rates are only in the hundereds of KB/sec., I felt that I must be doing something wrong in my application.  I searched the mail list and came across a thread started by Caleb Kamere (msg00212 from 17 June 2011) that described a similar issue he was having and, from his posts and the responses to them I learned a lot.  I now have a much better understanding of how USB works at the Linux kernel level and why using the approach shown in the steam_test.c example is much better.  However, in studying that program, along with the source code in the ftdi_stream.c file, I came across something that surprised me.  Everything in the stream_test program indicates the direction is from device to host.  My experience with USB is that it is host centric so I would expect the ftdi_readstream() function in ftdi_stream.c to configure the libusb_transfer structs to use the IN endpoint.  However, the function configures a queue of structures using the "out_ep" endpoint.  Thinking that I must be missing something, I went ahead and used "out_ep" in my application as well.  I then set a breakpoint in the program after the call to libusb_fill_bulk_transfer().  Sure enough, examining the transfer->endpoint value after the return showed that the MSB was set, indicating an OUT direction.  Given this, I cannot see how the example program works.  What am I missing?

Thanks,
Dave


---
This email has been checked for viruses by AVG.
http://www.avg.com


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Current Thread
  • Question about stream_test.c / ftdi_stream.c, Dave Harper <=