Quantcast

Isochronous IN problem

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

Isochronous IN problem

Ekkehard
Hello,
still not perfectly working my isochronous IN transfer.
The current problem is that usb_reap_async returns very fast and returns length of data which is much too small (eg. 8K instead of 64K)
My approach is in a thread and the functions works as follow (psedo-code, catching errors not shown)

  BufCount = 8;
  TSEndPoint = $84;
  PacketSize = 5*188;
  QueryReadCount = 64*PacketSize;


for i := 0 to BufCount-1
  usb_isochronous_setup_async(FDeviceHandle, pcontexts[i], TSEndPoint, PacketSize);
for i := 0 to BufCount-1
  usb_submit_async(pcontexts[i], @(bufs[i,0]), QueryReadCount);
while not Terminated {
  for i := 0 to BufCount-1 {
    len := usb_reap_async(pcontexts[i], FTimeOutMs);
    if len > 0
      ProcessData(xxx)
    usb_submit_async(pcontexts[i], @bufs[i,0], QueryReadCount);
  }
}

If I use a USB logger (like SnoopyPro), than I can see that the USB Isochronous transfer, contains 64 packets with PacketSize data, contiously filled with the expected data, but in the program len indicates usually less than 10 packets.
I have to use isochronous transfer.
Any ideas?

Best regards
Ekkehard

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

Re: Isochronous IN problem

Ekkehard
Some news on the problem.
I filled the transfer buffer prior the call of usb_submit_async with 0xFF, and found that the driver scatter the received data in the whole buffer. The length returned by usb_reap_async is the netto sum of received data. These amount of bytes are now laying in the buffer, but where? I logged the transfer in parallel with USB SnoopyPro and found that the data are well organized in offset and length.
Example: you have a Packetsize of 1024 and a Buffer size of 4 Packets (4096 bytes in total), and the device has not so much data to send, so it fills the transfered Packets only half than your usb_reap_async returns 2048 but the data may be organized as follow

Address Content ("xx" = 256 bytes of unchanged data, "data" 256 bytes received data
0000 xx
0100 data
0200 data
0300 xx

0400 data
0500 xx
0600 data
0700 xx

0800 xx
0900 xx
0A00 data
0B00 data

0C00 xx
0D00 data
0E00 xx
0F00 data

So you see 8*256 bytes received data = 2048. Unfortunally if your data are not different from the "underground" you can not identify (Of course the data is alligned to the packetsize which is helpful)
So the questions to the developers, where can I access the list of received bytes and there location?
Best regards and have a nice weekend
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Ekkehard
Bad news, something still not working. I am able to locate my data, but if the scattered data is located on a specific address in the buffer, the values are corrupted. In parallel the SnoopyPro shows uncorrupted data.
I am near to thingk, that I am the first person who uses this isochronous stuff under Windows.
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Isochronous IN problem

Xiaofan Chen


On Friday, November 25, 2011, Ekkehard <[hidden email]> wrote:
> Bad news, something still not working. I am able to locate my data, but if
> the scattered data is located on a specific address in the buffer, the
> values are corrupted. In parallel the SnoopyPro shows uncorrupted data.
> I am near to thingk, that I am the first person who uses this isochronous
> stuff under Windows.

Is this a high speed USB device? Libusb-win32 may not work well
for high speed isochronous device. You might try libusbk.sys
and see if that helps, just change the driver without changing
your device first. Or you can look at the native libusbk API.

libusbk website:
http://code.google.com/p/usb-travis/


--
Xiaofan

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Ekkehard
Yes it is an high-speed device, and I want to reach rougly 45MBit/s transferrate.
I am not amused to hear, that this LibUSB Win32, will not work. Esspecially at this stage of development, but thats "open source" :-)
I tested your approach with libusbK and this stuff changes something, but is (using the same API) not the final solution.
For example the buffer could now increaded above 64K. For lower data rates (less than 10MBit/s) the stuff is working (in High-Speed Mode).
Thanx.
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Xiaofan Chen
On Sat, Nov 26, 2011 at 9:35 PM, Ekkehard
<[hidden email]> wrote:
> Yes it is an high-speed device, and I want to reach rougly 45MBit/s
> transferrate.

That should be possible.

> I am not amused to hear, that this LibUSB Win32, will not work. Esspecially
> at this stage of development, but thats "open source" :-)

Travis will be able to give you more details about the limitations of
libusb-win32
in terms of high speed isochronous transfer.

One of the motivation to move to libusbK (based on KMDF) is to improve
the isochronous transfer.

> I tested your approach with libusbK and this stuff changes something, but is
> (using the same API) not the final solution.
> For example the buffer could now increaded above 64K. For lower data rates
> (less than 10MBit/s) the stuff is working (in High-Speed Mode).

Good to hear that it works for some cases. But for 45Mbit/sec, I think
libusbK should able to work. What is the problem you are having?
Are you using the libusb-win32 API or the libusbK API?

--
Xiaofan

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Ekkehard
Xiaofan Chen wrote
Travis will be able to give you more details about the limitations of
libusb-win32
in terms of high speed isochronous transfer.
Is Travis reading this thread?

Xiaofan Chen wrote
One of the motivation to move to libusbK (based on KMDF) is to improve
the isochronous transfer.
Sure, because it's not really working with LibUSB Win32

Xiaofan Chen wrote
Good to hear that it works for some cases. But for 45Mbit/sec, I think
libusbK should able to work. What is the problem you are having?
Are you using the libusb-win32 API or the libusbK API?
For the quick check with libusbK, I simply installed the new generated driver, and left my SW unchanged. The major problem is that the data becomes corrupted, when the data rate is higher than 10MBit/s. With an unchange LibUsb-Win32 this occours every time (my minimum data rate is 6-8MBit/s).
As explained above it is not easy to guess where valid packets are placed by the driver in the transfer buffer. I fill the buffer prior to the query with $FF and my packets are clear to identify. But depending on the requested size, one specific address becomes damaged.

I am now busy to understand the native libusbK interface. Unfortunally there exists no Delphi (Pascal) port, and the header file is huge, so I am porting, and porting, ... on a lazy sunday afternoon :-)

Best regards
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Travis
On 11/27/2011 6:03 AM, Ekkehard wrote:
> Xiaofan Chen wrote
>> Travis will be able to give you more details about the limitations of
>> libusb-win32
>> in terms of high speed isochronous transfer.
>>
> Is Travis reading this thread?
>

Yes. I was only away for the holidays. ;)

> Xiaofan Chen wrote
>> One of the motivation to move to libusbK (based on KMDF) is to improve
>> the isochronous transfer.
>>
> Sure, because it's not really working with LibUSB Win32
>
>
> Xiaofan Chen wrote
>> Good to hear that it works for some cases. But for 45Mbit/sec, I think
>> libusbK should able to work. What is the problem you are having?
>> Are you using the libusb-win32 API or the libusbK API?
>>
> For the quick check with libusbK, I simply installed the new generated
> driver, and left my SW unchanged. The major problem is that the data becomes
> corrupted, when the data rate is higher than 10MBit/s.
Your data rate should not be limited in any way by libusbK.  Make sure
your are using the async API and always have 2 or more transfers pending.
Make sure your test application is not writing gobs of text to std.

Using an AVR UC3 Xplained demo board, We can sustain extremely high data
rates.

>   With an unchange
> LibUsb-Win32 this occours every time (my minimum data rate is 6-8MBit/s).
> As explained above it is not easy to guess where valid packets are placed by
> the driver in the transfer buffer.

Using these basic transfer functions, libusbK.sys should be packing the
valid bytes to the front of the transfer buffer.  i.e. When the reap
function returns the length, indexes 0 thru transferLength-1 contain
your valid data.  As you have noted, this is not necessarily true  for
libusb0.sys.  Instead the data remains indexed in packet frames and you
have no way of knowing which parts of the transfer buffer are valid.

libusb-win32 does transfer splitting in the dll (libusb0.dll).  This
does not really work for ISO pipes on transfers larger than 64k (hard
coded) because it waits for each batch to complete before submitting the
next.  i.e. There must always be multiple pending transfer requests.

> I fill the buffer prior to the query with
> $FF and my packets are clear to identify. But depending on the requested
> size, one specific address becomes damaged.
>
> I am now busy to understand the native libusbK interface. Unfortunally there
> exists no Delphi (Pascal) port, and the header file is huge, so I am
> porting, and porting, ... on a lazy sunday afternoon :-)
>

Yes,  There are C# and vb.net ports but no pascal yet.  At any rate, I
hope you will send me your codes when your done.  I would like to
include your pascal port in the distribution packages.
If you run in to problems let me know.  libusbK is in beta so I am still
able to make public api changes. (not for much longer though)

Reflector can auto-generate delphi code from .NET, but I'm not sure if
it is any good.
I've attached it, but if you want to use any of it, let me know and I
will re-generate everything from the most up-to-date libusbK header files.

Regards,
Travis



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel

libusbK_delphi.txt (53K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Ekkehard
Hello Travis,
just short, because I am late and have to run home.
I will give you some code, as soon as it runs. Thanx for the header translation, I will take a look, but I have translated a lot of stuff so far.
Probably I have to ask you several things - but not today.
BTW I hope you enjoyed your holdays!

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

Re: Isochronous IN problem

Damos
In reply to this post by Travis
Hi !

>----- Original Message -----
>From: Travis
>To: [hidden email]
>Sent: Sunday, November 27, 2011 6:21 PM
>Subject: Re: [Libusb-win32-devel] Isochronous IN problem
>
> [...]
>Using an AVR UC3 Xplained demo board, We can sustain extremely high data
>rates.

Sorry for the off-topic, is this firmare for UC3 available somwhere?

Kind regards !

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Travis
On 11/27/2011 11:05 AM, Damos wrote:

> Hi !
>
>> ----- Original Message -----
>> From: Travis
>> To: [hidden email]
>> Sent: Sunday, November 27, 2011 6:21 PM
>> Subject: Re: [Libusb-win32-devel] Isochronous IN problem
>>
>> [...]
>> Using an AVR UC3 Xplained demo board, We can sustain extremely high data
>> rates.
> Sorry for the off-topic, is this firmare for UC3 available somwhere?
>

Yes, It is the Benchmark firmware for the AVR UC3.  You can use it with
kBench.exe to run a variety of tests.
All endpoint types are supported, but the AVR firmware is focused more
on isochronous transfers.
http://code.google.com/p/usb-travis/source/browse/#svn%2Ftrunk%2FBmFW%2FAVR%2FASF

If you have configuration questions, let me know and I will try to help.

Regards,
Travis

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Xiaofan Chen
In reply to this post by Ekkehard
On Thu, Nov 24, 2011 at 9:12 PM, Ekkehard
<[hidden email]> wrote:
> I have to use isochronous transfer.

BTW, I have to ask why you really need to use isochronous transfer?
Unless you are developing a USB Audio/Video device, isochronous
transfer can usually be replaced by interrupt and bulk transfer. This
is especially true for high speed USB device.

An example from NI.
http://zone.ni.com/devzone/cda/tut/p/id/4636

--
Xiaofan

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Ekkehard
In reply to this post by Damos
Hello Travis, hello Xiaofan,
I have done some more investigation in my problem, which also existst with libUsbK.
My latest impression is, that the maximum packet size, declared in the descriptor, causes the trouble.
To disclose thirdparty problems, I create (or modify) a small firmware for my Cypress FX2 based test board.
This firmware does nothing else than prepare the send buffer with some data (marker, packet counter), and arm them as fast as possible. This allows 45..62 MBit/s transfer speed, which is less than expected, but enough for my purpose.

If I declare the maximum packet size to 0x400 (1024d) in the decriptor than everything run smooth. The transmitted data seems to be uncorrupted, since the marker are in place and the counters are contious.

If I declare the maximum packet size to 0x3AC (940d) in the descriptor, the trouble starts. If I use only less than 320 bytes per packet (roughly 20MBit/s) the stuff is running, if I increase the actual packetsize the data becomes corrupted (overwritten with zeros, 0xFFs or random data). This behaviour is data rate independend, because if I only send larger packets in larger time steps, they are still corrupted.

Just to block the question: No I can not change the 940 Byte maximum packet size, since it is fixed in my target device.

I become now really desperated, and hope that you can help me.

Best regards
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem

Travis
On 11/29/2011 2:47 AM, Ekkehard wrote:

> Hello Travis, hello Xiaofan,
> I have done some more investigation in my problem, which also existst with
> libUsbK.
> My latest impression is, that the maximum packet size, declared in the
> descriptor, causes the trouble.
> To disclose thirdparty problems, I create (or modify) a small firmware for
> my Cypress FX2 based test board.
> This firmware does nothing else than prepare the send buffer with some data
> (marker, packet counter), and arm them as fast as possible. This allows
> 45..62 MBit/s transfer speed, which is less than expected, but enough for my
> purpose.

Interesting, would this firmware work with this board?
http://www.cutedigi.com/product_info.php?products_id=4515
I have one of these but I have never used it.  I cannot test this 940
byte packet size with my current hardware so if you could help me get
this firmware running on the device above it would help tremendously.

> If I declare the maximum packet size to 0x400 (1024d) in the decriptor than
> everything run smooth. The transmitted data seems to be uncorrupted, since
> the marker are in place and the counters are contious.
>
> If I declare the maximum packet size to 0x3AC (940d) in the descriptor, the
> trouble starts. If I use only less than 320 bytes per packet (roughly
> 20MBit/s) the stuff is running, if I increase the actual packetsize the data
> becomes corrupted (overwritten with zeros, 0xFFs or random data). This
> behaviour is data rate independend, because if I only send larger packets in
> larger time steps, they are still corrupted.
>

What are you using for the transfer size? High speed devices need to
transfer packets in intervals of 8; there are other limitations as well.
It would help if I could see your PC code.  It is okay if it's delphi.

> Just to block the question: No I can not change the 940 Byte maximum packet
> size, since it is fixed in my target device.
>
> I become now really desperated, and hope that you can help me.
>

ISO is one of libusbK's primary functions.  Provided hardware is working
properly and USB 2.0 high speed rules are not being violated, I'm
confident we can resolve your problem.

I will wait for your response about my cutedigi board. What we do next
will be dependent on that.

Regards,
Travis


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem (Solved, but why?)

Ekkehard
Hello Travis,
the stuff is running! But I dont know why?
I believed until a few minutes ago that the size given to UsbK_IsoReadPipe must be multiples of the maximum packet size from the descriptor (and multiples of 8). So I allways used multiples of 940, eg. 64*940.
But this seems to be wrong!
I also believed that the calls
IsoK_Init and IsoK_SetPackets
also tied to the maximum packet of the descriptor.

But digging around with my test FW, I made a mistake, leaving 1024 bytes as packet size in my Windows program, while having 940 bytes as maximum packet size in the descriptor.

And, surprise, it's running!!

Honnestly, without this mistake I would not be able to guess this.

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

Re: Isochronous IN problem (USB Board)

Ekkehard
In reply to this post by Travis
The mentioned Board uses the CY7C68014A, while mine uses the Cy7C68013 chip.
I expect that the FW examples bound with the development kit of the FX2 will work with both chips.
Basicly my FW follows the Streaming example given in
http://www.cypress.com/?rID=12967
Just the descriptor and the send packetsize are changend
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem (Solved, but why?)

Travis
In reply to this post by Ekkehard
On 11/29/2011 8:52 AM, Ekkehard wrote:
> Hello Travis,
> the stuff is running! But I dont know why?

Great! Glad you are having success.

> I believed until a few minutes ago that the size given to UsbK_IsoReadPipe
> must be multiples of the maximum packet size from the descriptor (and
> multiples of 8). So I allways used multiples of 940, eg. 64*940.
> But this seems to be wrong!

It must be large enough to hold the data described by the iso packet
descriptors.
In your case, this seems mostly correct?  The transfer size must be
intervals of 8*940.
Could you elaborate?

> I also believed that the calls
> IsoK_Init and IsoK_SetPackets
> also tied to the maximum packet of the descriptor.
>

No.  These advanced ISO functions give you full control of the packet
descriptors.
IsoK_Init() creates a hunk of memory to hold the iso packet descriptors
(not the data).
IsoK_SetPackets() initializes all iso packets to the same length
(specified).

> But digging around with my test FW, I made a mistake, leaving 1024 bytes as
> packet size in my Windows program, while having 940 bytes as maximum packet
> size in the descriptor.
>

That would certainly cause problems. ;)

So, is this correct?
you are calling IsoK_Init() with NumberOfPackets=64
IsoK_SetPackets() with PacketSize=940
and using a transfer size of 64*940 in UsbK_IsoReadPipe()

Regards,
Travis


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem (Solved, but why?)

Ekkehard
Hello Travis,
ok I was too short, here comes everything in detail
1.) Descriptor
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DLL version: 1.2.5.0
Driver version: 3.0.4.0

bus/device  idVendor/idProduct
bus-0/\\.\libusb0-0255--0xXXXX-0xXXXX XXXX/XXXX
- Manufacturer : XXXXXXXXXXXX
- Product      : XXXXXXXXXXXX
- Serial Number: XXXXXXXXXXXX
bLength:             18
bDescriptorType:     01h
bcdUSB:              0200h
bDeviceClass:        00h
bDeviceSubClass:     00h
bDeviceProtocol:     00h
bMaxPacketSize0:     40h
idVendor:            2013h
idProduct:           024Fh
bcdDevice:           0100h
iManufacturer:       1
iProduct:            2
iSerialNumber:       3
bNumConfigurations:  1
  wTotalLength:         55
  bNumInterfaces:       1
  bConfigurationValue:  1
  iConfiguration:       0
  bmAttributes:         80h
  MaxPower:             250
    bInterfaceNumber:   0
[snip AlternateSetting  0]
    bAlternateSetting:  1
    bNumEndpoints:      2
    bInterfaceClass:    255
    bInterfaceSubClass: 0
    bInterfaceProtocol: 0
    iInterface:         0
      bEndpointAddress: 84h
      bmAttributes:     01h
      wMaxPacketSize:   940
      bInterval:        1
      bRefresh:         0
      bSynchAddress:    0
      bEndpointAddress: 85h
      bmAttributes:     01h
      wMaxPacketSize:   940
      bInterval:        1
      bRefresh:         0
      bSynchAddress:    0

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

2.) Definitions in Windows SW
  BufCount = 16;
  TSEndPoint = $84;
  PacketSize = 1024;
  IsoPacketsPerTransfer = 128;  
  QueryReadCount = IsoPacketsPerTransfer*PacketSize;

3.) Function calls (Delphi/Pascal)

SetLength(myBuffers[i],QueryReadCount); // BufCount buffers
...
IsoK_SetPackets(isoCtxs[i], PacketSize);
...
success := UsbK_IsoReadPipe(usbHandle, TSEndPoint, myBuffers[i][0], Length(myBuffers[i]), ovlkHandles[i], isoCtxs[i]);
...
success := OvlK_WaitOrCancel(ovlkHandles[i], 1000, transferredLength);
...
// loop through all isoPackets, with Offset and Length

Conclusion:
The maximum packet size "940" in the descriptor is total misleading. It can probably not work because 940 could not be divided by 8, without remainder.
But 1024 works perfect! All data is alligned, all isoPacket.Offset values are correct etc.

One other thing, I have seen that you only pass the lower 16bit of the isoPacket status, this might be a problem because some status are zero in the lowest 16bit and contain errors
#define USBD_STATUS_CANCELED                            ((USBD_STATUS)0xC0010000L)
Maybe you can copy the topmost 2 bits of the original status to the bit 15 and 14 of the 16 bit status that you return.


Best regards
Ekkehard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem (Solved, but why?)

Travis
On 11/30/2011 1:01 AM, Ekkehard wrote:

