⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sfu_test.c

📁 测试误码率的
💻 C
📖 第 1 页 / 共 2 页
字号:
		if(prog_num > 0)
		{
			//libc_printf("\nreceive %d program!\n",prog_num);
			UIPlayChannel(0);
		}
		else
		{
			//libc_printf("no prog!\n");
		}

		
	}
	else
	{
		//libc_printf("lock failed , search end!\n");
	}

	libc_printf("End Search\n");
	
	return 0;  
}

static void Skyworth_SFU_channel_serarch_init(void)
{
	FW_ClearMsgBuffer();
	UISiaeClose();

	AP_ClearPanel();
	AP_StopPlayback(TRUE);

	sys_data_set_cur_chan_mode(PROG_AUDIO_MODE);
	CHN_DeleteAll();
	sys_data_set_cur_chan_mode(PROG_VIDEO_MODE);
	CHN_DeleteAll();
	
	sys_data_set_cur_chan_mode(PROG_VIDEO_MODE);

	UIPanDisplayChannel(CC_CMD_UI_CLOSE_CH);
	UIShowLogo();

	osal_task_dispatch_off();
	stop_search == 0;
	osal_task_dispatch_on();
}

static int Skyworth_SFU_Stop_Search(unsigned int argc, unsigned char *argv[])
{
	if (argc != 1)
	{
		SciEcho("Usage: stop_search \r\n");
		return -1;
	}

	as_service_stop();

	osal_task_dispatch_off();
	stop_search = 1;
	osal_task_dispatch_off();
	
	osal_task_sleep(SFU_CHECK_LOCK_DELAY*4);
	
	SciEcho("Search end, plesae query! \r\n");

}

static int Skyworth_SFU_Return_Result(unsigned int argc, unsigned char *argv[])
{
	UINT32 	ber;

	UINT8 	lock = 0;
	UINT32 	cout = 0;
	UINT32 	Frequence;
	UINT32 	BandWidth;

	char buffer[128];
	
	if (argc != 1)
	{
		SciEcho("Usage: query_result \r\n");
		return -1;
	}

	Frequence =  skyworth_sfu_search_param.Frequence;
	BandWidth = skyworth_sfu_search_param.BandWidth;
	
	do
	{
		if(!api_nim_get_lock() || api_nim_get_lock() == 0xff)
		{
			cout ++;
		}
		else
		{
			
			lock = 1;
			break;
		}

		osal_task_sleep(SFU_CHECK_LOCK_DELAY);
		
	}while(cout < SFU_CHECK_LOCK_COUNT);

	ber = api_nim_get_BER();
	
	osal_task_dispatch_off();

	sprintf(buffer,"result: %s %d , %s %d , %s %d , %s %d\r\n", "frequence = ", Frequence, "BandWidth = ", BandWidth, "lock = ",lock,"ber = ",ber);
	SciEcho(buffer);
	
	osal_task_dispatch_on();


}

static int Skyworth_SFU_Stop(unsigned int argc, unsigned char *argv[])
{
	if (argc != 1)
	{
		SciEcho("Usage: close_dmd_autotest\r\n");
		return -1;
	}
	
	sfu_ash_task_delete();

	SciEcho("Exit SFU Test Success!\r\n");
	
	return 0;  
}


static int Do_SetTP(UINT32 central_freq, UINT32 bandwidth)
{
    BOOL pause_status_bak;
    if (central_freq < 47000 || central_freq > 890000 || (bandwidth != 6 && bandwidth != 7 && bandwidth != 8) )
    {
        SciEcho("Usage: settp <Central_Frequence_KHz> <BandWidth_MHz>\r\n");
        SciEcho("Central_Frequence_KHz : 47000 ~ 890000, BandWidth_MHz : 6/7/8\r\n");
        return -1;
    }
    
    m_freq = central_freq;
    m_bandwidth = bandwidth;
    
    pause_status_bak = m_pause_auto_get_current_status_task;
    m_pause_auto_get_current_status_task = TRUE;
    osal_delay(50); //wait for finish the output of the previous command.

    //make the frequence start point from the frequence central point.
    UIChChgAerialSignalMonitor(central_freq - bandwidth*1000/2, bandwidth);
    SciEcho("SUCCESS\r\n");
    
    m_pause_auto_get_current_status_task = pause_status_bak;
    return 0;    
}

static int SFU_Reboot(unsigned int argc, unsigned char *argv[])
{
    P_NODE p_node;
    T_NODE t_node;

    if (argc != 1)
    {
        SciEcho("Usage: reboot\r\n");
        return -1;
    }

    UIStopPlay(TRUE);
    m_pause_auto_get_current_status_task = TRUE;


    //for change the frequency of current channel as the SFU testing frequency.
    if(CHN_GetCount(CHN_C_ALL_PROG, CHN_C_CUR_MODE))
    {
        if (get_prog_at(sys_data_get_cur_channel(),&p_node) == SUCCESS)
        {
            get_tp_by_id(p_node.tp_id, &t_node);

            t_node.frq = m_freq;
            t_node.bandwidth = m_bandwidth;
			if (lookup_node(TYPE_TP_NODE, &t_node,0)!=SUCCESS) 
			{
				if ((UINT32)add_node(TYPE_TP_NODE, &t_node)==(UINT32)STORE_SPACE_FULL)
                {
					SciEcho("Err: Database is full.\r\n");
                    return -1;
				}
                if (update_data(TYPE_TP_NODE) != SUCCESS)
                {
					SciEcho("Err: Fail to add the tp.\r\n");
                    return -1;
				}
			}
            
            if (p_node.tp_id != t_node.tp_id)
            {
                p_node.tp_id = t_node.tp_id;
                if ( modify_prog(sys_data_get_cur_channel(), &p_node) != SUCCESS )
                {
    				SciEcho("Err: Fail to modify the tp of program.\r\n");
                    return -1;
    			}
                if (update_data(TYPE_PROG_NODE) != SUCCESS)
                {
					SciEcho("Err: Fail to modify the tp of program.\r\n");
                    return -1;
				}
            }
        }
    }

    sys_data_set_sfu_frequency(m_freq);
    sys_data_set_sfu_bandwidth(m_bandwidth);
    sys_data_save_bak();
    osal_delay(100);

	sfu_ash_task_delete();
    sfu_auto_get_current_status_task_delete();
    osal_interrupt_disable();
    sys_watchdog_reboot();
    return 0;    
}

