libftdi Archives

Subject: Re: Understanding "ftdi_usb_purge_rx_buffer"

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 14 Nov 2014 11:11:49 +0100
>>>>> "Günther" == Günther Grantig <powertomato@xxxxxxxxx> writes:

    Günther> Hi, I'm using a FT232RL in bitbang mode to communicate to a
    Günther> device with a proprietary protocoll. It has a lot of burst
    Günther> writes, but occasionally replies with short messages. For those
    Günther> I need reads correlating to specific clock edges.

    Günther> The way I intended to do this was:

    Günther> 1. change to BITMODE_BITBANG 2. burst write the data 3. change
    Günther> to BITMODE_SYNCBB 4. ftdi_usb_purge_rx_buffer 5. toggle the
    Günther> clock line a couple of times 6. read the data 7. change back to
    Günther> BITMODE_BITBANG and continue writing


    Günther> The problem with this solution was, that even after a
    Günther> successful "ftdi_usb_purge_rx_buffer" call, the buffer seemed
    Günther> to contain data (>200bytes!). Why is this? For now I clear the
    Günther> buffer manually by reading it's content.

Can it be that you mix TX and RX. rx_buffer is probably data written by the
PC and read out by the FTDI. So maybe ftdi_usb_purge_tx_buffer is a better
way for your task. For every transaction done by the FTDI there is a
resulting byte read.

    Günther> If you need code I'll gladly try to reproduce this in a simpler
    Günther> example. The current code is too nested to post here.
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread