API CAN_Initialize CAN_SetValue both succeed, but WaitForSingleObject always get trigger while no message received. Here is my code. Could you help me with it please?
Code: Select all
void* canReceiveLoop(void* arg)
{
TPCANStatus status;
CAN_HANDLE handle = (CAN_HANDLE)arg;
HANDLE hEvent;
TPCANMsg peakMsg;
hEvent = CreateEvent(NULL, FALSE, FALSE, L"ReceiveEvent");
status = CAN_SetValue(handle, PCAN_RECEIVE_EVENT, &hEvent, sizeof(HANDLE));
if (status != PCAN_ERROR_OK) {
char strMsg[256];
CAN_GetErrorText(status, 0, strMsg);
MSG_ERROR("%s",strMsg);
return NULL;
}
while (1) {
if ( WAIT_OBJECT_0 == WaitForSingleObject(hEvent, INFINITE)) {
ResetEvent(hEvent);
CAN_Read(handle, &peakMsg, NULL)
}
}
return NULL;
}