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

USB low-full-high speed peripherals Forum Discussions

chhe_4303246
Level 2
Level 2

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 -> bIn;

bool bBulk =  (Camera -> EndPoints -> Attributes == 2);

if (bBulk  && bIn) BulkIn = (CCyBulkEndPoint *) Camera -> EndPoints;

   }

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.hEvent = CreateEvent(NULL, false, false, NULL);

for (i = 0; i < packageNum; i++)

{

inContext = BulkIn -> BeginDataXfer(buf, packageSize, &inOvLap);

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, 1000))

{

BulkIn->Abort();

            WaitForSingleObject(inOvLap.hEvent,INFINITE);

};

}

buf = (PUCHAR)image;

for (i = 0; i < packageNum; i++)

{

BulkIn -> FinishDataXfer(buf, (LONG &) recieveNum, &inOvLap, inContext);

totalNum -= recieveNum;

CloseHandle(inOvLap.hEvent);

buf += packageSize;

}

ctrlPoint -> ReqCode = 0xa9;

ctrlPoint -> XferData(ctrlBuf, length);//this vendor cmd tell the camera board to stop send frame data

0 Likes
1 Solution

Hello:

     Mr Yatheesh, I solved this by reduced the camera input frame rate from 60fps to 30fps, Now I can use libusb to receive the camera frame correctly.I think the problem is in the PC's usb hardware interface, It's bandwith can't reach fx2's USB interface requirement

View solution in original post

0 Likes
3 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

The CYAPI library source can be found in the FX3 SDK page (CyUSB3_USB_Suite_Source.zip) and is not open source. You may use the source code for reference.

Can you please let me know which example program you have referred for writing your code in linux for FX2.

Best Regards,

Yatheesh

0 Likes

Hello:

     Yatheesh, I am not using the fx2 example code, I am using a fx2 based usb camera board which I told front before.So I am devloped with the board it's firmware code which I also think based on fx2 slavefifo example code like.

0 Likes

Hello:

     Mr Yatheesh, I solved this by reduced the camera input frame rate from 60fps to 30fps, Now I can use libusb to receive the camera frame correctly.I think the problem is in the PC's usb hardware interface, It's bandwith can't reach fx2's USB interface requirement

0 Likes