- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the bulkloop source code, in function public unsafe void TransfersThread(), I just change to send out 1024 bytes per time, then inEndpoint.FinishDataXfer will return false, and failed receive the data. the change is as following, there will no problem if set xferLen to 1023 or 1025. I have attached the source code
xferLen = lenOut;
//calls the XferData function for bulk transfer(OUT/IN) in the cyusb.dll
bResult = outEndpoint.XferData(ref outBuffer, ref xferLen);
change to
xferLen = 1024; // has problem
//calls the XferData function for bulk transfer(OUT/IN) in the cyusb.dll
bResult = outEndpoint.XferData(ref outBuffer, ref xferLen);
Solved! Go to Solution.
- Labels:
-
USB Superspeed Peripherals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mary,
Yes. If the data received is not 256KB (in your case) and if it is multiple of 1KB, then the transfer fails.
To summarize again:
In your case, the IN transfer succeeds in below conditions
a. Entire 256KB is sent by device.
b. less than 256KB is sent, but the last packet is a short packet (size less than 1024 bytes).
c. less than 256KB is sent, but the last packet is a zero length packet.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Which firmware are you using on the device? What device controller are you using?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
The firmware I use is USBBulkLoopAuto, device controller is bulkloop.
And I found the XferData function also has same problem, I test with USB Control Center
1. send out 1024 byte
2. read 1025 bytes, XferData will return false
3. but if I send out 1023 bytes, then read 1025 bytes, XferData will return true
Since in my project, the data length sending out by firmware is not fixed, so the parameters len of function XferData(ref byte[] buf, ref int len) or BeginDataXfer(ref byte[] singleXfer, ref byte[] buffer, ref int len, ref byte[] ov) is large than the data sending out by firmware, it can be received successfully if firmware sends out 1023 or 1025 bytes, but if firmware sends out 1024 byte, the reception will fail
Looking forward to your reply, thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please see the thread https://community.cypress.com/t5/USB-Superspeed-Peripherals/XferData-may-return-FALSE-in-short-packe...
You can see the condition for which a transfer(made by the host) ends.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Adding to my last post:
The IN transfer initiated from the host ends under following conditions
a. All the requested data is sent by the device OR
b. less than requested data is sent by device BUT the last sent packet from the device is a short packet (not maxpacket size)
c. less than requested data is sent by the device BUT last sent packet from the device is Zero length packet (ZLP)
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
Thanks for your reply.
Do you mean the problem will be resolved by sending a ZLP after sending the 1024 bytes data? I will try this solution with our FPGA engineers.
Thanks,
Mary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
How to send a ZLP, and how does the PC confirm that the firmware has sent a ZLP?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
My inEndpoint.MaxPktSize is 16384, in buffer size is 16384 * 256, our FPGA change to send a ZLP if the sending data length is multiples of 16384, then the question that receive data failed if the data length is multiples of 16384 has been solved , but if the sending length is multiples of 1024 but not multiples of 16384, reception still fails, should the PGA change to send a ZLP if the sending data length is multiples of 1024?
Thanks,
Mary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mary,
Do you mean buffer size on your host application is 256*16KB?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
Yes, the buffer size on host application is 256*16KB, inEndpoint.MaxPktSize is 16KB
Thanks,
Mary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mary,
Yes. If the data received is not 256KB (in your case) and if it is multiple of 1KB, then the transfer fails.
To summarize again:
In your case, the IN transfer succeeds in below conditions
a. Entire 256KB is sent by device.
b. less than 256KB is sent, but the last packet is a short packet (size less than 1024 bytes).
c. less than 256KB is sent, but the last packet is a zero length packet.
Regards,