libftdi Archives

Subject: Re: Callback when data available to read?

From: Rogier Wolff <R.E.Wolff@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sat, 21 Jun 2014 13:08:09 +0200
On Thu, Jun 19, 2014 at 07:58:49PM +0200, Samuel Bryner wrote:
> Hi,
> 
> Is there a way to get a callback when there is data available to read?
> 
> As far as I can see, you can either:
> 
> - poll ftdi_read_data()
> - create a ftdi_transfer_control with ftdi_read_data_submit() and poll
> that (with the additional drawback that you need to know the amount of
> data you want to read beforehand)
> - directly use libusb, defeating the point of libftdi somewhat.
> 
> This would be nice for asynchronous writes as well, maybe even with some
> sort of intermediate progress callback.
> 
> ftdi_readstream() seems to go into the right direction but uses a
> special synchronous FIFO mode.


I'd say: that'd be tricky to implement: your program "has control"
over the thread, and when it is not checking the FTDI chip, it's
simply not checking the FTDI chip! So the library would have to create
a separate thread and call your callback from the other thread, or
maybe something with signals, and then call your callback from the
signal.

Definitively not "trivial to add".

        Roger.

-- 
** R.E.Wolff@xxxxxxxxxxxx ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Current Thread