Ejemplo n.º 1
0
/**
 * \return S_OK for success, S_FALSE for failure
 *
 * Lists the hardware interface available. sSelHwInterface
 * will contain the user selected hw interface.
 */
HRESULT CDIL_CAN_i_VIEW::CAN_ListHwInterfaces(
    INTERFACE_HW_LIST&  sSelHwInterface,
    INT&            nCount)
{
    INTERFACE_HW HWIF[defNO_OF_CHANNELS];

    EnterCriticalSection(&m_Mutex);

    pVCIMap_t::iterator Itr = m_VCI.begin();
    nCount = m_VCI.size();

    for ( int i=0; Itr != m_VCI.end(); Itr++, i++ )
    {
        std::ostringstream Tmp, Tmp1;
        HWIF[i].m_dwIdInterface = Itr->second->Id();
        HWIF[i].m_bytNetworkID = (unsigned char)Itr->second->CAN();
        HWIF[i].m_dwVendor = Itr->second->TypeId();
        HWIF[i].m_acDeviceName = Itr->second->Firmware();
        Tmp << Itr->second->Name() << " CAN " << std::dec << Itr->second->CAN();
        HWIF[i].m_acDescription = Tmp.str();
        Tmp1 << " CAN " << std::dec << Itr->second->CAN();
        HWIF[i].m_acNameInterface = Tmp1.str();
    }
    LeaveCriticalSection(&m_Mutex);

    if( ListHardwareInterfaces( m_hOwnerWnd, 0, HWIF,
                                m_SelectedVCI, nCount ) != 0 )
    {
        return HW_INTERFACE_NO_SEL;
    }

    EnterCriticalSection(&m_Mutex);
    m_nChannels = nCount;
    for ( int i=0; i < nCount; i++ )
    {
        pVCI_t VCI = m_VCI[m_SelectedVCI[i]];
        m_Channel[i] = VCI;
        VCI->VCiIF()->Id( i+1 ); // Channels Id's start at 1
        sSelHwInterface[i] = HWIF[VCI->Id()];
    }
    LeaveCriticalSection(&m_Mutex);

    m_CurrState = STATE_HW_INTERFACE_LISTED;
    return S_OK;
}
Ejemplo n.º 2
0
/**
 * @brief
 *  Create a list will all IXXAT CAN controllers.
 *
 * @todo
 *  At this time only the settings for the first CAN will be set
 *  and no dialog will shown.
 * *
 *
 * @param [in,out]  sSelHwInterface
 *  The selected hardware interface.
 * @param [in,out]  nCount
 *  Number of.
 *
 * @return
 *      S_OK - list successful filled
 *      E_POINTER - no access to the VCI drivers
 *      NO_HW_INTERFACE - no CAN interface found
 */