> Hello Travis,
> ok I was too short, here comes everything in detail
> 1.) Descriptor
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> DLL version: 1.2.5.0
> Driver version: 3.0.4.0
>
> bus/device  idVendor/idProduct
> bus-0/\\.\libusb0-0255--0xXXXX-0xXXXX XXXX/XXXX
> - Manufacturer : XXXXXXXXXXXX
> - Product      : XXXXXXXXXXXX
> - Serial Number: XXXXXXXXXXXX
> bLength:             18
> bDescriptorType:     01h
> bcdUSB:              0200h
> bDeviceClass:        00h
> bDeviceSubClass:     00h
> bDeviceProtocol:     00h
> bMaxPacketSize0:     40h
> idVendor:            2013h
> idProduct:           024Fh
> bcdDevice:           0100h
> iManufacturer:       1
> iProduct:            2
> iSerialNumber:       3
> bNumConfigurations:  1
>    wTotalLength:         55
>    bNumInterfaces:       1
>    bConfigurationValue:  1
>    iConfiguration:       0
>    bmAttributes:         80h
>    MaxPower:             250
>      bInterfaceNumber:   0
> [snip AlternateSetting  0]
>      bAlternateSetting:  1
>      bNumEndpoints:      2
>      bInterfaceClass:    255
>      bInterfaceSubClass: 0
>      bInterfaceProtocol: 0
>      iInterface:         0
>        bEndpointAddress: 84h
>        bmAttributes:     01h
>        wMaxPacketSize:   940
>        bInterval:        1
>        bRefresh:         0
>        bSynchAddress:    0
>        bEndpointAddress: 85h
>        bmAttributes:     01h
>        wMaxPacketSize:   940
>        bInterval:        1
>        bRefresh:         0
>        bSynchAddress:    0
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> 2.) Definitions in Windows SW
>    BufCount = 16;
>    TSEndPoint = $84;
>    PacketSize = 1024;
>    IsoPacketsPerTransfer = 128;
>    QueryReadCount = IsoPacketsPerTransfer*PacketSize;
>
> 3.) Function calls (Delphi/Pascal)
>
> SetLength(myBuffers[i],QueryReadCount); // BufCount buffers
> ...
> IsoK_SetPackets(isoCtxs[i], PacketSize);
> ...
> success := UsbK_IsoReadPipe(usbHandle, TSEndPoint, myBuffers[i][0],
> Length(myBuffers[i]), ovlkHandles[i], isoCtxs[i]);
> ...
> success := OvlK_WaitOrCancel(ovlkHandles[i], 1000, transferredLength);
> ...
> // loop through all isoPackets, with Offset and Length
>
> Conclusion:
> The maximum packet size "940" in the descriptor is total misleading. It can
> probably not work because 940 could not be divided by 8, without remainder.

The "interval of 8" constraint applies to the number of packets, not the
maximum packet size, so 940 *should* be acceptable.

> But 1024 works perfect! All data is alligned, all isoPacket.Offset values
> are correct etc.
>

There should be holes of uninitialized data in your transfer buffer
every 940 bytes.  Is this the case?

Is it possible your device is returning more than 940 bytes despite what
is defined in the ep descriptor?

I'm beginning to suspect that the "940" in your endpoint descriptor is
misleading because it is literally incorrect as it is being treated as a
1024 byte ep.

> One other thing, I have seen that you only pass the lower 16bit of the
> isoPacket status, this might be a problem because some status are zero in
> the lowest 16bit and contain errors
> #define USBD_STATUS_CANCELED
> ((USBD_STATUS)0xC0010000L)

Correct.  This was a recent change that decreases the size of an iso
packet descriptor to 64bits

> Maybe you can copy the topmost 2 bits of the original status to the bit 15
> and 14 of the 16 bit status that you return.
>

Thanks for the tip.  I will get this fixed for the next release.

Regards,
Travis


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Isochronous IN problem (Solved, but why?)

Ekkehard
I am working with an existing device, coming up with the given descriptor.
Since it does'nt worked, I made a firmware for my Cypress board to emulate the behavior, e.g. coming up with an compareable descriptor, sending data in the same size and matter etc.
Having now two devices behaving same, I am pretty sure that there is something strange - or not understood by me.
As described above in the thread I was able to catch the transmitted data with Snoopy Pro, which shows the up and down going URBs and there related content.
Definitly I can say that a buffer size of 940 bytes passed to the related functions, will cause errors in the received data, more precisely in the URBs shown in Snoopy Pro. The errors occours often on the same memory positions, but I was not able to determine the prinicple of occourence.
Using 1024 instead (a kind of ignoring the descriptor) works perfect. There are no transmission errors, holes, overwritten or missed data, etc. I left the program run for hours free of errors.
Anyway, since it works, your software does the job!!
12
Loading...