# Detecting Smart Module

For all operations related to the smart module, detecting the module is the first step. You can know the number and information of the smart module after successful detection. Before detecting the smart module, you must detect the receiving card successfully.

# The following steps are required for detecting the smart module and obtaining its information

Step 1. Detect the video controller.
Step 2. Detect the receiving card.
Step 3. Detect the smart module.
Step 4. Get the information of the smart module.

Below is an example of obtaining information of all smart modules of the first video controller:

    // detect device info
    CLTSearchAllDevice();

    // get device counts
    int deviceCount = CLTGetDeviceCounts();
    if (deviceCount <= 0) {
        return;
    }

    int scIndex = 0;                // device index
    int portIndex = 0;              // port index
    int rcvIndex = 0;               // receiving card index

    // get network port count
    int portCount = 0;
    EnPrcClass enPrcClass;
    CLTGetDeviceClass(&enPrcClass);
    switch(enPrcClass)
    {
    case enSenderS:
        portCount = CLTProcessorSGetPortCount(scIndex);
        break;
    case enSenderZ:
        portCount = CLTProcessorZGetPortCount(scIndex);
        break;
    case enProcessorV:
        portCount = CLTProcessorVGetPortCount(scIndex);
        break;
    default:
        break;
    }
    if(portCount <= 0){
        return;
    }

    // detect receiving card information
    SQuickDetectRcvsParam param;
    param.bDetectType = riut_for_calibration;
    HRESULT hr = CLTReceiverDetectAll(scIndex, portIndex, param);
    if(FAILED(hr)){
        return;
    }
    int rcvCount = CLTReceiverGetCountEx(scIndex, -1);
    if(rcvCount <= 0){
        return;
    }

    //detect module information
    SDetectModuleStateParam param2;
    hr = CLTModuleDetectStateInfo(scIndex, -1, param2);
    if(FAILED(hr)){
        return;
    }
    int moduleCount = CLTModuleGetCount();
    if(moduleCount <= 0){
        return;
    }

    // get module monitor information
    SQuickDetectModuleMonitorParam param3;
    for (int i=0; i<portCount; i++)
    {
        rcvCount = CLTReceiverGetCountEx(scIndex, i);
        if(0 == rcvCount)
            continue;

        CLTModuleDetectMonitorInfo(scIndex, i, -1, param3);
        for (int j=0;j<rcvCount;j++)
        {
            SRcvModuleMonitorInfo* pRcvModuleInfo = CLTModuleGetMonitorInfoEx(scIndex, i, j); //get module monitor information
            if(nullptr != pRcvModuleInfo)
            {
                for(DWORD i=0; i<pRcvModuleInfo->moduleCount; i++)
                {
                    SModuleMonitorInfo* pModuleInfo = pRcvModuleInfo->pInfos+i;
                    if(pModuleInfo->bValid)
                    {
                        int jx          = pModuleInfo->jxIndex;
                        int jx_index    = pModuleInfo->inIndex;
                    }
                }
            }
        }
    }