Discussion:
[Libusbx-devel] Isochronous packets request result in 8byte garbage at the end of accumulated packets
Kuldeep Singh Dhaka
2014-06-01 10:35:04 UTC
Permalink
Howdy guys,
Im facing a weird problem.
i have a ST uC (FS usb) that send data of ADC (12 bit) at 176Kilo
samples at bInterval=1; (2bytes for 1 sample)
ie 352byte isochronous endpoint requested every 1ms

when i request 1000 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of the 999th packet (assuming
packet index start from 0).
when i request 500 packets (each of 352 bytes), i received 8byte garbage
value (mostly 0x00) at the end of 499th packet.
when i request 100 packets (each of 352 bytes), i received 8byte garbage
value (mostly 0x00) at the end of 99th packet.
when i request 10 packets (each of 352 bytes) i received 8byte byte
garbage value (mostly 0x00 | non-zero on offset 1 byte of garbage start)
at the end of 9th packet. (non-zero garbage value position is 352 - 8 + 1).

since, the garbage position shits as number of packets variate, so i can
assume that the device is successfully sending each packet.
(and the packet count also not known to device, it very unlikely that
this will be related to device).
(even if the problem is in device, the problem should occur in each
packet or some multiple version, why every-time error position is similar)

i can see plotting bumps, or 4 samples are garbage after the accumulated
packets are plotted. (qcustomplot + qt + libusbx)
im reading sine wave using the ADC so the problem can be seen visually.
plotting on a 10second time-line, request 1000 packets in one callback
(1second data), i see 10 points inconsistent, (and after zooming to any
of the point, i can see that the point is made up of 4 samples that are
always garbage).

for 1000 packets (and 10second timeline) i see 10 inconsistent points
(all 0V)
for 100 packets (and 10second timeline) i see 50 inconsistent points
(all 0V),
for 10 packets (and 10 second timeline) i see 100 * 10 inconsistent
points (first is usually 40 volts (max voltage is 3V), and all others
are 0V)

plotting approch: start plotting from 0th position, and when reach the
end of memory, again start plotting from 0th position, this is how i was
able detect that the problem (that it is at the end of accumulated
packets of one callback). (garbage point are always at constant position)

another test:
i wrote pre-defined bytes (also that would never be send by device) to
the allocated buffer buffer, before submiting the iso packets request,
and after the callback, the memory was garbage (last 8byte were not
equal to the pre-defined bytes). so the memory was actually being
incorrectly written written by device, or kernel or libusb.

but since based on the assumption the problem is not from device,
problem should be kernel or libusb.

[***@localhost ~]$ uname -a
Linux localhost.localdomain 3.13.11-100.fc19.x86_64 #1 SMP Wed Apr 23
20:10:57 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[***@localhost ~]$ yum info libusbx
Loaded plugins: auto-update-debuginfo, langpacks
Installed Packages
Name : libusbx
Arch : i686
Version : 1.0.16
Release : 3.fc19
Size : 127 k
Tim Roberts
2014-06-02 18:38:28 UTC
Permalink
Post by Kuldeep Singh Dhaka
Im facing a weird problem.
i have a ST uC (FS usb) that send data of ADC (12 bit) at 176Kilo
samples at bInterval=1; (2bytes for 1 sample)
ie 352byte isochronous endpoint requested every 1ms
when i request 1000 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of the 999th packet (assuming
packet index start from 0).
when i request 500 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of 499th packet.
when i request 100 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of 99th packet.
when i request 10 packets (each of 352 bytes) i received 8byte byte
garbage value (mostly 0x00 | non-zero on offset 1 byte of garbage
start) at the end of 9th packet. (non-zero garbage value position is
352 - 8 + 1).
Can you show us your code? It's difficult to imagine how anything below
your application could cause this.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Kuldeep Singh Dhaka
2014-06-04 12:13:37 UTC
Permalink
Finally got the problem solved, (sorry for the chaos.)
problem was i incorrectly used "libusb_control_transfer_get_data"
instead of transfer->buffer and that was contributing to the +8.
instead of sending the whole source (ie WIP, untested mostly), when i
wrote a new program (to share), it didnt showed the error, and finally
found the differential. :).
Thank You.
Post by Tim Roberts
Post by Kuldeep Singh Dhaka
Im facing a weird problem.
i have a ST uC (FS usb) that send data of ADC (12 bit) at 176Kilo
samples at bInterval=1; (2bytes for 1 sample)
ie 352byte isochronous endpoint requested every 1ms
when i request 1000 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of the 999th packet (assuming
packet index start from 0).
when i request 500 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of 499th packet.
when i request 100 packets (each of 352 bytes), i received 8byte
garbage value (mostly 0x00) at the end of 99th packet.
when i request 10 packets (each of 352 bytes) i received 8byte byte
garbage value (mostly 0x00 | non-zero on offset 1 byte of garbage
start) at the end of 9th packet. (non-zero garbage value position is
352 - 8 + 1).
Can you show us your code? It's difficult to imagine how anything
below your application could cause this.
--
Providenza & Boekelheide, Inc.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
libusbx-devel mailing list
https://lists.sourceforge.net/lists/listinfo/libusbx-devel
--
*Kuldeep Singh Dhaka*
+91-8791676237
Programmer, Open Source, Embedded System, Entrepreneur, System
Administrator, Animal Lover, Web Developer, Learner.
My GnuPG Public Key
<http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x23816C5609DC7E26>
Fork Me <http://github.com/kuldeepdhaka>
Bitcoins Accepted.
Loading...