Understanding "ftdi_usb_purge_rx_buffer"

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Understanding "ftdi_usb_purge_rx_buffer"

Günther Grantig
Hi,

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

The way I intended to do this was:

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


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

If you need code I'll gladly try to reproduce this in a simpler
example. The current code is too nested to post here.

Best regards

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Understanding "ftdi_usb_purge_rx_buffer"

Uwe Bonnes
>>>>> "Günther" == Günther Grantig <[hidden email]> 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                [hidden email]

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 [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Understanding "ftdi_usb_purge_rx_buffer"

Günther Grantig
Yes that was it, thanks. A shame I didn't think about that...

2014-11-14 11:11 GMT+01:00 Uwe Bonnes <[hidden email]>:

>>>>>> "Günther" == Günther Grantig <[hidden email]> 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                [hidden email]
>
> 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 [hidden email]
>

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Understanding "ftdi_usb_purge_rx_buffer"

Uwe Bonnes
>>>>> "Günther" == Günther Grantig <[hidden email]> writes:

    Günther> Yes that was it, thanks. A shame I didn't think about that...

Understanding TX and RX direction always needs some brain twist...
--
Uwe Bonnes                [hidden email]

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 [hidden email]

Loading...