libftdi Archives

Subject: Re: Checking for available bytes

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 18 Jun 2009 09:27:23 +0200
Hello Matthias,

On Wednesday, 17. June 2009 22:33:37 Matthias Nagl wrote:
> I'm using libftdi to communicate with an AVR (via FT232R). To receive bytes
> sent from the µC I am currently polling the FT with repeated calls of
> ftdi_read_data() in a loop. However this method often doesn't notice new
> bytes available before I send something downstream. Another problem is that
> it blocks the calling thread which is also responsible for sending commands
> (a nonblocking read function would be better in my case).
>
> Is there a method to poll for the number of available bytes like
> FT_GetStatus in the official D2XX-Driver? Or is there even an event driven
> method (I think the ideal solution would be a callback-function, that is
> automatically called after a newline has been received). As I don't see any
> suitable methods I assume that this feature is not available in libftdi
> (yet?). So my question is if it is possible / makes sense considering the
> abilities of the FT hardware.

AFAIK the D2XX-Driver uses threads to constantly poll the device
for data in the background. So it's very easy to check for
available bytes in the internal buffer.

Maybe the new libusb 1.x API could be of help,
though I haven't checked that yet.

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx

Current Thread