ftdi.read_data

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

ftdi.read_data

drodomon
Hi all,

I wrote a simple python code to interface the FT245R FTDI chip.
With this code I am able to establish an USB connection.
After that I tried to perform some read actions (ret, readData =
ftdi.read_data(ftdic, chunksize)) and for all of them referred to a
"small" amount of data, I received completely the expected data back.
This is not true when the expected data is around 819 Bytes, some data
are missing.
It seems that the sw is not fast enough to read data back from the FTDI
chip buffer.
I executed the same read action without problem with an hyperterminal,
so now I am wondering if this is a phython language limitation or if I
am missing some settings.

Have you ever faced this problem before?

Below there is the used code.
Thank you in advance.


import os
import sys
import ftdi1 as ftdi
import time

# Establish USB connection
ftdic = ftdi.new()

ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
ret = ftdi.usb_reset(ftdic)
ret = ftdi.usb_purge_buffers(ftdic)
ret = ftdi.set_baudrate(ftdic, 115200)
ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
ftdi.NONE)
ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)

# Write TX buffer
wrBuffer = chr(2)+chr(82)+chr(68)+chr(49)+chr(48)+chr(49)+chr(3)
BytesWritten = ftdi.write_data(ftdic, wrBuffer, len(wrBuffer))

time.sleep(1)

# Read RX buffer
ret, readData = ftdi.read_data(ftdic, 4096)

--
--

Davide Rodomonti

--
--

Davide Rodomonti

 

LOEP (Linac and Operations/ Electric Power System)

 

Tel. +49-6159-71-1905

BR2 2.107

 

GSI Helmholtzzentrum für Schwerionenforschung GmbH

Planckstraße 1
64291 Darmstadt
www.gsi.de


Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: Darmstadt
Handelsregister: Amtsgericht Darmstadt, HRB 1528

Geschäftsführung:
Ursula Weyrich
Professor Dr. Karlheinz Langanke

Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt

 


--
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: ftdi.read_data

Rogier Wolff
On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:

> ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
> ret = ftdi.usb_reset(ftdic)
> ret = ftdi.usb_purge_buffers(ftdic)
> ret = ftdi.set_baudrate(ftdic, 115200)
> ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
> ftdi.NONE)
> ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)

How are you putting data into the '245?

You are setting a baud rate and "disable flow control" which do not
really make sense for a '245 chip.

        Roger.


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

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

Re: ftdi.read_data

drodomon
The data are provide to the 245 by a NIOS controller that implements a
sort of hand shake protocol.

On 03.06.2015 12:40, Rogier Wolff wrote:

> On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:
>
>> ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
>> ret = ftdi.usb_reset(ftdic)
>> ret = ftdi.usb_purge_buffers(ftdic)
>> ret = ftdi.set_baudrate(ftdic, 115200)
>> ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
>> ftdi.NONE)
>> ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)
> How are you putting data into the '245?
>
> You are setting a baud rate and "disable flow control" which do not
> really make sense for a '245 chip.
>
> Roger.
>
>

--
--

Davide Rodomonti

 

LOEP (Linac and Operations/ Electric Power System)

 

Tel. +49-6159-71-1905

BR2 2.107

 

GSI Helmholtzzentrum für Schwerionenforschung GmbH

Planckstraße 1
64291 Darmstadt
www.gsi.de


Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: Darmstadt
Handelsregister: Amtsgericht Darmstadt, HRB 1528

Geschäftsführung:
Ursula Weyrich
Professor Dr. Karlheinz Langanke

Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt

 


--
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: ftdi.read_data

Rogier Wolff
On Wed, Jun 03, 2015 at 12:45:38PM +0200, d.rodomonti wrote:
> The data are provide to the 245 by a NIOS controller that implements
> a sort of hand shake protocol.

