コード例 #1
0
ファイル: DIL_CAN.cpp プロジェクト: ArunMaiya/busmaster
CDIL_CAN::CDIL_CAN()
{
    m_hDll = NULL;
    m_hOldDll = NULL;
    m_dwDriverID = DAL_NONE;
    pfGetIDILCAN_Controller = NULL;
    m_pBaseDILCAN_Controller = NULL;
    m_pOldBaseDILCAN_Controller = NULL;
    vSelectInterface_Dummy();
}
コード例 #2
0
ファイル: DIL_LIN.cpp プロジェクト: Jason45degree/busmaster
CDIL_LIN::CDIL_LIN()
{
    m_hDll = nullptr;
    m_hOldDll = nullptr;
    m_dwDriverID = DAL_NONE;
    pfGetIDILLIN_Controller = nullptr;
    m_pBaseDILLIN_Controller = nullptr;
    m_pOldBaseDILLIN_Controller = nullptr;
    vSelectInterface_Dummy();
}
コード例 #3
0
ファイル: DIL_CAN.cpp プロジェクト: ArunMaiya/busmaster
/**
 * \brief     Closure operation
 * \req       RSI_14_007 - DILC_PerformClosureOperations
 * \req       RS_23_09 - Carry out closure operations
 *
 * Call for all uninitialisation operations
 */
HRESULT CDIL_CAN::DILC_PerformClosureOperations(void)
{
    HRESULT hResult =  S_FALSE;
    if ( m_pBaseDILCAN_Controller )
    {
        m_pBaseDILCAN_Controller->CAN_PerformClosureOperations();
        m_pBaseDILCAN_Controller->CAN_UnloadDriverLibrary();
    }

    vSelectInterface_Dummy();
    m_dwDriverID = DAL_NONE;
    return hResult;
}
コード例 #4
0
ファイル: DIL_CAN.cpp プロジェクト: ArunMaiya/busmaster
/**
 * \brief     Select driver from DIL list
 * \req       RSI_14_002 - DILC_SelectDriver
 * \req       RS_23_02 - Selecting a driver from the DIL list
 *
 * This function selects a driver abstraction layer (DAL). If support for the
 * intended one isn't allowed with the present license, this returns NO_LICENSE.
 */
HRESULT CDIL_CAN::DILC_SelectDriver(DWORD dwDriverID, HWND hWndOwner,
                                    Base_WrapperErrorLogger* pILog)
{
    USES_CONVERSION;

    HRESULT hResult = S_FALSE;

    if (DILC_GetSelectedDriver() == dwDriverID)
    {
        hResult = DAL_ALREADY_SELECTED;
    }
    else if (pILog == NULL)
    {
        hResult = ERRLGR_INVALID;
    }
    else
    {
        if (hWndOwner == NULL)
        {
            /* Log a warning message informing about the invalidity of the
            owner window handle. */
        }

        //Save the currently selected DIL library handle
        if ( m_hDll )
        {
            //FreeLibrary(m_hDll);
            m_hOldDll = m_hDll;
            m_pOldBaseDILCAN_Controller = m_pBaseDILCAN_Controller;
            m_dwOldDriverID = m_dwDriverID;
            m_hDll = NULL;
        }

        switch(dwDriverID)
        {
            case DRIVER_CAN_PEAK_USB:
                m_hDll = LoadLibrary("CAN_PEAK_USB.dll");
                break;

            case DRIVER_CAN_ICS_NEOVI:
            case DRIVER_CAN_ETAS_ES581:
                m_hDll = LoadLibrary("CAN_ICS_neoVI.dll");
                break;

            case DRIVER_CAN_ETAS_BOA:
                m_hDll = LoadLibrary("CAN_ETAS_BOA.dll");
                break;

            case DRIVER_CAN_VECTOR_XL:
                m_hDll = LoadLibrary("CAN_Vector_XL.dll");
                break;
            case DRIVER_CAN_IXXAT:
                m_hDll = LoadLibrary("CAN_IXXAT_VCI.dll");
                break;
            case DRIVER_CAN_KVASER_CAN:
                m_hDll = LoadLibrary("CAN_Kvaser_CAN.dll");
                break;

            case DRIVER_CAN_STUB:
                m_hDll = LoadLibrary("CAN_STUB.dll");
                break;

            case DRIVER_CAN_MHS:
                m_hDll = LoadLibrary("CAN_MHS.dll");
                break;

            case DRIVER_CAN_VSCOM:
                m_hDll = LoadLibrary("CAN_VSCOM.dll");
                break;
            case DAL_NONE:
                DILC_PerformClosureOperations();
                vSelectInterface_Dummy();
                m_dwDriverID = DAL_NONE;
                return hResult;

            default:
                hResult = DAL_INVALID;
                m_dwDriverID = DAL_NONE;
                return hResult;
        }

        if (m_hDll == NULL)
        {
            hResult = ERR_LOAD_DRIVER;
            pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library failed..."));
        }
        else
        {
            // First select the dummy interface
            //DILC_SelectDriver((DWORD)DAL_NONE, hWndOwner, pILog);

            pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library successful..."));
            pfGetIDILCAN_Controller = (GETIDIL_CAN_CONTROLLER)GetProcAddress(m_hDll, "GetIDIL_CAN_Controller");
            pfGetIDILCAN_Controller((void**)&m_pBaseDILCAN_Controller);
            if ( m_pBaseDILCAN_Controller )
            {
                // set the application parameters.
                m_pBaseDILCAN_Controller->CAN_SetAppParams(hWndOwner, pILog);
                hResult = m_pBaseDILCAN_Controller->CAN_LoadDriverLibrary();
                switch (hResult)
                {
                    case S_OK:
                    case DLL_ALREADY_LOADED:
                        m_dwDriverID = dwDriverID;
                        hResult = S_OK;
                        break;

                    default:
                        hResult = ERR_LOAD_DRIVER;
                        pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library failed..."));
                        /* New Code */
                        /* Get rid of current DIL library */
                        if ( m_pBaseDILCAN_Controller )
                        {
                            m_pBaseDILCAN_Controller->CAN_PerformClosureOperations();
                            m_pBaseDILCAN_Controller->CAN_UnloadDriverLibrary();
                        }
                        FreeLibrary(m_hDll);
                        if ( m_hOldDll )
                        {
                            m_hDll = m_hOldDll;
                            m_pBaseDILCAN_Controller = m_pOldBaseDILCAN_Controller;
                            m_dwDriverID =  m_dwOldDriverID;
                        }
                        /* New Code */
                        break;
                }
            }
        }
    }

    return hResult;
}
コード例 #5
0
ファイル: DIL_CAN.cpp プロジェクト: ArunMaiya/busmaster
/**
 * The router is realised as a set of function pointers
 * Initialisation with dummy functions
 */
