//////////////////////////////////////////////////////////////////////////// // demoCreateRxThread // set the notification and creates the thread. // //////////////////////////////////////////////////////////////////////////// XLstatus demoCreateRxThread(void) { XLstatus xlStatus = XL_ERROR; DWORD ThreadId=0; if (g_xlPortHandle != XL_INVALID_PORTHANDLE) { // Send an event for each Msg!!! xlStatus = xlSetNotification (g_xlPortHandle, &g_hMsgEvent, 1); g_hRXThread = CreateThread(0, 0x1000, RxThread, (LPVOID) 0, 0, &ThreadId); } return xlStatus; }
/** * \brief Read thread procedure * \param[in] pVoid contains the CPARAM_THREADPROC class object * \return void * \authors Arunkumar Karri * \date 07.19.2013 Created */ DWORD WINAPI CDIL_LIN_VectorXL::LINMsgReadThreadProc_LIN_Vector_XL(LPVOID pVoid) { USES_CONVERSION; CPARAM_THREADPROC* pThreadParam = (CPARAM_THREADPROC*) pVoid; XLstatus xlStatus = XL_SUCCESS; /* Assign thread action to CREATE_TIME_MAP */ pThreadParam->m_unActionCode = CREATE_TIME_MAP; /* Set the event to LIN_Vector_XL driver for wakeup and frame arrival notification */ //for (UINT i = 0; i < sg_unClientCnt; i++) { xlStatus = xlSetNotification (g_xlPortHandle[0], &g_hDataEvent[0], 1); } /* Set the thread action event to first notification event handle */ if (g_hDataEvent[0] != nullptr) { pThreadParam->m_hActionEvent = g_hDataEvent[0]; } /* Get the handle to the controller and validate it */ VALIDATE_POINTER_RETURN_VALUE_LOG(pThreadParam->m_hActionEvent, (DWORD)-1); DWORD dwResult = 0; unsigned int msgsrx; XLevent xlEvent; bool bLoopON = true; while (bLoopON) { WaitForSingleObject(g_hDataEvent[0], INFINITE); switch (pThreadParam->m_unActionCode) { case INVOKE_FUNCTION: { bool bMoreDataExist; msgsrx = RECEIVE_EVENT_SIZE; xlStatus = xlReceive(g_xlPortHandle[0], &msgsrx, &xlEvent); while (xlStatus == XL_SUCCESS ) { switch (xlStatus) { case XL_SUCCESS: { if ( g_pouDIL_LIN_Vector_XL != nullptr ) { g_pouDIL_LIN_Vector_XL->ProcessLINMsg(xlEvent); bMoreDataExist = true; } } break; default: break; } xlStatus = xlReceive(g_xlPortHandle[0], &msgsrx, &xlEvent);; } } break; case EXIT_THREAD: { bLoopON = false; } break; case CREATE_TIME_MAP: { //vCreateTimeModeMapping(pThreadParam->m_hActionEvent); SetEvent(pThreadParam->m_hActionEvent); pThreadParam->m_unActionCode = INVOKE_FUNCTION; } break; default: case INACTION: { // nothing right at this moment } break; } } SetEvent(pThreadParam->hGetExitNotifyEvent()); { ResetEvent(g_hDataEvent[0]); g_hDataEvent[0] = nullptr; } pThreadParam->m_hActionEvent = nullptr; return 0; }