V124 1.修正功率配置过程,避免升功率或降功率时配置瞬间可能超出目标功率值的问题;2.修正上一版本配置功率时按下确认键,导致瞬间功率下降问题;3.调整LCD配置功率上限为衰减器最大上限;4.修正RS485通讯问题;
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
* Usage from a shell:
|
||||
* echo "freq 473" > /tmp/atsc_ctrl
|
||||
* echo "rxfreq 473" > /tmp/atsc_ctrl
|
||||
* echo "power up 10 100" > /tmp/atsc_ctrl
|
||||
* echo "power down 10 100" > /tmp/atsc_ctrl
|
||||
* echo "status" > /tmp/atsc_ctrl
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@@ -24,6 +26,10 @@
|
||||
#include "../inc/console_ctrl.h"
|
||||
|
||||
#define ATSC_CTRL_FIFO "/tmp/atsc_ctrl"
|
||||
#define POWER_TEST_DEFAULT_STEPS 1U
|
||||
#define POWER_TEST_DEFAULT_INTERVAL_MS 100U
|
||||
#define POWER_TEST_MAX_STEPS 10000U
|
||||
#define POWER_TEST_MAX_INTERVAL_MS 60000U
|
||||
|
||||
static int mhz_to_chn(uint32 mhz)
|
||||
{
|
||||
@@ -73,11 +79,79 @@ static void save_rx_freq(uint8 chn)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Simulate repeated LCD power-key operations. One step is 0.05 dB and each
|
||||
* step uses the normal power-setting path, including the HMC472/ADRV9009
|
||||
* crossover ordering and the physical attenuation-headroom limit.
|
||||
*/
|
||||
static void test_power_key(uint8 power_up, uint32 steps, uint32 interval_ms)
|
||||
{
|
||||
uint32 i;
|
||||
uint16 old_power;
|
||||
uint16 max_power;
|
||||
S_RF_PARA power_para;
|
||||
|
||||
if(steps == 0)
|
||||
{
|
||||
printf("[atsc_ctrl] power test steps must be greater than zero\n");
|
||||
return;
|
||||
}
|
||||
if((steps > POWER_TEST_MAX_STEPS) ||
|
||||
(interval_ms > POWER_TEST_MAX_INTERVAL_MS))
|
||||
{
|
||||
printf("[atsc_ctrl] power test limit: steps<=%u interval_ms<=%u\n",
|
||||
POWER_TEST_MAX_STEPS, POWER_TEST_MAX_INTERVAL_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; i < steps; i++)
|
||||
{
|
||||
old_power = atsc_para.rf_para.power;
|
||||
memcpy(&power_para, &atsc_para.rf_para, sizeof(power_para));
|
||||
|
||||
if(power_up)
|
||||
{
|
||||
max_power = atsc_para.wj_para.p_c ? RF_POWER_P_C_ON : RF_POWER_MAX;
|
||||
if(atsc_para.ad3_para.max_power < max_power)
|
||||
max_power = atsc_para.ad3_para.max_power;
|
||||
|
||||
if((old_power >= max_power) ||
|
||||
(atsc_para.rf_para.db >= RF_POWER_DB_MAX))
|
||||
break;
|
||||
|
||||
power_para.power++;
|
||||
power_para.db++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((old_power == 0) || (atsc_para.rf_para.db == 0))
|
||||
break;
|
||||
|
||||
power_para.power--;
|
||||
power_para.db--;
|
||||
}
|
||||
|
||||
apply_rf_power_para(&power_para);
|
||||
if(atsc_para.rf_para.power == old_power)
|
||||
break;
|
||||
|
||||
if(interval_ms && ((i + 1) < steps))
|
||||
usleep(interval_ms * 1000);
|
||||
}
|
||||
|
||||
printf("[atsc_ctrl] power %s requested=%u completed=%u interval_ms=%u power=%u db=%u display_db_x100=%d\n",
|
||||
power_up ? "up" : "down", steps, i, interval_ms,
|
||||
atsc_para.rf_para.power, atsc_para.rf_para.db,
|
||||
((int32)atsc_para.rf_para.power - RF_POWER_ZERO) * 5);
|
||||
}
|
||||
|
||||
static void exec_cmd(char *line)
|
||||
{
|
||||
char a0[32] = {0};
|
||||
char a1[32] = {0};
|
||||
int n = sscanf(line, "%31s %31s", a0, a1);
|
||||
char a2[32] = {0};
|
||||
char a3[32] = {0};
|
||||
int n = sscanf(line, "%31s %31s %31s %31s", a0, a1, a2, a3);
|
||||
|
||||
if(n < 1)
|
||||
return;
|
||||
@@ -110,6 +184,20 @@ static void exec_cmd(char *line)
|
||||
save_rx_freq((uint8)chn);
|
||||
printf("[atsc_ctrl] rxfreq %u MHz -> chn %d done\n", mhz, chn);
|
||||
}
|
||||
else if((strcmp(a0, "power") == 0) && (n >= 2))
|
||||
{
|
||||
uint32 steps = (n >= 3) ? (uint32)strtoul(a2, NULL, 0)
|
||||
: POWER_TEST_DEFAULT_STEPS;
|
||||
uint32 interval_ms = (n >= 4) ? (uint32)strtoul(a3, NULL, 0)
|
||||
: POWER_TEST_DEFAULT_INTERVAL_MS;
|
||||
|
||||
if(strcmp(a1, "up") == 0)
|
||||
test_power_key(1, steps, interval_ms);
|
||||
else if(strcmp(a1, "down") == 0)
|
||||
test_power_key(0, steps, interval_ms);
|
||||
else
|
||||
printf("[atsc_ctrl] usage: power <up|down> [steps] [interval_ms]\n");
|
||||
}
|
||||
else if(strcmp(a0, "status") == 0)
|
||||
{
|
||||
printf("[atsc_ctrl] tx=%u MHz(chn=%u) rx=%u MHz(chn=%u) rf=%u power=%u db=%u\n",
|
||||
@@ -123,7 +211,7 @@ static void exec_cmd(char *line)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[atsc_ctrl] usage: freq <MHz> | rxfreq <MHz> | status\n");
|
||||
printf("[atsc_ctrl] usage: freq <MHz> | rxfreq <MHz> | power <up|down> [steps] [interval_ms] | status\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user