static int SFU_Stop(unsigned int argc, unsigned char *argv[])
{
    if (argc != 1)
    {
        SciEcho("Usage: stop\r\n");
        return -1;
    }
    SFUTestingStop();
    return 0;    
}

static int IntPrintf(unsigned int src)
{
    UINT8 NumStack[10];
    UINT8 pos = 0;
    INT32 i;

    do{
        NumStack[pos] = src%10;
	 src = src /10;
	 pos++;        
    } while(src);

    for(i = 0; i < pos; i++)
        LIB_ASH_OC((NumStack[pos - i -1] + '0'));        
    
    return 0;    
}

//================================================
static void sfu_auto_get_current_status()
{
    unsigned int i;
    nim_rec_performance_t status;

//    static UINT32 StartCount = 0;
//    static UINT32 CurCount = 0;
//    CurCount = OS_GetTickCount();
//    if (CurCount - StartCount < m_AutoRepeatInterval_ms)
//    {
//        StartCount = CurCount;
//    }

    struct nim_device *nim_dev = dev_get_by_id(HLD_DEV_TYPE_NIM, 0);
    while (1)
    {
        if (m_exit_task)
            return;
        
        status.valid = FALSE;
        while (status.valid == FALSE)
        {
            if (m_exit_task)
                return;
            if (m_pause_auto_get_current_status_task)
                break;
            if ( nim_io_control(nim_dev, NIM_DRIVER_GET_REC_PERFORMANCE_INFO, (UINT32)&status) != SUCCESS )
            {
                SH_PRINTF("%s: fail.\n", __FUNCTION__);
                return;
            }
            if ( status.lock == 0 || status.lock == 0xff)
            {
                status.valid = FALSE;
                status.ber = 0;
                status.per = 0;
                break;
            }
        }
        if (m_pause_auto_get_current_status_task)
            continue;

        if( status.lock == 0 || status.lock == 0xff)
            SciEcho("UNLOCK ");
        else
            SciEcho("LOCK ");    
        
        IntPrintf(status.ber);
        SciEcho(" ");    
        IntPrintf(status.per);
        SciEcho("\r\n");

        if (m_AutoRepeatInterval_ms == 0)   //run 1 time.
        {
            sfu_auto_get_current_status_task_id = OSAL_INVALID_ID;
            return;
        }
        osal_task_sleep(m_AutoRepeatInterval_ms);
    }
}

static BOOL sfu_auto_get_current_status_task_start()
{
	OSAL_T_CTSK		t_ctsk;
    m_exit_task = FALSE;
    
	t_ctsk.stksz	= 0x1000;
	t_ctsk.quantum	= 10;
	t_ctsk.itskpri	= OSAL_PRI_NORMAL;
	t_ctsk.name[0]	= 'G';
	t_ctsk.name[1]	= 'C';
	t_ctsk.name[2]	= 'S';
	t_ctsk.task = (FP)sfu_auto_get_current_status;
	sfu_auto_get_current_status_task_id = osal_task_create(&t_ctsk);
	if(OSAL_INVALID_ID == sfu_auto_get_current_status_task_id)
	{
		PRINTF("Fail to create sfu_auto_get_current_status_task_id task\n");
		return FALSE;
	}

	return TRUE;
}

static void sfu_auto_get_current_status_task_delete()
{
	if(OSAL_INVALID_ID != sfu_auto_get_current_status_task_id)
	{
        m_pause_auto_get_current_status_task = TRUE;
        osal_delay(50); //wait for finish the output.

        osal_task_delete(sfu_auto_get_current_status_task_id);
        m_exit_task = TRUE;
        sfu_auto_get_current_status_task_id = OSAL_INVALID_ID;
	}
}

//================================================

static int SFU_GetCurrentStatus(unsigned int argc, unsigned char *argv[])
{
    INT32 ret;
    UINT32 AutoRepeatInterval_ms = 0;

    if (argc > 2)
    {
        SciEcho("Usage: getcs [AutoRepeatInterval_ms]\r\n");
        return -1;
    }
    
    if (argc == 2)
        AutoRepeatInterval_ms = ATOI(argv[1]);

    sfu_auto_get_current_status_task_delete();  //clean up the previous command first.
    
    m_AutoRepeatInterval_ms = AutoRepeatInterval_ms;
    m_pause_auto_get_current_status_task = FALSE;
    sfu_auto_get_current_status_task_start();
}


BOOL Skyworth_SFUTestInit()
{
	ash_cm_register(Skyworth_SFUTestCommand);  
	enable_serial_port(TRUE);

	if(skyworth_sfu_ash_task_init())		
    		SciEcho("SFU Testing init success.\r\n");
	else
		SciEcho("SFU Testing init failed.\r\n");
		
    	return TRUE;
}



#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -