3 Replies Latest reply on Sep 8, 2019 6:47 PM by chhe_4303246

    How did windows Cyapi.lib communicate in bulk transaction compare to libusb with ubuntu?

    chhe_4303246

      Hello:

           I am currently using a fx2 based usb camera devlopment board, When I use Cyapi.lib to design a QT program  to communicate with it, Things all going fine to me, I can get a picture rate about 7fps with this camera board.But when comes to linux Ubuntu with libusb, I can't get a single full picture with the camera board, I put my linux code and  the picture I captured to the attachment files.

           So what's the diffrence between this two mechanism, IS the Cyapi.lib open source?If so, where can I download this code?And I read the cyusb_linux_1.0.5 code which is offered in the fx3 1.3.4 SDK version, I see there is no diffrence between the company code  and my code, at least the libusb usage is the same.Also to state more clearly, I paste the windows code which I use at the bottom:

      int i;
      
      
      CCyControlEndPoint * ctrlPoint = Camera -> ControlEndPt;
      ctrlPoint -> Target = TGT_DEVICE;
      ctrlPoint -> ReqType = REQ_VENDOR;
      ctrlPoint -> Direction = DIR_TO_DEVICE;
      ctrlPoint -> ReqCode = 0xa8;
      ctrlPoint -> Value = 0;
      ctrlPoint -> Index = 0;
      PUCHAR ctrlBuf = new UCHAR;
      
      
      PUCHAR buf = (PUCHAR)image;
      LONG length = 0;
      //ctrlPoint -> XferData(ctrlBuf, length);
      
      
      CCyBulkEndPoint * BulkIn = NULL;
      
      
      int eptCount = Camera -> EndPointCount();
      
      
      for (int i = 1; i < eptCount;  i++)
      { 
      bool bIn = Camera -> EndPoints[i] -> bIn; 
      bool bBulk =  (Camera -> EndPoints[i] -> Attributes == 2); 
      
      
      if (bBulk  && bIn) BulkIn = (CCyBulkEndPoint *) Camera -> EndPoints[i]; 
         } 
      
      
      int packageNum = 5;
      BulkIn ->SetXferSize(size / packageNum);
        LONG packageSize = size /packageNum;
      
      
      if (size % packageSize) packageNum ++;
      
      
      OVERLAPPED inOvLap[8];
      UCHAR * inContext[8];
      LONG recieveNum[8];
      int totalNum= size;
      
      
      for (i = 0; i <packageNum; i++) inOvLap[i].hEvent = CreateEvent(NULL, false, false, NULL);
      
      
      for (i = 0; i < packageNum; i++) 
      {
      inContext[i] = BulkIn -> BeginDataXfer(buf, packageSize, &inOvLap[i]);
      buf += packageSize;
      }
      
      ctrlPoint -> XferData(ctrlBuf, length);//this vendor cmd tell the camera board to start send frame data
      
      
      for (i = 0; i < packageNum; i++) 
      {
      
      
      if(!BulkIn -> WaitForXfer(&inOvLap[i], 1000)) 
      { 
      BulkIn->Abort();
                  WaitForSingleObject(inOvLap[i].hEvent,INFINITE);
      };
      }
      buf = (PUCHAR)image;
      for (i = 0; i < packageNum; i++)
      {
      BulkIn -> FinishDataXfer(buf, (LONG &) recieveNum[i], &inOvLap[i], inContext[i]);
      totalNum -= recieveNum[i];
      CloseHandle(inOvLap[i].hEvent);
      buf += packageSize;
      }
      
      
      ctrlPoint -> ReqCode = 0xa9;
      ctrlPoint -> XferData(ctrlBuf, length);//this vendor cmd tell the camera board to stop send frame data