From 23584669c5e25cdea01c342fdedc3cd7cb3e0c17 Mon Sep 17 00:00:00 2001 From: zhuyanlin Date: Fri, 6 May 2022 19:31:12 +0800 Subject: [PATCH] pmconfig: add last state and modify current state to next state Signed-off-by: zhuyanlin --- nshlib/nsh_syscmds.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c index 40a449113..620a246ce 100644 --- a/nshlib/nsh_syscmds.c +++ b/nshlib/nsh_syscmds.c @@ -180,7 +180,8 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) if (argc <= 2) { - int current_state; + int next_state; + int last_state; int normal_count; int idle_count; int standby_count; @@ -193,7 +194,11 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) ctrl.action = BOARDIOC_PM_QUERYSTATE; boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl); - current_state = ctrl.state; + last_state = ctrl.state; + + ctrl.action = BOARDIOC_PM_CHECKSTATE; + boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl); + next_state = ctrl.state; ctrl.action = BOARDIOC_PM_STAYCOUNT; ctrl.state = PM_NORMAL; @@ -212,8 +217,10 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl); sleep_count = ctrl.count; - nsh_output(vtbl, "Current state %d, PM stay [%d, %d, %d, %d]\n", - current_state, normal_count, idle_count, standby_count, sleep_count); + nsh_output(vtbl, "Last state %d, Next state %d", + "PM stay [%d, %d, %d, %d]\n", + last_state, next_state, normal_count, idle_count, + standby_count, sleep_count); } else if (argc <= 4) {