From: 孙春阳 Date: Wed, 15 Oct 2025 11:13:58 +0000 (+0800) Subject: 添加AT^PMVETOGET获取投票信息,AT^TASKSWITCHPRINT开启task切换打印 X-Git-Tag: V1.0.9_20251128_194606_LN~233^2~2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=eadc6ced1ab29f47911a32b14f9b6bc3433a0810;p=mirrors%2FFD230.git 添加AT^PMVETOGET获取投票信息,AT^TASKSWITCHPRINT开启task切换打印 --- diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index 25d054a06..e83952834 100644 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -1267,6 +1267,38 @@ static void pm_print_veto_info(void) } } +static void pm_print_active_veto_info(void) +{ + uint8_t i = 0; + uint8_t active_count = 0; + pm_veto_t *pm_veto_ptr = pm_veto_get_info(); + + wstp_print("========== PM Active Veto Info ==========\r\n"); + wstp_print("Total votes: %d\r\n", pm_veto_ptr->veto_counts.total_counts); + + if (pm_veto_ptr->veto_counts.total_counts == 0) { + wstp_print("No active votes.\r\n"); + } else { + wstp_print("Active votes:\r\n"); + for (i = 0; i < PM_ID_MAX; i++) { + if (pm_veto_ptr->veto_counts.sub_counts[i] > 0) { + wstp_print(" [%d] %s: %d vote(s)\r\n", + i, + get_pm_id_name(i), + pm_veto_ptr->veto_counts.sub_counts[i]); + active_count++; + } + } + wstp_print("Total active modules: %d\r\n", active_count); + } + + if (pm_veto_ptr->veto_timeout_timestamp > 0) { + wstp_print("Veto timeout timestamp: %llu ms\r\n", pm_veto_ptr->veto_timeout_timestamp); + } + + wstp_print("========================================\r\n"); +} + static void lpc_print_veto_info(void) { uint8_t i = 0; @@ -1289,6 +1321,36 @@ uint32_t mcu_pm_dfx_mode(uint8_t *para, uint32_t para_len) return ERRCODE_SUCC; } +uint32_t mcu_pm_veto_get(uint8_t *para, uint32_t para_len) +{ + unused(para); + unused(para_len); + + pm_print_active_veto_info(); + return ERRCODE_SUCC; +} + +uint32_t mcu_task_switch_print_ctrl(uint8_t *para, uint32_t para_len) +{ + unused(para_len); + + if (para == NULL) { + wstp_print("Usage: AT^TASKSWITCHPRINT=<0|1>\r\n"); + wstp_print(" 0: Disable task switch print\r\n"); + wstp_print(" 1: Enable task switch print\r\n"); + return ERRCODE_FAIL; + } + + uint32_t enable = atoi((char*)para); + + extern void OsTaskSwitchPrintSetEnable(uint32_t enable); + OsTaskSwitchPrintSetEnable(enable); + + wstp_print("Task switch print %s\r\n", enable ? "enabled" : "disabled"); + + return ERRCODE_SUCC; +} + uint32_t mcu_pm_cldo1_power_down(uint8_t *para, uint32_t para_len) { unused(para); @@ -2762,6 +2824,8 @@ static const app_process_table g_app_funcs[] = { { PMMODESET, mcu_pm_req_mode }, { PMMODEUSR, mcu_set_pm_req_mode_usr}, { PMMODEGET, mcu_pm_dfx_mode }, + { PMVETOGET, mcu_pm_veto_get }, + { TASKSWITCHPRINT, mcu_task_switch_print_ctrl }, { GETCURSEC, mcu_dfx_get_cur_second}, { LCDFILL, lcd_fill }, { GETIDS, get_ids }, diff --git a/code/sdk/application/wstp/at_service/app/app_cmd_manager.c b/code/sdk/application/wstp/at_service/app/app_cmd_manager.c index 9c8014034..1bc3008dd 100644 --- a/code/sdk/application/wstp/at_service/app/app_cmd_manager.c +++ b/code/sdk/application/wstp/at_service/app/app_cmd_manager.c @@ -387,6 +387,28 @@ static uint32_t app_test_pm_dfx_mode(uint8_t *para, uint32_t para_len, char *str return ERRCODE_SUCC; } +static uint32_t app_test_pm_veto_get(uint8_t *para, uint32_t para_len, char *str_cmd) +{ + unused(str_cmd); + if (para == NULL) { + return ERRCODE_FAIL; + } + + app_pkg_msg_send(PMVETOGET, DIAG_CONTROL_FALSE, para, para_len); + return ERRCODE_SUCC; +} + +static uint32_t app_test_task_switch_print(uint8_t *para, uint32_t para_len, char *str_cmd) +{ + unused(str_cmd); + if (para == NULL) { + return ERRCODE_FAIL; + } + + app_pkg_msg_send(TASKSWITCHPRINT, DIAG_CONTROL_FALSE, para, para_len); + return ERRCODE_SUCC; +} + static uint32_t app_test_pm_lcd_off(uint8_t *para, uint32_t para_len, char *str_cmd) { unused(str_cmd); @@ -1118,6 +1140,8 @@ static const at_cmd_table_t g_app_cmd[] = { { "AT^PMMODE", app_test_pm_req_mode, "" }, { "AT^PMMODESETUSR", app_test_set_pm_req_mode, "" }, { "AT^PMMODEGET", app_test_pm_dfx_mode, "" }, + { "AT^PMVETOGET", app_test_pm_veto_get, "" }, + { "AT^TASKSWITCHPRINT", app_test_task_switch_print, "" }, { "AT^GETCURSEC", app_get_cur_second, "" }, { "AT^LCDFILL", app_test_lcd_fill, "" }, { "AT^LCDLIGHT", app_test_lcd_light, "" }, diff --git a/code/sdk/application/wstp/at_service/app/app_msg_manager.h b/code/sdk/application/wstp/at_service/app/app_msg_manager.h index 4456e8352..286ac9602 100644 --- a/code/sdk/application/wstp/at_service/app/app_msg_manager.h +++ b/code/sdk/application/wstp/at_service/app/app_msg_manager.h @@ -117,6 +117,8 @@ typedef enum { SCHEDSTART = 0x56, SCHEDSTOP = 0x57, SDIOTEST = 0x58, + PMVETOGET = 0x59, // 新增:获取PM投票信息 + TASKSWITCHPRINT = 0x5A, // 新增:控制任务切换打印 MSG_ID_MAX_BUTT, } app_msg_id; diff --git a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/include/los_task_pri.h b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/include/los_task_pri.h index 8d9e39620..b671e1d40 100644 --- a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/include/los_task_pri.h +++ b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/include/los_task_pri.h @@ -136,6 +136,10 @@ extern UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv); #define OS_ALL_TASK_MASK 0xFFFFFFFF extern UINT32 OsDbgTskInfoGet(UINT32 taskId); extern UINT32 OsGetIdleTaskId(VOID); + +/* Task switch print control */ +extern UINT32 OsTaskSwitchPrintIsEnabled(VOID); +extern VOID OsTaskSwitchPrintSetEnable(UINT32 enable); extern CHAR *OsCurTaskNameGet(VOID); extern VOID OsTaskAdd2TimerList(LosTaskCB *taskCB, UINT32 timeout); extern VOID OsTimerListDelete(LosTaskCB *taskCB); diff --git a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/sched/sched_sq/los_sched.c b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/sched/sched_sq/los_sched.c index 8bfe31502..537023e4e 100644 --- a/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/sched/sched_sq/los_sched.c +++ b/code/sdk/kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/kernel/base/sched/sched_sq/los_sched.c @@ -40,6 +40,26 @@ #include "los_perf_pri.h" #endif +/* 全局变量:控制任务切换打印开关(默认关闭)*/ +static volatile UINT32 g_taskSwitchPrintEnable = 0; + +/* 获取任务切换打印开关状态 */ +UINT32 OsTaskSwitchPrintIsEnabled(VOID) +{ + return g_taskSwitchPrintEnable; +} + +/* 设置任务切换打印开关 */ +VOID OsTaskSwitchPrintSetEnable(UINT32 enable) +{ + g_taskSwitchPrintEnable = enable ? 1 : 0; + if (enable) { + printf("[TASK_SWITCH] Task switch print enabled\n"); + } else { + printf("[TASK_SWITCH] Task switch print disabled\n"); + } +} + VOID OsSchedResched(VOID) { LosTaskCB *runTask = NULL; @@ -72,6 +92,15 @@ VOID OsSchedResched(VOID) newTask->currCpu = ArchCurrCpuid(); #endif + /* 任务切换打印(由全局开关控制)*/ + if (g_taskSwitchPrintEnable) { + const char *runTaskName = (runTask->taskName != NULL) ? runTask->taskName : "NULL"; + const char *newTaskName = (newTask->taskName != NULL) ? newTask->taskName : "NULL"; + printf("[TASK_SWITCH] %s(ID:%u) -> %s(ID:%u)\n", + runTaskName, runTask->taskId, + newTaskName, newTask->taskId); + } + OsTaskTimeUpdateHook(runTask->taskId); #ifdef LOSCFG_KERNEL_CPUP