Sort of? Does it, or does it not check for the "RXNE" (or whatever it
is called signal?

Even if in tests is mostly works, you must account on that hardware
side that the software migth decide to do something else for a while,
and then the buffer fills. The '245 handles that situation gracefully
and will let your hardware know when it is no longer possible to
accept data.

        Roger.

>
> On 03.06.2015 12:40, Rogier Wolff wrote:
> >On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:
> >
> >>ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
> >>ret = ftdi.usb_reset(ftdic)
> >>ret = ftdi.usb_purge_buffers(ftdic)
> >>ret = ftdi.set_baudrate(ftdic, 115200)
> >>ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
> >>ftdi.NONE)
> >>ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)
> >How are you putting data into the '245?
> >
> >You are setting a baud rate and "disable flow control" which do not
> >really make sense for a '245 chip.
> >
> > Roger.
> >
> >
>
> --
> --
>
> Davide Rodomonti
>
>
> LOEP (Linac and Operations/ Electric Power System)
>
>
> Tel. +49-6159-71-1905
>
> BR2 2.107
>
>
> GSI Helmholtzzentrum für Schwerionenforschung GmbH
>
> Planckstraße 1
> 64291 Darmstadt
> www.gsi.de
>
>
> Gesellschaft mit beschränkter Haftung
> Sitz der Gesellschaft: Darmstadt
> Handelsregister: Amtsgericht Darmstadt, HRB 1528
>
> Geschäftsführung:
> Ursula Weyrich
> Professor Dr. Karlheinz Langanke
>
> Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
> Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
>
>
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to
> [hidden email]
>

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

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

Re: ftdi.read_data

drodomon
Thank you Roger for yours tips.

The system is up and running, but the sw part is developed in visual
basic (and I don't like it).
My target is to write a light sw version in python following the vb code
as template, but probably I missed some parts.

I let you know when I will understand the problem.

On 03.06.2015 12:51, Rogier Wolff wrote:

> On Wed, Jun 03, 2015 at 12:45:38PM +0200, d.rodomonti wrote:
>> The data are provide to the 245 by a NIOS controller that implements
>> a sort of hand shake protocol.
> Sort of? Does it, or does it not check for the "RXNE" (or whatever it
> is called signal?
>
> Even if in tests is mostly works, you must account on that hardware
> side that the software migth decide to do something else for a while,
> and then the buffer fills. The '245 handles that situation gracefully
> and will let your hardware know when it is no longer possible to
> accept data.
>
> Roger.
>
>> On 03.06.2015 12:40, Rogier Wolff wrote:
>>> On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:
>>>
>>>> ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
>>>> ret = ftdi.usb_reset(ftdic)
>>>> ret = ftdi.usb_purge_buffers(ftdic)
>>>> ret = ftdi.set_baudrate(ftdic, 115200)
>>>> ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
>>>> ftdi.NONE)
>>>> ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)
>>> How are you putting data into the '245?
>>>
>>> You are setting a baud rate and "disable flow control" which do not
>>> really make sense for a '245 chip.
>>>
>>> Roger.
>>>
>>>
>> --
>> --
>>
>> Davide Rodomonti
>>
>>
>> LOEP (Linac and Operations/ Electric Power System)
>>
>>
>> Tel. +49-6159-71-1905
>>
>> BR2 2.107
>>
>>
>> GSI Helmholtzzentrum für Schwerionenforschung GmbH
>>
>> Planckstraße 1
>> 64291 Darmstadt
>> www.gsi.de
>>
>>
>> Gesellschaft mit beschränkter Haftung
>> Sitz der Gesellschaft: Darmstadt
>> Handelsregister: Amtsgericht Darmstadt, HRB 1528
>>
>> Geschäftsführung:
>> Ursula Weyrich
>> Professor Dr. Karlheinz Langanke
>>
>> Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
>> Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
>>
>>
>>
>> --
>> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
>> To unsubscribe send a mail to
>> [hidden email]
>>

--
--

Davide Rodomonti

 

LOEP (Linac and Operations/ Electric Power System)

 

Tel. +49-6159-71-1905

BR2 2.107

 

GSI Helmholtzzentrum für Schwerionenforschung GmbH

Planckstraße 1
64291 Darmstadt
www.gsi.de


Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: Darmstadt
Handelsregister: Amtsgericht Darmstadt, HRB 1528

Geschäftsführung:
Ursula Weyrich
Professor Dr. Karlheinz Langanke

Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt

 


--
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: ftdi.read_data

drodomon
Hi all,

I am not able to understand where is the problem with the python sw that
I wrote, so I decide to convert it in C++ using directly the d2xx
library provided by FTDI and I have no more the problem discussed.
The two code are quite the same excepted for the following action
performed before each read action:
  ftStatus = FT_GetQueueStatus(ftHandle[0], &dwRxSize);
  :
  :
  ftStatus = FT_Read(ftHandle[0], pcBufRead, dwRxSize, &dwBytesRead);

maybe something similar is already performed with ftdi.read_data
command, but this is the only difference that I found.
Is it possible that I didn't install properly the library?
Have you some explanation to this strange behavior?

Thank you in advance for your support.


On 03.06.2015 13:08, d.rodomonti wrote:

> Thank you Roger for yours tips.
>
> The system is up and running, but the sw part is developed in visual
> basic (and I don't like it).
> My target is to write a light sw version in python following the vb
> code as template, but probably I missed some parts.
>
> I let you know when I will understand the problem.
>
> On 03.06.2015 12:51, Rogier Wolff wrote:
>> On Wed, Jun 03, 2015 at 12:45:38PM +0200, d.rodomonti wrote:
>>> The data are provide to the 245 by a NIOS controller that implements
>>> a sort of hand shake protocol.
>> Sort of? Does it, or does it not check for the "RXNE" (or whatever it
>> is called signal?
>>
>> Even if in tests is mostly works, you must account on that hardware
>> side that the software migth decide to do something else for a while,
>> and then the buffer fills. The '245 handles that situation gracefully
>> and will let your hardware know when it is no longer possible to
>> accept data.
>>
>>     Roger.
>>
>>> On 03.06.2015 12:40, Rogier Wolff wrote:
>>>> On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:
>>>>
>>>>> ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
>>>>> ret = ftdi.usb_reset(ftdic)
>>>>> ret = ftdi.usb_purge_buffers(ftdic)
>>>>> ret = ftdi.set_baudrate(ftdic, 115200)
>>>>> ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
>>>>> ftdi.NONE)
>>>>> ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)
>>>> How are you putting data into the '245?
>>>>
>>>> You are setting a baud rate and "disable flow control" which do not
>>>> really make sense for a '245 chip.
>>>>
>>>>     Roger.
>>>>
>>>>
>>> --
>>> --
>>>
>>> Davide Rodomonti
>>>
>>>
>>> LOEP (Linac and Operations/ Electric Power System)
>>>
>>>
>>> Tel. +49-6159-71-1905
>>>
>>> BR2 2.107
>>>
>>>
>>> GSI Helmholtzzentrum für Schwerionenforschung GmbH
>>>
>>> Planckstraße 1
>>> 64291 Darmstadt
>>> www.gsi.de
>>>
>>>
>>> Gesellschaft mit beschränkter Haftung
>>> Sitz der Gesellschaft: Darmstadt
>>> Handelsregister: Amtsgericht Darmstadt, HRB 1528
>>>
>>> Geschäftsführung:
>>> Ursula Weyrich
>>> Professor Dr. Karlheinz Langanke
>>>
>>> Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
>>> Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
>>>
>>>
>>>
>>> --
>>> libftdi - see http://www.intra2net.com/en/developer/libftdi for
>>> details.
>>> To unsubscribe send a mail to
>>> [hidden email]
>>>
>

--
--

Davide Rodomonti

 

LOEP (Linac and Operations/ Electric Power System)

 

Tel. +49-6159-71-1905

BR2 2.107

 

GSI Helmholtzzentrum für Schwerionenforschung GmbH

Planckstraße 1
64291 Darmstadt
www.gsi.de


Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: Darmstadt
Handelsregister: Amtsgericht Darmstadt, HRB 1528

Geschäftsführung:
Ursula Weyrich
Professor Dr. Karlheinz Langanke

Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt

 


--
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: ftdi.read_data

Rogier Wolff
On Fri, Jun 05, 2015 at 03:12:01PM +0200, d.rodomonti wrote:

> Hi all,
>
> I am not able to understand where is the problem with the python sw
> that I wrote, so I decide to convert it in C++ using directly the
> d2xx library provided by FTDI and I have no more the problem
> discussed.
> The two code are quite the same excepted for the following action
> performed before each read action:
>  ftStatus = FT_GetQueueStatus(ftHandle[0], &dwRxSize);
>  :
>  :
>  ftStatus = FT_Read(ftHandle[0], pcBufRead, dwRxSize, &dwBytesRead);

That should just: "ask how many bytes are available" and then read
exactly that many bytes.

Just asking for "as many as you have", should also work.

On the other hand: I'm hearing these reports of dataloss so often that
I'm starting to believe that there is something going on.

It could be a design problem.  Maybe libftdi cannot keep read-buffers
available for the ftdi to dump data into when it is not actively
running. So that your program would need to be in "ftdi_read" 99% of
the time to be able to catch 99% of the data. Not a desirable
situation.

