Multiple uses of XferData for CCyIsocEndPoint

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RuPa_4353591
Level 1
Level 1
First like given

I have a problem in using the CCyIsocEndPoint->XferData for a low-latency loopback application.

Basically I want to measure the loop latency in a FX3 device with the USBIsochLoopAuto firmware.

#include "CyAPI.h"

int main() {

   CCyUSBDevice *USBDevice = new CCyUSBDevice();

   CCyIsocEndPoint *IsoIn = USBDevice->IsocInEndPt;

   CCyIsocEndPoint *IsoOut = USBDevice->IsocOutEndPt;

   if (!IsoIn) { std::cout << "Failed to get IsocInEndPt\n"; return 1; }

   if (!IsoOut) { std::cout << "Failed to get IsocOutEndPt\n"; return 1; }

   const int bufSize = 8;

   LONG outbufLen;

   UCHAR outbuf[bufSize];

   LONG inbufLen;

   UCHAR inbuf[bufSize];

   CCyIsoPktInfo *isoOutPktInfos;

   CCyIsoPktInfo *isoInPktInfos;

   int pkts;

   isoOutPktInfos = IsoOut->CreatePktInfos(bufSize, pkts);

   isoInPktInfos = IsoIn->CreatePktInfos(bufSize, pkts);

   std::cout << "IsoOut->MaxPktSize: " << IsoOut->MaxPktSize << "\n";

   std::cout << "Allocated packets: " << pkts << "\n";

   // THIS WORKS:

   strcpy_s((char*)outbuf, bufSize, "hello");

   outbufLen = bufSize;

   inbufLen = bufSize;

   IsoOut->XferData(outbuf, outbufLen, isoOutPktInfos);

   IsoIn->XferData(inbuf, inbufLen, isoInPktInfos);

   std::cout << "Transferred out: " << outbufLen << ", in: " << inbufLen << "\n"; // Always bufSize

   std::cout << "isoOutPktInfos.Status: " << isoOutPktInfos->Status << "\n"; // Always 0

   std::cout << "isoOutPktInfos.Length: " << isoOutPktInfos->Length << "\n"; // Always bufSize

   std::cout << outbuf << " -> " << inbuf << "\n"; // Everything ok

   // THIS DOES NOT WORK:

   strcpy_s((char*)outbuf, bufSize, "world");

   outbufLen = bufSize;

   inbufLen = bufSize;

   IsoOut->XferData(outbuf, outbufLen, isoOutPktInfos);

   IsoIn->XferData(inbuf, inbufLen, isoInPktInfos);

   std::cout << "Transferred out: " << outbufLen << ", in: " << inbufLen << "\n"; // Often 0, sometimes strange values

   std::cout << "isoOutPktInfos.Status: " << isoOutPktInfos->Status << "\n"; // Often 0, Sometimes 67, 4390979, ...

   std::cout << "isoOutPktInfos.Length: " << isoOutPktInfos->Length << "\n"; // Often bufSize, Sometimes 67, 4390973, ...

   std::cout << outbuf << " -> " << inbuf << "\n"; // inbuf unchanged!

}

0 Likes
1 Solution

Hello Rune,

Please refer to my response 1 on Low latency loopback application

Best regards,

Srinath S

View solution in original post

0 Likes
3 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello,

I could reproduce the mentioned issue using the code snippet that you have shared. There seems to be an issue when two consecutive ISOC transfer requests are issued in quick succession to the endpoint. The issue is not seen when a Sleep(1500); statement is added after the first data word "hello' is transferred.

The issue is also seen on Control Center application. I shall dig more and let you know the possible cause of this issue.

Best regards,

Srinath S

Thanks,

I can add that the first transfer may also fail if we set a larger value for const int bufSize.

Sleeping will not be an option since the usecase is a streaming low-latency (low bandwidth) application:

Low latency loopback application

Looking forward to see if you can figure out a solution.

In general, any example/solution with low-latency two-way streaming would help.

//Rune

0 Likes

Hello Rune,

Please refer to my response 1 on Low latency loopback application

Best regards,

Srinath S

0 Likes