Quantcast

Data loss while ftdi_read_data() from FT232RL

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

Data loss while ftdi_read_data() from FT232RL

Venkatesh Shukla
Hello guys

Sorry for bugging you. But I am facing a problem while using libftdi.

I am trying to read data from a divecomputer Heinrichs Weikamp OSTC3.
It has FT232RL for interfacing.

I am using libftdi to achieve that.
The steps to read the data are

 1. Initialise the device
 2. Send INIT byte (0xBB) to the device.
 3. The device responds with an echo of the command (0xBB).
 4. The device then sends a READY byte (0x4D). The device is now ready
for the next step.
 5. Send the HEADER (0x61) byte to the device.
 6. In response to this, it first sends an echo (0x61) back to the device.
 7. Then it sends the device headers. This is the data I need. It
should be of 65536 bytes. But I am reading only around 65446 bytes. It
is a serious error.

I am new to libftdi and ftdi chips in general. What am I missing? How
can the above stated problem be resolved?

I am attaching my complete code for the data import.

I have asked this question on Stack overflow as well :
http://stackoverflow.com/questions/23825324/data-loss-while-ftdi-read-data-from-ft232rl
Please help me resolve this issue or point to suitable resources that
could help me.

Sincerely

--

Venkatesh Shukla

Senior
Indian Institute of Technology
Banaras Hindu University
Varanasi
India

--
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: Data loss while ftdi_read_data() from FT232RL

Uwe Bonnes
>>>>> "Venkatesh" == Venkatesh Shukla <[hidden email]> writes:

    Venkatesh> Hello guys Sorry for bugging you. But I am facing a problem
    Venkatesh> while using libftdi.

    Venkatesh> I am trying to read data from a divecomputer Heinrichs
    Venkatesh> Weikamp OSTC3.  It has FT232RL for interfacing.

    Venkatesh> I am using libftdi to achieve that.  The steps to read the
    Venkatesh> data are

    Venkatesh>  1. Initialise the device 2. Send INIT byte (0xBB) to the
    Venkatesh> device.  3. The device responds with an echo of the command
    Venkatesh> (0xBB).  4. The device then sends a READY byte (0x4D). The
    Venkatesh> device is now ready for the next step.  5. Send the HEADER
    Venkatesh> (0x61) byte to the device.  6. In response to this, it first
    Venkatesh> sends an echo (0x61) back to the device.  7. Then it sends
    Venkatesh> the device headers. This is the data I need. It should be of
    Venkatesh> 65536 bytes. But I am reading only around 65446 bytes. It is
    Venkatesh> a serious error.

    Venkatesh> I am new to libftdi and ftdi chips in general. What am I
    Venkatesh> missing? How can the above stated problem be resolved?

Did you try to do the same from /dev/ttyUSBx? Does the problem happen there
too?

If you need pure UART functionallity from the FT device, I think the kernel
driver is the best way.

Bye

--
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: Data loss while ftdi_read_data() from FT232RL

Venkatesh Shukla
On Fri, May 23, 2014 at 4:26 PM, Uwe Bonnes
<[hidden email]> wrote:

>>>>>> "Venkatesh" == Venkatesh Shukla <[hidden email]> writes:
>
>     Venkatesh> Hello guys Sorry for bugging you. But I am facing a problem
>     Venkatesh> while using libftdi.
>
>     Venkatesh> I am trying to read data from a divecomputer Heinrichs
>     Venkatesh> Weikamp OSTC3.  It has FT232RL for interfacing.
>
>     Venkatesh> I am using libftdi to achieve that.  The steps to read the
>     Venkatesh> data are
>
>     Venkatesh>  1. Initialise the device 2. Send INIT byte (0xBB) to the
>     Venkatesh> device.  3. The device responds with an echo of the command
>     Venkatesh> (0xBB).  4. The device then sends a READY byte (0x4D). The
>     Venkatesh> device is now ready for the next step.  5. Send the HEADER
>     Venkatesh> (0x61) byte to the device.  6. In response to this, it first
>     Venkatesh> sends an echo (0x61) back to the device.  7. Then it sends
>     Venkatesh> the device headers. This is the data I need. It should be of
>     Venkatesh> 65536 bytes. But I am reading only around 65446 bytes. It is
>     Venkatesh> a serious error.
>
>     Venkatesh> I am new to libftdi and ftdi chips in general. What am I
>     Venkatesh> missing? How can the above stated problem be resolved?
>
> Did you try to do the same from /dev/ttyUSBx? Does the problem happen there
> too?
>
> If you need pure UART functionallity from the FT device, I think the kernel
> driver is the best way.
>
> Bye
>
> --
> Uwe Bonnes                [hidden email]

