//---------------------------------------------------------------------------
void __fastcall CanReceive::Execute()
{
HANDLE hEvent;
unsigned int command;
read = write = 0;
Priority = tpNormal;
FreeOnTerminate = true;
hEvent = CreateEvent(NULL, false, false, "");
FT_SetEventNotification(ftHandle, FT_EVENT_RXCHAR, hEvent);
while(Terminated == False)
{
WaitForSingleObject(hEvent, INFINITE);
EnterCriticalSection(&Form1->CS);
usb_Read(&RxMessage[write]);
if(++write >= BUFFERSIZE){
write = 0;
}
LeaveCriticalSection(&Form1->CS);
}
}
//---------------------------------------------------------------------------