/** * \brief Function to set the channel baud rate configured by user * \param void * \return linOK if succeeded, else respective error code * \authors [email protected] * \date 05.29.2015 Created */ static int nSetBaudRate() { LinStatus xlStatus; /* Set baud rate to all available hardware */ for ( UINT unIndex = 0; unIndex < sg_nNoOfChannels; unIndex++) { // Get Current channel reference CChannel& odChannel = sg_aodChannels[ unIndex ]; if( odChannel.m_hnd >= 0 ) { unsigned int rate = odChannel.m_unBaudrate; xlStatus = linSetBitrate(odChannel.m_hnd,rate); } else { vRetrieveAndLog(xlStatus, __FILE__, __LINE__); // Invalid Hardware Handle. Could be a simulation network. // Wrong call } // Check for failure if( xlStatus != linOK ) { // break the loop unIndex = sg_nNoOfChannels; } } return xlStatus; }
/** * \brief This function will remove the existing client ID * \param[in] dwClientId, client ID to be removed * \return Returns TRUE if client ID removal is success, else FALSE * \authors Arunkumar Karri * \date 07.10.2011 Created */ static BOOL bRemoveClient(DWORD dwClientId) { BOOL bResult = FALSE; if (sg_unClientCnt > 0) { UINT unClientIndex = (UINT)-1; if (bGetClientObj(dwClientId, unClientIndex)) { /* clear the client first */ if (sg_asClientToBufMap[unClientIndex].hClientHandle != 0) { HRESULT hResult = S_OK;//(*pfCAN_RemoveClient)(sg_asClientToBufMap[unClientIndex].hClientHandle); if (hResult == S_OK) { sg_asClientToBufMap[unClientIndex].dwClientID = 0; sg_asClientToBufMap[unClientIndex].hClientHandle = 0; memset (sg_asClientToBufMap[unClientIndex].pacClientName, 0, sizeof (char) * MAX_PATH); for (int i = 0; i < MAX_BUFF_ALLOWED; i++) { sg_asClientToBufMap[unClientIndex].pClientBuf[i] = nullptr; } sg_asClientToBufMap[unClientIndex].unBufCount = 0; bResult = TRUE; } else { vRetrieveAndLog(hResult, __FILE__, __LINE__); } } else { sg_asClientToBufMap[unClientIndex].dwClientID = 0; memset (sg_asClientToBufMap[unClientIndex].pacClientName, 0, sizeof (char) * MAX_PATH); for (int i = 0; i < MAX_BUFF_ALLOWED; i++) { sg_asClientToBufMap[unClientIndex].pClientBuf[i] = nullptr; } sg_asClientToBufMap[unClientIndex].unBufCount = 0; bResult = TRUE; } if (bResult == TRUE) { if ((unClientIndex + 1) < sg_unClientCnt) { sg_asClientToBufMap[unClientIndex] = sg_asClientToBufMap[sg_unClientCnt - 1]; } sg_unClientCnt--; } } } return bResult; }
/** * \brief StopHardware * \param void * \return S_OK for success, S_FALSE for failure * \authors [email protected] * \date 05.29.2015 Created */ HRESULT CDIL_LIN_Kvaser::StopHardware(void) { // VALIDATE_VALUE_RETURN_VAL(sg_bCurrState, STATE_CONNECTED, ERR_IMPROPER_STATE); HRESULT hResult = S_OK; //Terminate the read thread sg_sParmRThread.bTerminateThread(); hResult = nConnect(FALSE); if (hResult == defERR_OK) { hResult = S_OK; sg_bCurrState = STATE_HW_INTERFACE_SELECTED; } else { //log the error for open port failure vRetrieveAndLog(hResult, __FILE__, __LINE__); hResult = ERR_LOAD_HW_INTERFACE; } return hResult; }