The library libdivecomputer does use /dev/ttyUSB* efficiently to
extract data from the device. But I have to do the import part on
android platform. Android does not provide access to USB devices as
normal linux systems do, and native code is preferred, I have decided
to use libftdi for the import part. It does indeed work on the android
emulator after getting requisite permissions but there is this data
loss error. Any way out.?

--
Venkatesh Shukla

--
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: Data loss while ftdi_read_data() from FT232RL

Uwe Bonnes
>>>>> "Venkatesh" == Venkatesh Shukla <[hidden email]> writes:


    Venkatesh> The library libdivecomputer does use /dev/ttyUSB* efficiently
    Venkatesh> to extract data from the device. But I have to do the import
    Venkatesh> part on android platform. Android does not provide access to
    Venkatesh> USB devices as normal linux systems do, and native code is
    Venkatesh> preferred, I have decided to use libftdi for the import
    Venkatesh> part. It does indeed work on the android emulator after
    Venkatesh> getting requisite permissions but there is this data loss
    Venkatesh> error. Any way out.?

Does the libftdi programm compiled and run on the PC show the same problem?
If it shows the same problems, use the debugging possibilities offered by
the PC: strace,  ltrace and wireshare with the USB  debug file system.

Bye
--
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: Data loss while ftdi_read_data() from FT232RL

Rogier Wolff
In reply to this post by Venkatesh Shukla
On Fri, May 23, 2014 at 04:33:31PM +0530, Venkatesh Shukla wrote:

> The library libdivecomputer does use /dev/ttyUSB* efficiently to
> extract data from the device. But I have to do the import part on
> android platform. Android does not provide access to USB devices as
> normal linux systems do, and native code is preferred, I have decided
> to use libftdi for the import part. It does indeed work on the android
> emulator after getting requisite permissions but there is this data
> loss error. Any way out.?

Ah! New information! You're using an emulator inside a host computer!

Does the problem also happen "in real life"? I can very well imagine
that the emulator is occasionally too slow to handle the data before a
buffer overrun happens.

The ftdi chip knows that "libftdi" has not read the data. So it will
try to convince whatever is sending the data to stop. But there is
only so much that it can do: I expect that RTS/CTS are not connected
inside the dive computer meaning that the processor in the dive
computer will simply continue to send data even when the FTDI buffer
fills up.

Can you synchronize in the datastream? Can you download that header
multiple times to see if you're missing the same parts every time?  Or
maybe just download it once correctly using "libdivecomputer"? Compare
the data!

        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: Data loss while ftdi_read_data() from FT232RL

Xiaofan Chen
In reply to this post by Venkatesh Shukla
On Fri, May 23, 2014 at 7:03 PM, Venkatesh Shukla
<[hidden email]> wrote:
> On Fri, May 23, 2014 at 4:26 PM, Uwe Bonnes
> The library libdivecomputer does use /dev/ttyUSB* efficiently to
> extract data from the device. But I have to do the import part on
> android platform. Android does not provide access to USB devices as
> normal linux systems do, and native code is preferred, I have decided
> to use libftdi for the import part. It does indeed work on the android
> emulator after getting requisite permissions but there is this data
> loss error. Any way out.?
>

libftdi is based on libusb. What is the version of libusb
are you using on your Android platform? Your problem
may well be not related to libftdi but rather an older
version of libusb.

Right now libusb on Android is still problematic with
regard to the permission issue. There are some talks of using
Android native USB codes to get around this but no
working codes yet.
https://github.com/libusb/libusb/tree/master/android


--
Xiaofan

--
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: Data loss while ftdi_read_data() from FT232RL

Venkatesh Shukla
In reply to this post by Rogier Wolff
Sorry for the late response guys.

On Tue, May 27, 2014 at 10:16 AM, Rogier Wolff <[hidden email]> wrote:
On Fri, May 23, 2014 at 04:33:31PM +0530, Venkatesh Shukla wrote:

> The library libdivecomputer does use /dev/ttyUSB* efficiently to
> extract data from the device. But I have to do the import part on
> android platform. Android does not provide access to USB devices as
> normal linux systems do, and native code is preferred, I have decided
> to use libftdi for the import part. It does indeed work on the android
> emulator after getting requisite permissions but there is this data
> loss error. Any way out.?