Anyway, such low-level design issues are out of my league (in my free
time. I'll happily investigate to the bare metal if you're willing to
pay my commercial rate...).

        Roger.


> maybe something similar is already performed with ftdi.read_data
> command, but this is the only difference that I found.
> Is it possible that I didn't install properly the library?
> Have you some explanation to this strange behavior?
>
> Thank you in advance for your support.
>
>
> On 03.06.2015 13:08, d.rodomonti wrote:
> >Thank you Roger for yours tips.
> >
> >The system is up and running, but the sw part is developed in
> >visual basic (and I don't like it).
> >My target is to write a light sw version in python following the
> >vb code as template, but probably I missed some parts.
> >
> >I let you know when I will understand the problem.
> >
> >On 03.06.2015 12:51, Rogier Wolff wrote:
> >>On Wed, Jun 03, 2015 at 12:45:38PM +0200, d.rodomonti wrote:
> >>>The data are provide to the 245 by a NIOS controller that implements
> >>>a sort of hand shake protocol.
> >>Sort of? Does it, or does it not check for the "RXNE" (or whatever it
> >>is called signal?
> >>
> >>Even if in tests is mostly works, you must account on that hardware
> >>side that the software migth decide to do something else for a while,
> >>and then the buffer fills. The '245 handles that situation gracefully
> >>and will let your hardware know when it is no longer possible to
> >>accept data.
> >>
> >>    Roger.
> >>
> >>>On 03.06.2015 12:40, Rogier Wolff wrote:
> >>>>On Tue, Jun 02, 2015 at 11:50:06AM +0200, d.rodomonti wrote:
> >>>>
> >>>>>ret = ftdi.usb_open(ftdic, 0x0403, 0x6001)
> >>>>>ret = ftdi.usb_reset(ftdic)
> >>>>>ret = ftdi.usb_purge_buffers(ftdic)
> >>>>>ret = ftdi.set_baudrate(ftdic, 115200)
> >>>>>ret = ftdi.set_line_property(ftdic, ftdi.BITS_8 , ftdi.STOP_BIT_1,
> >>>>>ftdi.NONE)
> >>>>>ret = ftdi.setflowctrl(ftdic,ftdi.SIO_DISABLE_FLOW_CTRL)
> >>>>How are you putting data into the '245?
> >>>>
> >>>>You are setting a baud rate and "disable flow control" which do not
> >>>>really make sense for a '245 chip.
> >>>>
> >>>>    Roger.
> >>>>
> >>>>
> >>>--
> >>>--
> >>>
> >>>Davide Rodomonti
> >>>
> >>>
> >>>LOEP (Linac and Operations/ Electric Power System)
> >>>
> >>>
> >>>Tel. +49-6159-71-1905
> >>>
> >>>BR2 2.107
> >>>
> >>>
> >>>GSI Helmholtzzentrum für Schwerionenforschung GmbH
> >>>
> >>>Planckstraße 1
> >>>64291 Darmstadt
> >>>www.gsi.de
> >>>
> >>>
> >>>Gesellschaft mit beschränkter Haftung
> >>>Sitz der Gesellschaft: Darmstadt
> >>>Handelsregister: Amtsgericht Darmstadt, HRB 1528
> >>>
> >>>Geschäftsführung:
> >>>Ursula Weyrich
> >>>Professor Dr. Karlheinz Langanke
> >>>
> >>>Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
> >>>Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
> >>>
> >>>
> >>>
> >>>--
> >>>libftdi - see http://www.intra2net.com/en/developer/libftdi
> >>>for details.
> >>>To unsubscribe send a mail to
> >>>[hidden email]
> >>>
> >
>
> --
> --
>
> Davide Rodomonti
>
>
> LOEP (Linac and Operations/ Electric Power System)
>
>
> Tel. +49-6159-71-1905
>
> BR2 2.107
>
>
> GSI Helmholtzzentrum für Schwerionenforschung GmbH
>
> Planckstraße 1
> 64291 Darmstadt
> www.gsi.de
>
>
> Gesellschaft mit beschränkter Haftung
> Sitz der Gesellschaft: Darmstadt
> Handelsregister: Amtsgericht Darmstadt, HRB 1528
>
> Geschäftsführung:
> Ursula Weyrich
> Professor Dr. Karlheinz Langanke
>
> Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
> Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
>
>
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to
> [hidden email]
>

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

Loading...