HRESULT CDIL_CAN_IXXAT_VCI::CAN_ListHwInterfaces(INTERFACE_HW_LIST& sSelHwInterface, INT& nCount, PSCONTROLLER_DETAILS InitData)
{
#ifdef _IXXAT_DEBUG
    LogMessage(TRUE, "------> CDIL_CAN_IXXAT_VCI::CAN_ListHwInterfaces\n");
#endif
    HRESULT hResult = E_POINTER;

    UINT unDefaultChannelCnt = nCount;
    // default: no IXXAT interface available
    nCount = 0;
    m_iNumberOfCANChannelsTotal = 0;

    if (m_bDriverAccessLoaded)
    {
        HANDLE        hEnum;   // enumerator handle
        VCIDEVICEINFO sInfo;   // device info

        // open the device list
        hResult = DYNCALL(vciEnumDeviceOpen)(&hEnum);
        if (VCI_OK == hResult)
        {
            while (DYNCALL(vciEnumDeviceNext)(hEnum, &sInfo) == VCI_OK)
            {
                // increment the counter and add the device info to our list
                m_iNumberOfCANChannelsTotal += VciDeviceInfoAddToArray(nCount, &sInfo, m_sSelHwInterface);
            }
        }
        int nHwCount = m_iNumberOfCANChannelsTotal;
        //TODO: currently only 1 interface selected
        if (m_iNumberOfCANChannelsTotal > 0)
        {
            INT64 qiVCIDeviceID = 0;
            int iCANControllerNumber = 0;
            CClientList* pClientList = nullptr;

            //if ( m_iNumberOfCANChannelsTotal == 1 ) /* Only single channel available */
            //{
            //    sSelHwInterface[0] = m_sSelHwInterface[0];

            //    /* Rearrange hardware parameters */
            //    m_arrTmpIxxatCanChannels[0].GetHardwareParams(&qiVCIDeviceID,
            //            &iCANControllerNumber, (void**)&pClientList);
            //    m_arrIxxatCanChannels[0].SetHardwareParams(qiVCIDeviceID, iCANControllerNumber,
            //            pClientList);
            //}
            //else    /* Multiple channels available */
            {
                /* If the default channel count parameter is set, prevent displaying the hardware selection dialog */
                if ( unDefaultChannelCnt && nHwCount >= unDefaultChannelCnt )
                {
                    for (UINT i = 0; i < unDefaultChannelCnt; i++)
                    {
                        m_anSelectedItems[i] = i;
                    }
                    nHwCount  = unDefaultChannelCnt;
                }
                else if ( ListHardwareInterfaces(m_hOwnerWndHandle, m_sSelHwInterface, m_anSelectedItems, nHwCount,InitData) != 0 )
                {
                    /* return if user cancels hardware selection */
                    return HW_INTERFACE_NO_SEL;
                }

                for ( int nCount = 0; nCount < nHwCount; nCount++ )
                {
                    /* Order the hardware information according to user selection */
                    sSelHwInterface[nCount] = m_sSelHwInterface[m_anSelectedItems[nCount]];

                    /* Rearrange hardware parameters */
                    m_arrTmpIxxatCanChannels[m_anSelectedItems[nCount]].GetHardwareParams(&qiVCIDeviceID,
                            &iCANControllerNumber, (void**)&pClientList);
                    m_arrIxxatCanChannels[nCount].SetHardwareParams(qiVCIDeviceID, iCANControllerNumber,
                            pClientList);
                }
                m_iNumberOfCANChannelsTotal = nHwCount;
            }
            nCount = m_iNumberOfCANChannelsTotal;
        }

        if (m_iNumberOfCANChannelsTotal == 0)
        {
            hResult = NO_HW_INTERFACE;
            LogMessage(FALSE, "No valid IXXAT CAN interface found.");
        }

        m_byCurrHardwareState = STATE_HW_INTERFACE_LISTED;
    }
    else
    {
        // the return value is already set to E_POINTER
        LogMessage(FALSE, "IXXAT VCI access not loaded or valid.");
    }

    return hResult;
}
Ejemplo n.º 3
0
/**
* \brief         This function will get the hardware selection from the user
*                and will create essential networks.
* \param         unDefaultChannelCnt
* \return        returns defERR_OK (always)
* \authors       Arunkumar Karri
* \date          07.10.2011 Created
*/
static int nCreateMultipleHardwareNetwork(UINT unDefaultChannelCnt = 0)
{
    int nHwCount = sg_ucNoOfHardware;
    int nChannels = 0;
    // Get Hardware Network Map
    for (unsigned int nCount = 0; nCount < g_xlDrvConfig.channelCount; nCount++)
    {
        // we take all hardware we found and
        // check that we have only CAN cabs/piggy's
        // at the moment there is no VN8910 XLAPI support!
        if ( /*(g_xlDrvConfig.channel[nCount].channelBusCapabilities & XL_BUS_ACTIVE_CAP_CAN)
              && */(g_xlDrvConfig.channel[nCount].hwType != XL_HWTYPE_VN8900) )
        {
            if ( /*(g_xlDrvConfig.channel[nCount].hwType == XL_HWTYPE_CANCASEXL) &&*/
                !(g_xlDrvConfig.channel[nCount].channelBusCapabilities & XL_BUS_ACTIVE_CAP_LIN) )
            {
                continue;
            }
            sg_HardwareIntr[nChannels].m_dwIdInterface = nCount;
            sg_HardwareIntr[nChannels].m_dwVendor = g_xlDrvConfig.channel[nCount].serialNumber;
            /*sprintf(acTempStr, _("SN: %d, Port ID: %d"), sg_HardwareIntr[nChannels].m_dwVendor,
                                                                    sg_HardwareIntr[nChannels].m_dwIdInterface);*/
            sg_HardwareIntr[nChannels].m_acDescription = g_xlDrvConfig.channel[nCount].name;
            nChannels++;
        }
    }
    nHwCount = nChannels;   //Reassign hardware count according to final list of channels supported.

    /* If the default channel count parameter is set, prevent displaying the hardware selection dialog */
    if ( unDefaultChannelCnt && nChannels >= unDefaultChannelCnt )
    {
        for (UINT i = 0; i < unDefaultChannelCnt; i++)
        {
            sg_anSelectedItems[i] = i;
        }
        nHwCount = unDefaultChannelCnt;
    }
    else if ( ListHardwareInterfaces(sg_hOwnerWnd, DRIVER_CAN_VECTOR_XL, sg_HardwareIntr, sg_anSelectedItems, nHwCount) != 0 )
    {
        return HW_INTERFACE_NO_SEL;
    }
    sg_ucNoOfHardware = (UCHAR)nHwCount;
    sg_nNoOfChannels = (UINT)nHwCount;
    g_xlChannelMask = 0;
    //Reorder hardware interface as per the user selection
    for (int nCount = 0; nCount < sg_ucNoOfHardware; nCount++)
    {
        sg_aodChannels[nCount].m_pXLChannelInfo  = &g_xlDrvConfig.channel[sg_anSelectedItems[nCount]];
        g_xlChannelMask |= sg_aodChannels[nCount].m_pXLChannelInfo->channelMask;

        sg_HardwareIntr[nCount].m_dwIdInterface = nCount;
        sg_HardwareIntr[nCount].m_dwVendor = g_xlDrvConfig.channel[sg_anSelectedItems[nCount]].serialNumber;
        /*_stprintf(acTempStr, _("SN: %d, Port ID: %d"), sg_HardwareIntr[nChannels].m_dwVendor,
                                                                sg_HardwareIntr[nChannels].m_dwIdInterface);*/
        sg_HardwareIntr[nCount].m_acDescription = g_xlDrvConfig.channel[sg_anSelectedItems[nCount]].name;


    }
    g_xlPermissionMask = g_xlChannelMask;

    return defERR_OK;
}
Ejemplo n.º 4
0
/**
* \brief         This function will get the hardware selection from the user
*                and will create essential networks.
* \param         unDefaultChannelCnt
* \return        returns defERR_OK (always)
* \authors       [email protected]
* \date          05.29.2015 Created
*/
static int nCreateMultipleHardwareNetwork(UINT unDefaultChannelCnt = 0)
{
    int nHwCount = sg_ucNoOfHardware;
    DWORD dwFirmWare[2];
    char chBuffer[512] = "";
    std::string name;
    int i = 0;
    // Get Hardware Network Map
    for (int nCount = 0; nCount < nHwCount; nCount++)
    {
        canGetChannelData(nCount, canCHANNELDATA_CHANNEL_NAME,
                          chBuffer, sizeof(chBuffer));
        name = chBuffer;

        if(name.find(" LIN ",0)!=std::string::npos)
        {
            sg_HardwareIntr[nCount].m_acDescription = chBuffer;

            sg_HardwareIntr[nCount].m_dwIdInterface = i;

            canGetChannelData(nCount, canCHANNELDATA_CARD_SERIAL_NO,
                              chBuffer, sizeof(chBuffer));
            sscanf_s( chBuffer, "%ld", &sg_HardwareIntr[nCount].m_dwVendor );

            //Get Firmware info
            canGetChannelData(nCount, canCHANNELDATA_CARD_FIRMWARE_REV, dwFirmWare, sizeof(dwFirmWare));

            sprintf_s(chBuffer, sizeof(chBuffer), "0x%08lx 0x%08lx", dwFirmWare[0], dwFirmWare[1]);
            sg_HardwareIntr[nCount].m_acDeviceName = chBuffer;
            //sprintf(sg_HardwareIntr[nCount].m_acDeviceName,"0x%08lx 0x%08lx", dwFirmWare[0], dwFirmWare[1]);

            canGetChannelData(nCount, canCHANNELDATA_CHANNEL_FLAGS, chBuffer, sizeof(chBuffer));
            i++;
        }
    }
    nHwCount = i;

    /* If the default channel count parameter is set, prevent displaying the hardware selection dialog */
    if ( unDefaultChannelCnt && nHwCount >= unDefaultChannelCnt )
    {
        for (UINT i = 0; i < unDefaultChannelCnt; i++)
        {
            sg_anSelectedItems[i] = i;
        }
        nHwCount = unDefaultChannelCnt;
    }
    else if ( ListHardwareInterfaces(sg_hOwnerWnd, DRIVER_LIN_KVASER, sg_HardwareIntr, sg_anSelectedItems, nHwCount) != 0 )
    {
        return HW_INTERFACE_NO_SEL;
    }
    sg_ucNoOfHardware = (UCHAR)nHwCount;
    sg_nNoOfChannels = (UINT)nHwCount;

    //Reorder hardware interface as per the user selection
    for (int nCount = 0; nCount < sg_ucNoOfHardware; nCount++)
    {
        sg_aodChannels[nCount].m_nChannel = sg_HardwareIntr[sg_anSelectedItems[nCount]].m_dwIdInterface;
        sprintf(sg_aodChannels[nCount].m_strName , _("Kvaser - %s, Serial Number- %ld, Firmware- %s"),
                sg_HardwareIntr[sg_anSelectedItems[nCount]].m_acDescription.c_str(),
                sg_HardwareIntr[sg_anSelectedItems[nCount]].m_dwVendor,
                sg_HardwareIntr[sg_anSelectedItems[nCount]].m_acDeviceName.c_str());
    }

    return defERR_OK;
}