Ah! New information! You're using an emulator inside a host computer!
Does the problem also happen "in real life"? I can very well imagine
that the emulator is occasionally too slow to handle the data before a
buffer overrun happens.


Yes indeed it does. Android is the ultimate aim. But currently I am using this script on my system (Fedora 20). It gives the same result on emulator as well. But with greater losses.
 
The ftdi chip knows that "libftdi" has not read the data. So it will
try to convince whatever is sending the data to stop. But there is
only so much that it can do: I expect that RTS/CTS are not connected
inside the dive computer meaning that the processor in the dive
computer will simply continue to send data even when the FTDI buffer
fills up.

Can you synchronize in the datastream? Can you download that header
multiple times to see if you're missing the same parts every time?  Or
maybe just download it once correctly using "libdivecomputer"? Compare
the data!


Yes. I am attaching the logs of both the code I have written and libdivecomputer generated logs. Also, for the sake of comparison, I am attaching combined logs of both. The first line in each pair in the file represents the data from libftdi and second line from libdivecomputer.

As I observed, 44 bytes are missing at offset 0xFE (line numbered 26) from read_data command.
Then again, 48 bytes are missing at offset 0x21C (line numbered 46) from read_data command.

For the rest of the logs, it is impossible to check for missing as all the data constitutes of 0xFF.

Regarding version of libusb being used, libusb-config --version command on my system gives output 0.1.12.
 
--
*Venkatesh Shukla*


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



import_ftdi.logs (265K) Download Attachment
import_subsurface.logs (178K) Download Attachment
compare_logs (585K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Data loss while ftdi_read_data() from FT232RL

Xiaofan Chen
On Thu, Jun 5, 2014 at 5:59 AM, Venkatesh Shukla
<[hidden email]> wrote:
> Regarding version of libusb being used, libusb-config --version command on
> my system gives output 0.1.12.

Then you should try to switch to libusb-1.0.18 and libftdi1-1.1
to see if that helps.


--
Xiaofan

--
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: Data loss while ftdi_read_data() from FT232RL

Venkatesh Shukla
On Thu, Jun 5, 2014 at 6:26 AM, Xiaofan Chen <[hidden email]> wrote:
On Thu, Jun 5, 2014 at 5:59 AM, Venkatesh Shukla
<[hidden email]> wrote:
> Regarding version of libusb being used, libusb-config --version command on
> my system gives output 0.1.12.

Then you should try to switch to libusb-1.0.18 and libftdi1-1.1
to see if that helps.


I tried. It seems libusb-1.0.8 is already installed in my system.
I tried building from sources but that doesn't change the libusb-config --version output for my system.
I tried 'sudo yum install libusb1' and the result was : Package libusbx-1.0.18-1.fc20.x86_64 already installed and latest version.

Also, I have built libftdi1-1.1 from sources. 

Still the error persists.
It is something else. Maybe I am not doing it the right way.

--
*Venkatesh Shukla*


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: Data loss while ftdi_read_data() from FT232RL

Xiaofan Chen
On Thu, Jun 5, 2014 at 3:10 PM, Venkatesh Shukla
<[hidden email]> wrote:
>
> I tried. It seems libusb-1.0.8 is already installed in my system.
> I tried building from sources but that doesn't change the libusb-config
> --version output for my system.
> I tried 'sudo yum install libusb1' and the result was : Package
> libusbx-1.0.18-1.fc20.x86_64 already installed and latest version.

libusb-config is only for libusb-0.1. You should use pkg-config
to check about libusb-0.1 and libusb-1.0.

Anyway, it seems your system comes with libusb-1.0
(libusbx-1.0.18 which is equivalent to libusb-1.0.18
since libusb and libusbx merged with the release
of libusb-1.0.18).

> Also, I have built libftdi1-1.1 from sources.

Is the build successful?

> Still the error persists.
> It is something else. Maybe I am not doing it the right way.

What do you mean by error persist?

BTW, you need to make sure you understand the
communication protocol of the device. You mentioned
the following:
> Then it sends the device headers. This is the data I need. It
> should be of 65536 bytes. But I am reading only around 65446
> bytes. It is a serious error."

You will need to make sure your device really send 65536
bytes and not 65446 bytes.

You can try to use usbmon to see if your device
really send 65536 bytes.
https://www.kernel.org/doc/Documentation/usb/usbmon.txt

--
Xiaofan

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

Loading...