📄 sfu_test.c
字号:
/****************************************************************************
*
* ALi (Shanghai) Corporation, All Rights Reserved. 2002 Copyright (C)
*
* File: lib_ashcmd.c
*
* Description: This file contains all functions definition SFU test
* command functions.
* History:
* Date Author Version Comment
* ======= ======== ======== =========
* 1 2008.03.10 Berferd 0.1 Creat
****************************************************************************/
#include <sys_config.h>
#include <basic_types.h>
#include <api/libc/string.h>
#include <api/libnim/Lib_nim.h>
#include <api/libpub27/lib_pub27.h>
#include "ap_com.h"
#include "sfu_ash.h"
#include <framework/fw_control.h>
#ifdef _DEBUG_VERSION_
#define DEBUG
#define SH_PRINTF soc_printf
#else
#define SH_PRINTF(...)
#endif
//#ifdef SUPPORT_SFU_TESTING
#if (defined(SUPPORT_SFU_TESTING) || defined(SKYWORTH_SFU_TEST))
void SetSFUTestingParameter(UINT32 freq, UINT8 bandwidth);
BOOL SFUTestingIsTurnOn();
BOOL BootupCheckingForSFUTesting();
BOOL SFUTestInit();
void SFUTestingStop();
void SciEcho(char *str);
void ShowSFUTestingHelp(char *str);
static int SFU_SetTP(unsigned int argc, unsigned char *argv[]);
static int Do_SetTP(UINT32 central_freq, UINT32 bandwidth);
static int SFU_Reboot(unsigned int argc, unsigned char *argv[]);
static int SFU_Stop(unsigned int argc, unsigned char *argv[]);
static int IntPrintf(unsigned int src);
static void sfu_auto_get_current_status();
static BOOL sfu_auto_get_current_status_task_start();
static void sfu_auto_get_current_status_task_delete();
static int SFU_GetCurrentStatus(unsigned int argc, unsigned char *argv[]);
BOOL Skyworth_SFUTestInit();
static int Skyworth_SFU_ComConnect(unsigned int argc, unsigned char *argv[]);
static int Skyworth_SFU_EnterTest(unsigned int argc, unsigned char *argv[]);
static int Skyworth_SFU_Lock(unsigned int argc, unsigned char *argv[]);
static int Skyworth_SFU_Stop_Search(unsigned int argc, unsigned char *argv[]);
static int Skyworth_SFU_Return_Result(unsigned int argc, unsigned char *argv[]);
static int Skyworth_SFU_Stop(unsigned int argc, unsigned char *argv[]);
static void Skyworth_SFU_channel_serarch_init(void);
// Command <-> function map list.
struct ash_cmd SFUTestCommand[] =
{
{"settp", SFU_SetTP},
{"getcs", SFU_GetCurrentStatus},
{"reboot", SFU_Reboot},
{"stop", SFU_Stop},
// {"getlock", SFU_GetLock},
// {"getber", SFU_GetBER},
// {"getper", SFU_GetPER},
{NULL, NULL}
};
struct ash_cmd Skyworth_SFUTestCommand[] =
{
{"COM_CONNECT_TOPSET", Skyworth_SFU_ComConnect},
{"dmd_autotest_on", Skyworth_SFU_EnterTest},
{"search", Skyworth_SFU_Lock},
//{"stop_search", Skyworth_SFU_Stop_Search},
{"query_result",Skyworth_SFU_Return_Result},
{"close_dmd_autotest", Skyworth_SFU_Stop},
{NULL, NULL}
};
struct ash_search_param skyworth_sfu_search_param = {0,0};
static UINT32 stop_search = 0;
static UINT32 m_freq = 0;
static UINT32 m_bandwidth = 0;
static BOOL m_TurnOnSFUTesting = FALSE;
static UINT32 m_AutoRepeatInterval_ms = 0;
static ID sfu_auto_get_current_status_task_id = OSAL_INVALID_ID;
static BOOL m_pause_auto_get_current_status_task = FALSE;
static BOOL m_exit_task = FALSE;
pressed_key_filter_proc m_pressed_key_filter_proc_bak = NULL;
#define SFU_CHECK_LOCK_COUNT (10)
#define SFU_CHECK_LOCK_DELAY (50)
static BOOL SkipAllPressedKeyProc(ControlMsg_t *pMsg)
{
return TRUE;
}
void SetSFUTestingParameter(UINT32 freq, UINT8 bandwidth)
{
m_freq = freq;
m_bandwidth = bandwidth;
}
BOOL SFUTestingIsTurnOn()
{
return m_TurnOnSFUTesting;
}
BOOL BootupCheckingForSFUTesting() //CHN_Init() must be called first before call BootupCheckingForSFUTesting().
{
unsigned char cmd_buffer[30];
unsigned char *argv[2];
SetSFUTestingParameter(sys_data_get_sfu_frequency(), sys_data_get_sfu_bandwidth());
if ( m_freq == 0 || m_bandwidth == 0 )
return FALSE;
//always clean up the flag of SFU testing.
UIStopPlay(TRUE);
sys_data_set_sfu_frequency(0);
sys_data_set_sfu_bandwidth(0);
sys_data_save_bak();
osal_delay(40);
return SFUTestInit();
// Do_SetTP(m_freq, m_bandwidth);
}
BOOL SFUTestInit()
{
P_NODE p_node;
T_NODE t_node;
enable_serial_port(TRUE);
if(CHN_GetCount(CHN_C_ALL_PROG, CHN_C_CUR_MODE) == 0)
{
SciEcho("No program.\r\n");
enable_serial_port(FALSE);
return FALSE;
}
//init with current channel.
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);
m_freq = t_node.frq;
m_bandwidth = t_node.bandwidth;
}
}
m_pressed_key_filter_proc_bak = FW_GetPressedKeyFilterProc();
FW_AttachPressedKeyFilterProc(SkipAllPressedKeyProc);
ash_cm_register(SFUTestCommand);
sfu_ash_task_init();
m_TurnOnSFUTesting = TRUE;
SciEcho("SFU testing start.\r\n");
return TRUE;
}
void SFUTestingStop()
{
P_NODE p_node;
T_NODE t_node;
sfu_ash_task_delete();
sfu_auto_get_current_status_task_delete();
m_freq = 0;
m_bandwidth = 0;
//for restore.
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);
UIChChgAerialSignalMonitor(t_node.frq - t_node.bandwidth*1000/2, t_node.bandwidth);
}
}
FW_AttachPressedKeyFilterProc(m_pressed_key_filter_proc_bak);
m_TurnOnSFUTesting = FALSE;
SciEcho("SFU testing stop.\r\n");
}
void SciEcho(char *str)
{
UINT32 len = ComStrLen(str);
UINT32 i;
for (i=0; i<len; ++i)
LIB_ASH_OC(str[i]);
}
void ShowSFUTestingHelp(char *str)
{
UINT32 i;
SciEcho("SFU testing commands:\r\n");
for (i=0; SFUTestCommand[i].command != NULL; ++i)
{
SciEcho(SFUTestCommand[i].command);
SciEcho("\r\n");
}
}
static int SFU_SetTP(unsigned int argc, unsigned char *argv[])
{
UINT32 freq; //in KHz.
UINT32 bandwidth;//must be 6/7/8 MHz.
UINT16 channel;
T_NODE t_node;
P_NODE p_node;
if (argc != 3)
{
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;
}
freq = ATOI(argv[1]);
bandwidth = ATOI(argv[2]);
Do_SetTP(freq, bandwidth);
return 0;
}
static int Skyworth_SFU_ComConnect(unsigned int argc, unsigned char *argv[])
{
if (argc != 1)
{
SciEcho("Usage: COM_CONNECT_TOPSET\r\n");
return -1;
}
SciEcho("CONNECTED_TOPSET\r\n");
return 0;
}
static int Skyworth_SFU_EnterTest(unsigned int argc, unsigned char *argv[])
{
if (argc != 1)
{
SciEcho("Usage: dmd_autotest_on\r\n");
return -1;
}
SciEcho("dmd_autotest_on OK!\r\n");
return 0;
}
static int Skyworth_SFU_Lock(unsigned int argc, unsigned char *argv[])
{
UINT32 Frequence;
UINT32 BandWidth;
UINT8 lock = 0;
UINT32 cout = 0;
UINT16 prog_num = 0;
ControlMsg_t pMsg;
UINT32 size;
if (argc != 3)
{
SciEcho("Usage: search <Frequence> <BandWidth> \r\n");
SciEcho("Frequence: 47000 ~ 890000, BandWidth : 6/7/8 \r\n");
return -1;
}
if(ATOI(argv[1]) < 47000 ||ATOI(argv[1]) > 890000)
{
SciEcho("Usage: Frequence 47000 ~ 890000 \r\n");
return -1;
}
if(ATOI(argv[2]) != 6 && ATOI(argv[2]) != 7 && ATOI(argv[2]) != 8)
{
SciEcho("Usage: BandWidth 6/7/8 \r\n");
return -1;
}
SciEcho("start search \r\n");
Frequence = skyworth_sfu_search_param.Frequence = ATOI(argv[1]);
BandWidth = skyworth_sfu_search_param.BandWidth = ATOI(argv[2]);
Skyworth_SFU_channel_serarch_init();
UIChChgAerialSignalMonitor(Frequence -BandWidth*1000/2 ,BandWidth);
osal_task_sleep(SFU_CHECK_LOCK_DELAY*4);
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);
if(lock)
{
SetAutoSearch(P_SEARCH_ALL, AS_METHOD_FREQ_BW, Frequence, BandWidth, BY_FREQ);
start_auto_search();
while(1)
{
if(stop_search == 1)
break;
//等待消息,timeout 为5S
if(E_OK == FW_ReceiveMessage(&pMsg, &size, 5000))
{
if(CTL_MSG_TYPE_SYSTEM == pMsg.msgType)
{
if(CTRL_MSG_SUBTYPE_SYSTEM_SCAN_PROGRESS == pMsg.msgSubType)
{
if(AS_PROGRESS_SCANOVER==pMsg.msgCode)
{
UISiaeOpen();
sys_data_set_cur_chan_mode(PROG_VIDEO_MODE);
prog_num = CHN_GetCount(CHN_C_ALL_PROG, PROG_VIDEO_MODE);
break;
}
}
else if(CTRL_MSG_SUBTYPE_SYSTEM_SCAN_ADD_TP == pMsg.msgSubType)
{
//libc_printf("add a new tp!\n");
}
else if(CTRL_MSG_SUBTYPE_SYSTEM_SCAN_ADD_PROG == pMsg.msgSubType)
{
P_NODE p_node;
get_prog_at(pMsg.msgCode, &p_node);
//libc_printf("add a program!\n");
if(p_node.av_flag)
{
//libc_printf("add a video program!\n");
CHN_IncCount(PROG_VIDEO_MODE);
}
else
{
//libc_printf("add an audio program!\n");
CHN_IncCount(PROG_AUDIO_MODE);
}
if(CHN_GetCount(CHN_C_ALL_PROG, CHN_C_ALL_MODE) >= SYS_MAX_NUM_PROGRAM)
{
//libc_printf("channel full!\n");
FW_ClearMsgBuffer();
osal_task_sleep(SFU_CHECK_LOCK_DELAY);
}
}
}
}
else
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -