/** * \brief Performs intial operations. * Initializes filter, queue, controller config with default values. * \param void * \return S_OK if the open driver call successfull otherwise S_FALSE */ HRESULT CDIL_CAN_MHS::CAN_PerformInitOperations(void) { HRESULT hResult; DWORD dwClientID; hResult = S_FALSE; sg_MhsCanCfg.CanSnrStr[0] = '\0'; sg_MhsCanCfg.CanSpeed = 125; sg_MhsCanCfg.CanBtrValue = 0; /* Create critical section for ensuring thread safeness of read message function */ InitializeCriticalSection(&sg_DIL_CriticalSection); /* Register Monitor client */ dwClientID = 0; if ( CAN_RegisterClient(TRUE, dwClientID, CAN_MONITOR_NODE) == S_OK ) { // ------------------------------------ // Init Driver // ------------------------------------ if (CanInitDriver(CanInitStr) >= 0) { // **** AutoConnect auf 1 //CanSetOptions("AutoConnect=1;AutoReopen=0"); // **** Event Funktionen setzen CanSetPnPEventCallback(&CanPnPEvent); CanSetStatusEventCallback(&CanStatusEvent); CanSetRxEventCallback(&CanRxEvent); // **** Alle Events freigeben CanSetEvents(EVENT_ENABLE_ALL); hResult = S_OK; } } return(hResult); }
HRESULT CDIL_CAN_STUB::CAN_PerformClosureOperations(void) { //First remove all the client for (UINT nCount = 0; nCount < sg_unClientCnt; nCount++) { CAN_RegisterClient(FALSE, sg_asClientToBufMap[nCount].dwClientID, _T("")); } // First disconnect from the simulation engine CAN_DeselectHwInterface(); // Then terminate the broker thread sg_sBrokerObjBusEmulation.bTerminateThread(); // Close the notification event if (NULL != sg_hNotifyFinish) { CloseHandle(sg_hNotifyFinish); sg_hNotifyFinish = NULL; } // Delete the critical section DeleteCriticalSection(&sg_CSBroker); sg_pIlog = NULL; // Log interface pointer SetCurrState(STATE_PRIMORDIAL); return S_OK; }
/** * \brief Performs intial operations. * Initializes filter, queue, controller config with default values. * \param void * \return S_OK if the open driver call successfull otherwise S_FALSE */ HRESULT CDIL_CAN_VSCOM::CAN_PerformInitOperations(void) { DWORD dwClientID; memset(&sg_VSCanCfg, 0, sizeof(sg_VSCanCfg)); /* Create critical section for ensuring thread safeness of read message function */ InitializeCriticalSection(&sg_DIL_CriticalSection); /* Register Monitor client */ dwClientID = 0; CAN_RegisterClient(TRUE, dwClientID, CAN_MONITOR_NODE); return(S_OK); }
/** * Close doen the iView interface driver. * Remove all the clients and buffers. * Stop the mDNS browser deselect the interfaces and * delete all the registered VCIs. */ HRESULT CDIL_CAN_i_VIEW::CAN_PerformClosureOperations(void) { VALIDATE_VALUE_RETURN_VAL(m_CurrState, STATE_DRIVER_SELECTED, ERR_IMPROPER_STATE); pClientMap_t Clients = m_Clients; pClientMap_t::iterator CItr = Clients.begin(); for (; CItr != Clients.end(); CItr++ ) { DWORD Id = CItr->first; CAN_RegisterClient(FALSE, Id, nullptr); } if (m_iViewBrowser) { m_iViewBrowser->Stop(); delete m_iViewBrowser; } if( m_CurrState == STATE_CONNECTED ) { CAN_StopHardware(); } CAN_DeselectHwInterface(); EnterCriticalSection(&m_Mutex); pVCIMap_t::iterator VItr = m_VCI.begin(); for (; VItr != m_VCI.end(); VItr++ ) { delete VItr->second->VCiIF(); delete VItr->second; } LeaveCriticalSection(&m_Mutex); DeleteCriticalSection(&m_Mutex); m_CurrState = STATE_DRIVER_LOADED; return S_OK; }