I wrote simple code, wich uses Bulk transfer.
Now it makes out transfer, and after transfers in, using the standart bulkloop.hex.
Made it on C++, used thread:
//---------------------------------------------------------------------------
class WriteAndReadThread : public TThread
{
private:
void __fastcall Printing();
protected:
void __fastcall Execute();
public:
__fastcall WriteAndReadThread(bool CreateSuspended);
};
//---------------------------------------------------------------------------
WriteAndReadThread *writereader;
//---------------------------------------------------------------------------
//конструктор потока WriteAndReadThread, по умолчанию пустой
__fastcall WriteAndReadThread::WriteAndReadThread(bool CreateSuspended) : TThread(CreateSuspended)
{}
//---------------------------------------------------------------------------
void __fastcall WriteAndReadThread::Execute()
{
AnsiString stryng = Form1->Edit1->Text.c_str();
outBuf=new char[stryng.Length()+1];
strcpy(outBuf,stryng.c_str());
length = stryng.Length()+1;
//length = strlen(buffer);
while(!Terminated)
{
outOvLap.hEvent = CreateEvent(NULL, false, false, "CYUSB_OUT");
UCHAR *outContext;
outContext = USBDevice->BulkOutEndPt->BeginDataXfer(outBuf, length, &outOvLap);
USBDevice->BulkOutEndPt->WaitForXfer(&outOvLap,100);
succesOut = USBDevice->BulkOutEndPt->FinishDataXfer(outBuf, length, &outOvLap,outContext);
if(!succesOut)
{
writereader->Terminate();
if(drawer)drawer->Terminate();
Form1->SpeedButton1->Caption = "Begin transfer";
Form1->SpeedButton1->Down = false;
Form1->Memo1->Lines->Add("Sending error!");
}
CloseHandle(outOvLap.hEvent);
inOvLap.hEvent = CreateEvent(NULL, false, false, "CYUSB_IN");
UCHAR *inContext = USBDevice->BulkInEndPt->BeginDataXfer(inBuf, length, &inOvLap);
USBDevice->BulkInEndPt->WaitForXfer(&inOvLap,100);
succesIn = USBDevice->BulkInEndPt->FinishDataXfer(inBuf, length, &inOvLap,inContext);
if(!succesIn)
{
writereader->Terminate();
if(drawer)drawer->Terminate();
Form1->SpeedButton1->Caption = "Begin transfer";
Form1->SpeedButton1->Down = false;
Form1->Memo1->Lines->Add("Recieving error!");
}
Synchronize(Printing);
CloseHandle(inOvLap.hEvent);
}
The speed for in transfer is realy slow. If I'll make the only IN transfer it will be not higther than 1 Mbyte per second.
Using the CyAPI how can I make with the speed 12 Mbyte per sec?
|