BOOL CDIL_CAN::InitInstance()
{
    vSelectInterface_Dummy();

    return TRUE;
}
コード例 #6
0
/**
 * \brief     Select driver from DIL list
 * \req       RSI_14_002 - DILL_SelectDriver
 * \req       RS_23_02 - Selecting a driver from the DIL list
 *
 * This function selects a driver abstraction layer (DAL). If support for the
 * intended one isn't allowed with the present license, this returns NO_LICENSE.
 */
HRESULT CDIL_LIN::DILL_SelectDriver(DWORD dwDriverID, HWND hWndOwner,
                                    Base_WrapperErrorLogger* pILog)
{
    USES_CONVERSION;

    HRESULT hResult = S_FALSE;

    if (DILL_GetSelectedDriver() == dwDriverID)
    {
        hResult = DAL_ALREADY_SELECTED;
    }
    else if (pILog == NULL)
    {
        hResult = ERRLGR_INVALID;
    }
    else
    {
        if (hWndOwner == NULL)
        {
            /* Log a warning message informing about the invalidity of the
            owner window handle. */
        }

        //Save the currently selected DIL library handle
        if ( m_hDll )
        {
            FreeLibrary(m_hDll);
            m_pBaseDILLIN_Controller = NULL;
            //m_hOldDll = m_hDll;
            //m_pOldBaseDILLIN_Controller = m_pBaseDILLIN_Controller;
            //m_dwOldDriverID = m_dwDriverID;
            m_hDll = NULL;
        }

        switch(dwDriverID)
        {

            case DRIVER_LIN_ISOLAR_EVE_VLIN:
                m_hDll = LoadLibrary("LIN_ISOLAR_EVE_VLIN.dll");
                break;

                /* case DRIVER_LIN_DEACTIVATE_VLIN:
                 if (m_hDll == NULL)
                 {
                     hResult = DAL_INVALID;
                     FreeLibrary(m_hDll);
                     m_dwDriverID = DAL_NONE;
                 }
                 else
                 {
                     hResult = ERR_LOAD_DRIVER;
                     pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("LIN not Active..."));
                 }
                     return hResult;*/
            case DRIVER_LIN_VECTOR_XL:
                m_hDll = LoadLibrary("LIN_Vector_XL.dll");
                break;
            default:
                vSelectInterface_Dummy();
                m_dwDriverID = DAL_NONE;
                return hResult;
        }

        if (m_hDll == NULL)
        {
            hResult = ERR_LOAD_DRIVER;
            pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library failed..."));
        }
        else
        {
            // First select the dummy interface
            //DILL_SelectDriver((DWORD)DAL_NONE, hWndOwner, pILog);

            pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library successful..."));
            pfGetIDILLIN_Controller = (GETIDIL_LIN_CONTROLLER)GetProcAddress(m_hDll, "GetIDIL_LIN_Controller");
            pfGetIDILLIN_Controller((void**)&m_pBaseDILLIN_Controller);
            if ( m_pBaseDILLIN_Controller )
            {
                // set the application parameters.
                m_pBaseDILLIN_Controller->LIN_SetAppParams(hWndOwner, pILog);
                hResult = m_pBaseDILLIN_Controller->LIN_LoadDriverLibrary();
                switch (hResult)
                {
                    case S_OK:
                    case DLL_ALREADY_LOADED:
                        m_dwDriverID = dwDriverID;
                        hResult = S_OK;
                        break;

                    default:
                        hResult = ERR_LOAD_DRIVER;
                        pILog->vLogAMessage(A2T(__FILE__), __LINE__, _("Load library failed..."));
                        /* New Code */
                        /* Get rid of current DIL library */
                        if ( m_pBaseDILLIN_Controller )
                        {
                            m_pBaseDILLIN_Controller->LIN_PerformClosureOperations();
                            m_pBaseDILLIN_Controller->LIN_UnloadDriverLibrary();
                        }
                        FreeLibrary(m_hDll);
                        m_pBaseDILLIN_Controller = NULL;
                        /*  if ( m_hOldDll )
                          {
                              m_hDll = m_hOldDll;
                              m_pBaseDILLIN_Controller = m_pOldBaseDILLIN_Controller;
                              m_dwDriverID =  m_dwOldDriverID;
                          }*/
                        /* New Code */
                        break;
                }
            }
        }
    }

    return hResult;
}