3 Replies Latest reply on Jul 29, 2019 10:52 PM by SrinathS_16

    Multiple uses of XferData for CCyIsocEndPoint

    RuPa_4353591

      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!

      }