I have problem with my application.
I have a wheel which is connected by CAN. This wheel send message at 100Hz.
But when i try to receive messages, i have 5sec of delay.
The message event is in a thread
It's my code :
Code: Select all
int UseEvent() {
std::cout << "DEMARRAGE UseEvent" << std::endl;
TPCANStatus status;
TPCANMsg peakMsg;
//status = CAN_Initialize(PCAN_PCIBUS1, PCAN_BAUD_1M);
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, L"ReceiveEvent");
status = CAN_SetValue(PCAN_PCIBUS1, PCAN_RECEIVE_EVENT, &hEvent, sizeof(HANDLE));
if (status != PCAN_ERROR_OK) {
char strMsg[256];
CAN_GetErrorText(status, 0, strMsg);
printf("%s", strMsg);
return NULL;
}
while (1) {
if (WAIT_OBJECT_0 == WaitForSingleObject(hEvent, INFINITE)) {
//ResetEvent(hEvent);
CAN_Read(PCAN_PCIBUS1, &peakMsg, NULL);
}
}
}
Thanks a lot,
Raphael