From 6f1190f935e48e75d45a3ef923db728f8efc9a3e Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:09:29 +0000 Subject: [PATCH 1/7] Revert "RDK-55706: PowerModePreChange handling" This reverts commit 363642b41291d5d6ae8c62a66f90587f4e6ed812. --- iarm_set_powerstate/IARM_BUS_SetPowerStatus.c | 227 ++---------------- 1 file changed, 26 insertions(+), 201 deletions(-) diff --git a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c index 527dc48..8f214c5 100644 --- a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +++ b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c @@ -16,161 +16,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include -#include #include -#include -#include -#include #include "power_controller.h" -#define ARRAY_SIZE 10 - const char* pPowerON = "ON"; const char* pPowerOFF = "OFF"; const char* pPowerStandby = "STANDBY"; const char* pPowerLigtSleep = "LIGHTSLEEP"; const char* pPowerDeepSleep = "DEEPSLEEP"; -const char* pNOP = "NOP"; -static void usage() +void usage() { - printf("\nUsage: 'SetPowerState [OPTIONS] [ON | STANDBY | LIGHTSLEEP | DEEPSLEEP | OFF | NOP] with PowerManager plugin\n"); + printf("\nUsage: 'SetPowerState [ON | STANDBY | LIGHTSLEEP | DEEPSLEEP | OFF ] with PowerManager plugin'\n"); printf("\t\t ON -> Set to Active Mode\n"); printf("\t\t STANDBY -> Set to Standby Mode\n"); printf("\t\t LIGHTSLEEP -> Set to LIGHT Sleep Standby mode\n"); printf("\t\t DEEPSLEEP -> Set to DEEP Sleep Standby mode\n"); printf("\t\t OFF -> Set to OFF\n"); - printf("\t\t NOP -> No operation, to support test scenarios with parallel `SetPowerState` run\n\n"); - printf("\tOptions:\n"); - printf("\t --client Specify client name (e.g., C1, C2).\n"); - printf("\t --ack Delay to acknowledge power change in seconds (-1: no ack, 0: quick ack, >0: delayed ack; default: -1).\n"); - printf("\t --delay Delay for power change in seconds, as CSV (default: no delay).\n"); - printf("\t Each delay corresponds to `DelayPowerModeChangeBy` call\n"); - printf("\t --await Wait at least this many seconds before exiting (default 0).\n"); -} - -static void parseCSV(const char* arg, int* values, int* size) -{ - char* token; - char buffer[256]; - int index = 0; - - strncpy(buffer, arg, sizeof(buffer) - 1); - buffer[sizeof(buffer) - 1] = '\0'; - - token = strtok(buffer, ","); - while (token != NULL && index < ARRAY_SIZE) { - values[index++] = atoi(token); - token = strtok(NULL, ","); - } - - *size = index; -} - -typedef struct { - char clientName[256]; - int ack; - int delay[ARRAY_SIZE]; - int delaySize; - uint32_t clientId; - volatile int transactionId; - pthread_t asyncThread; -} Controller; - -static void* asyncThreadMain(void* arg) -{ - Controller* controller = (Controller*)arg; - usleep((controller->ack - 0.05) * 1000000); // Ack delay minus 50ms - PowerController_PowerModePreChangeComplete(controller->clientId, controller->transactionId); - return NULL; -} - -static void onPowerModePreChangeEvent(const PowerController_PowerState_t currentState, - const PowerController_PowerState_t newState, - const int transactionId, const int stateChangeAfter, void* userdata) -{ - Controller* controller = (Controller*)userdata; - - printf("onPowerModePreChangeEvent currentState: %d, newState: %d, clientId: %d, transactionId: %d, stateChangeAfter: %d\n", - currentState, newState, controller->clientId, transactionId, stateChangeAfter); - - controller->transactionId = transactionId; - - if (controller->ack == 0) { - PowerController_PowerModePreChangeComplete(controller->clientId, transactionId); - } else if (controller->ack > 0) { - pthread_create(&(controller->asyncThread), NULL, asyncThreadMain, controller); - } -} - -static void initController(Controller* controller) -{ - PowerController_Init(); - - while (!PowerController_IsOperational()) { - uint32_t status = PowerController_Connect(); - - if (POWER_CONTROLLER_ERROR_NONE == status) { - printf("\nSuccess :: Connect\n"); - break; - } else if (POWER_CONTROLLER_ERROR_UNAVAILABLE == status) { - printf("\nFailed :: Connect :: Thunder is UNAVAILABLE\n"); - } else if (POWER_CONTROLLER_ERROR_NOT_EXIST == status) { - printf("\nFailed :: Connect :: PowerManager is UNAVAILABLE\n"); - } else { - // Do nothing - } - usleep(100 * 1000); // 100ms - } - - PowerController_RegisterPowerModePreChangeCallback(onPowerModePreChangeEvent, controller); - - if (strlen(controller->clientName) > 0) { - PowerController_AddPowerModePreChangeClient(controller->clientName, &(controller->clientId)); - } -} - -static void terminateController(Controller* controller) -{ - if (controller->asyncThread) { - pthread_join(controller->asyncThread, NULL); - } - - if (strlen(controller->clientName) > 0) { - PowerController_RemovePowerModePreChangeClient(controller->clientId); - } - - PowerController_UnRegisterPowerModePreChangeCallback(onPowerModePreChangeEvent); - - // TODO: without this delay there is a hang Communicator ThreadPool destroy. - // This is captured as part of jira `RDK-56273` & will be taken up in future sprints. - sleep(1); - PowerController_Term(); - printf("PowerController_Term after 1s delay\n"); -} - -static void runDelay(Controller* controller) -{ - int retry = 5; - - // Wait for PowerManager to respond - // `transactionId` will be updated on receiving onPowerModePreChangeEvent - while (controller->transactionId == 0 && retry-- > 0) { - usleep(100 * 1000); // 100ms - } - - if (controller->transactionId > 0) { - for (int i = 0; i < controller->delaySize; i++) { - if (controller->delay[i] > 0) { - PowerController_DelayPowerModeChangeBy(controller->clientId, controller->transactionId, controller->delay[i]); - usleep((controller->delay[i] - 0.05) * 1000000); // Delay minus 50ms - } - } - } } /** @@ -180,80 +44,42 @@ static void runDelay(Controller* controller) int main(int argc, char* argv[]) { PowerController_PowerState_t powerstate = POWER_STATE_ON; - struct option longOptions[] = { - { "client", required_argument, NULL, 'c' }, - { "ack", required_argument, NULL, 'a' }, - { "delay", required_argument, NULL, 'd' }, - { "await", required_argument, NULL, 'w' }, - { NULL, 0, NULL, 0 } - }; - Controller controller = { .clientName = "", .ack = -1, .delaySize = 0, .clientId = 0, .transactionId = 0 }; - - int await = 0; - char argstate[256] = ""; - - int opt; - int optionIndex = 0; - while ((opt = getopt_long(argc, argv, "c:a:d:w:", longOptions, &optionIndex)) != -1) { - switch (opt) { - case 'c': - strncpy(controller.clientName, optarg, sizeof(controller.clientName) - 1); - break; - case 'a': - controller.ack = atoi(optarg); - break; - case 'd': - parseCSV(optarg, controller.delay, &controller.delaySize); - break; - case 'w': - await = atoi(optarg); - break; - default: - usage(); - return EXIT_FAILURE; - } - } - - if (optind < argc) { - strncpy(argstate, argv[optind], sizeof(argstate) - 1); - } else { - fprintf(stderr, "Error: POWER_STATE is mandatory.\n"); + if (argc < 2) { usage(); - return EXIT_FAILURE; - } - - if (strncasecmp(pPowerON, argstate, strlen(pPowerON)) == 0) { + } else if (strncasecmp(pPowerON, argv[1], strlen(pPowerON)) == 0) { powerstate = POWER_STATE_ON; printf("ON Request...\n"); - } else if (strncasecmp(pPowerStandby, argstate, strlen(pPowerStandby)) == 0) { + } else if (strncasecmp(pPowerStandby, argv[1], strlen(pPowerStandby)) == 0) { powerstate = POWER_STATE_STANDBY; printf("STANDBY Request...\n"); - } else if (strncasecmp(pPowerLigtSleep, argstate, strlen(pPowerLigtSleep)) == 0) { + } else if (strncasecmp(pPowerLigtSleep, argv[1], strlen(pPowerLigtSleep)) == 0) { powerstate = POWER_STATE_STANDBY_LIGHT_SLEEP; printf("Light Sleep Request...\n"); - } else if (strncasecmp(pPowerDeepSleep, argstate, strlen(pPowerDeepSleep)) == 0) { + } else if (strncasecmp(pPowerDeepSleep, argv[1], strlen(pPowerDeepSleep)) == 0) { powerstate = POWER_STATE_STANDBY_DEEP_SLEEP; printf("Deep Sleep Request...\n"); - } else if (strncasecmp(pPowerOFF, argstate, strlen(pPowerOFF)) == 0) { + } else if (strncasecmp(pPowerOFF, argv[1], strlen(pPowerOFF)) == 0) { powerstate = POWER_STATE_OFF; printf("OFF Request...\n"); - } else if (strcmp(argstate, pNOP) == 0) { - powerstate = POWER_STATE_UNKNOWN; - printf("NOP Request...\n"); } else { usage(); - return EXIT_FAILURE; } - initController(&controller); + if ((POWER_STATE_ON == powerstate) + || (POWER_STATE_OFF == powerstate) + || (POWER_STATE_STANDBY == powerstate) + || (POWER_STATE_STANDBY_LIGHT_SLEEP == powerstate) + || (POWER_STATE_STANDBY_DEEP_SLEEP == powerstate)) { - // Wait for parallel `SetPowerState` run - usleep(100 * 1000); - - if (POWER_STATE_UNKNOWN != powerstate) { int keyCode = 0; - uint32_t res = PowerController_SetPowerState(keyCode, powerstate, "sys_mon_tool[SetPowerState]"); + uint32_t res = 0; + + PowerController_Init(); + + res = PowerController_SetPowerState(keyCode, powerstate, "sys_mon_tool[SetPowerState]"); + + /** Query current Power state */ if (POWER_CONTROLLER_ERROR_NONE == res) { printf("SetPowerState :: Success \n"); } else if (POWER_CONTROLLER_ERROR_UNAVAILABLE == res) { @@ -261,15 +87,14 @@ int main(int argc, char* argv[]) } else { printf("SetPowerState :: Failed \n"); } - } - runDelay(&controller); + // TODO: without this delay there is a hang Communicator ThreadPool destroy. + // This is captured as part of jira `RDK-56273` & will be taken up in future sprints. + sleep(1); - if (await > 0) { - sleep(await); + /* Term closes RPC conn, do not make any power controller calls after this */ + PowerController_Term(); + printf("PowerController_Term after 1s delay\n"); } - - terminateController(&controller); - return 0; } From 27d5fbcc8ced0936f80543f942928abbc75624d9 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:10:32 +0000 Subject: [PATCH 2/7] Revert "comments about inclusion of pwrMgr.h" This reverts commit 9de844ecce842a6106db9ed7647f16391bc98ca7. --- iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c index 0550d61..120051d 100644 --- a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c +++ b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c @@ -23,8 +23,7 @@ #include #include -// This include is still required for data types to read cached power status residing in /opt/uimgr_settings.bin -// TODO: after IARM PwrMgr logic is moved to PowerManager plugin refactor this code and remove this header file too. +/*#include "libIBus.h"*/ #include "pwrMgr.h" #include "power_controller.h" From 3cea2ae0f0cea3c96f1ea07d5bc2db9ce48238d1 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:10:40 +0000 Subject: [PATCH 3/7] Revert "removed .clang-format" This reverts commit 463930e114b307f26d65bb473f34ad10901f1220. --- .clang-format | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..7583a41 --- /dev/null +++ b/.clang-format @@ -0,0 +1,109 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^"config\.h"' + Priority: -1 + # The main header for a source file automatically gets category 0 + - Regex: '.*' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +QualifierAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... From 8a11efc744cf2c2ad03a98989f3c57d20e5e8bbf Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:10:46 +0000 Subject: [PATCH 4/7] Revert "Fix a build failure" This reverts commit f8094f50ee2ada42a2aa07e48474839e8c2a0953. --- iarm_set_powerstate/IARM_BUS_SetPowerStatus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c index 8f214c5..4b6a6e5 100644 --- a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +++ b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c @@ -43,7 +43,7 @@ void usage() */ int main(int argc, char* argv[]) { - PowerController_PowerState_t powerstate = POWER_STATE_ON; + PowerManager_PowerState_t powerstate = POWER_STATE_ON; if (argc < 2) { usage(); From 9501b49bc84b36c0770b69717c2eb6393e4242d7 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:11:02 +0000 Subject: [PATCH 5/7] Revert "Fix rebase issue" This reverts commit 7ba128df04b6dbbda177d5c6d74d1248e866f373. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index bd0c328..b19f85a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,10 +41,10 @@ bin_PROGRAMS = keySimulator mfr_util QueryPowerState SetPowerState IARM_event_se mfr_util_SOURCES = mfr-utils/sys_mfr_utils.c mfr_util_LDADD = -lIARMBus -QueryPowerState_SOURCES=iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c +QueryPowerState_SOURCES=IARM_Bus_CheckPowerStatus.c QueryPowerState_LDADD = $(DIRECT_LIBS) $(FUSION_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -lWPEFrameworkPowerController -SetPowerState_SOURCES=iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +SetPowerState_SOURCES=IARM_BUS_SetPowerStatus.c SetPowerState_LDADD = -ldbus-1 -lstdc++ -lpthread -lWPEFrameworkPowerController keySimulator_SOURCES=key_simulator/IARM_BUS_UIEventSimulator.c key_simulator/uinput.c From d76aed1b91e852270129d4e4967c4684f9c09bc7 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:11:11 +0000 Subject: [PATCH 6/7] Revert "add delay" This reverts commit 1bc98a407264fbd6c8b732c0336890c430e56783. --- Makefile.am | 6 +-- .../IARM_Bus_CheckPowerStatus.c | 48 ++++++++----------- iarm_set_powerstate/IARM_BUS_SetPowerStatus.c | 20 ++------ 3 files changed, 26 insertions(+), 48 deletions(-) diff --git a/Makefile.am b/Makefile.am index b19f85a..69f409f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,7 @@ AM_CFLAGS = \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/rdmmgr \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/receiver \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/sysmgr \ - -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/WPEFramework/powercontroller \ + -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/WPEFramework/powermanager \ -L$(PKG_CONFIG_SYSROOT_DIR)/usr/lib/ @@ -42,10 +42,10 @@ mfr_util_SOURCES = mfr-utils/sys_mfr_utils.c mfr_util_LDADD = -lIARMBus QueryPowerState_SOURCES=IARM_Bus_CheckPowerStatus.c -QueryPowerState_LDADD = $(DIRECT_LIBS) $(FUSION_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -lWPEFrameworkPowerController +QueryPowerState_LDADD = $(DIRECT_LIBS) $(FUSION_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -lWPEFrameworkPowerManagerClient SetPowerState_SOURCES=IARM_BUS_SetPowerStatus.c -SetPowerState_LDADD = -ldbus-1 -lstdc++ -lpthread -lWPEFrameworkPowerController +SetPowerState_LDADD = -ldbus-1 -lstdc++ -lpthread -lWPEFrameworkPowerManagerClient keySimulator_SOURCES=key_simulator/IARM_BUS_UIEventSimulator.c key_simulator/uinput.c keySimulator_LDADD = $(GLIB_LIBS) -lIARMBus $(DBUS_LIBS) diff --git a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c index 120051d..2ee13b1 100644 --- a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c +++ b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c @@ -26,7 +26,7 @@ /*#include "libIBus.h"*/ #include "pwrMgr.h" -#include "power_controller.h" +#include "powermanager_client.h" #define PADDING_SIZE 32 @@ -72,37 +72,30 @@ int main(int argc, char* argv[]) if (argc > 1) { if (argv[1][1] == 'c') { - uint32_t res = 0; - PowerController_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; - - PowerController_Init(); + PowerManager_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; /** Query current Power state */ - res = PowerController_GetPowerState(&curState, &previousState); - - if (POWER_CONTROLLER_ERROR_NONE == res) { + if (0 == PowerManager_GetPowerState(&curState, &previousState)) { if (POWER_STATE_OFF == curState) { - printf("OFF\n"); + printf("OFF"); } else if (POWER_STATE_STANDBY == curState) { - printf("STANDBY\n"); + printf("STANDBY"); } else if (POWER_STATE_ON == curState) { - printf("ON\n"); + printf("ON"); } else if (POWER_STATE_STANDBY_LIGHT_SLEEP == curState) { - printf("LIGHTSLEEP\n"); + printf("LIGHTSLEEP"); } else if (POWER_STATE_STANDBY_DEEP_SLEEP == curState) { - printf("DEEPSLEEP\n"); + printf("DEEPSLEEP"); } else { - printf("Unknown\n"); + printf("Unknown"); } - } else if (POWER_CONTROLLER_ERROR_UNAVAILABLE == res) { - printf("Error :: PowerManager plugin unavailable\n"); } else { - printf("Error :: Unknown\n"); + printf("Unknown"); } /* Dispose closes RPC conn, do not make any power manager calls after this */ - PowerController_Term(); + PowerManager_Dispose(); } else if (argv[1][1] == 'h') { usage(); @@ -123,24 +116,21 @@ int main(int argc, char* argv[]) } if (ret > 0) { - if (IARM_BUS_PWRMGR_POWERSTATE_OFF == pwrSettings.powerState) { + if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_OFF) printf("OFF"); - } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY == pwrSettings.powerState) { + else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) printf("STANDBY"); - } else if (IARM_BUS_PWRMGR_POWERSTATE_ON == pwrSettings.powerState) { + else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_ON) printf("ON"); - } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP == pwrSettings.powerState) { + else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) printf("LIGHTSLEEP"); - } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP == pwrSettings.powerState) { + else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) printf("DEEPSLEEP"); - } else { + else printf("Unknown Power state"); - } - } else { + } else printf("Error in reading PWRMgr settings File"); - } - - printf("\n"); } + printf("\n"); return 0; } diff --git a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c index 4b6a6e5..104cc19 100644 --- a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +++ b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c @@ -19,7 +19,7 @@ #include #include -#include "power_controller.h" +#include "powermanager_client.h" const char* pPowerON = "ON"; const char* pPowerOFF = "OFF"; @@ -73,28 +73,16 @@ int main(int argc, char* argv[]) || (POWER_STATE_STANDBY_DEEP_SLEEP == powerstate)) { int keyCode = 0; - uint32_t res = 0; - - PowerController_Init(); - - res = PowerController_SetPowerState(keyCode, powerstate, "sys_mon_tool[SetPowerState]"); /** Query current Power state */ - if (POWER_CONTROLLER_ERROR_NONE == res) { + if (!PowerManager_SetPowerState(keyCode, powerstate, "sys_mon_tool[SetPowerState]")) { printf("SetPowerState :: Success \n"); - } else if (POWER_CONTROLLER_ERROR_UNAVAILABLE == res) { - printf("SetPowerState :: Failed :: PowerManager plugin unavailable\n"); } else { printf("SetPowerState :: Failed \n"); } - // TODO: without this delay there is a hang Communicator ThreadPool destroy. - // This is captured as part of jira `RDK-56273` & will be taken up in future sprints. - sleep(1); - - /* Term closes RPC conn, do not make any power controller calls after this */ - PowerController_Term(); - printf("PowerController_Term after 1s delay\n"); + /* Dispose closes RPC conn, do not make any power manager calls after this */ + PowerManager_Dispose(); } return 0; } From 4174411d480c0c45a63b284dae2f924062d0bd09 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Wed, 25 Feb 2026 09:11:18 +0000 Subject: [PATCH 7/7] Revert "sys_mon_tools to use power manager plugin client library" This reverts commit b972da28c3873d72c36e9f7868a8a347b0f58639. --- .clang-format | 109 ------------- .gitignore | 58 ------- Makefile.am | 9 +- .../IARM_Bus_CheckPowerStatus.c | 154 ++++++++++-------- iarm_set_powerstate/IARM_BUS_SetPowerStatus.c | 118 ++++++++------ 5 files changed, 158 insertions(+), 290 deletions(-) delete mode 100644 .clang-format delete mode 100644 .gitignore diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 7583a41..0000000 --- a/.clang-format +++ /dev/null @@ -1,109 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All -BreakBeforeBraces: WebKit -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 0 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeCategories: - - Regex: '^"config\.h"' - Priority: -1 - # The main header for a source file automatically gets category 0 - - Regex: '.*' - Priority: 1 - - Regex: '^<.*\.h>' - Priority: 2 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -QualifierAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 77d1d6b..0000000 --- a/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# http://www.gnu.org/software/automake - -Makefile.in -/ar-lib -/mdate-sh -/py-compile -/test-driver -/ylwrap -.deps/ -.dirstamp - -# http://www.gnu.org/software/autoconf - -autom4te.cache -/autoscan.log -/autoscan-*.log -/aclocal.m4 -/compile -/config.cache -/config.guess -/config.h.in -/config.log -/config.status -/config.sub -/configure -/configure.scan -/depcomp -/install-sh -/missing -/stamp-h1 - -# https://www.gnu.org/software/libtool/ - -/ltmain.sh - -# http://www.gnu.org/software/texinfo - -/texinfo.tex - -# http://www.gnu.org/software/m4/ - -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 - -# Generated Makefile -# (meta build system like autotools, -# can automatically generate from config.status script -# (which is called by configure script)) -# Makefile - -cfg - -# clangd -compile_commands.json -.cache diff --git a/Makefile.am b/Makefile.am index 69f409f..50203e6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,6 @@ AM_CFLAGS = \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/rdmmgr \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/receiver \ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmmgrs/sysmgr \ - -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/WPEFramework/powermanager \ -L$(PKG_CONFIG_SYSROOT_DIR)/usr/lib/ @@ -41,11 +40,11 @@ bin_PROGRAMS = keySimulator mfr_util QueryPowerState SetPowerState IARM_event_se mfr_util_SOURCES = mfr-utils/sys_mfr_utils.c mfr_util_LDADD = -lIARMBus -QueryPowerState_SOURCES=IARM_Bus_CheckPowerStatus.c -QueryPowerState_LDADD = $(DIRECT_LIBS) $(FUSION_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -lWPEFrameworkPowerManagerClient +QueryPowerState_SOURCES=iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c +QueryPowerState_LDADD = $(DIRECT_LIBS) $(FUSION_LIBS) $(GLIB_LIBS) -lIARMBus $(DBUS_LIBS) -SetPowerState_SOURCES=IARM_BUS_SetPowerStatus.c -SetPowerState_LDADD = -ldbus-1 -lstdc++ -lpthread -lWPEFrameworkPowerManagerClient +SetPowerState_SOURCES=iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +SetPowerState_LDADD = -ldbus-1 -lstdc++ -lIARMBus -lpthread keySimulator_SOURCES=key_simulator/IARM_BUS_UIEventSimulator.c key_simulator/uinput.c keySimulator_LDADD = $(GLIB_LIBS) -lIARMBus $(DBUS_LIBS) diff --git a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c index 2ee13b1..17b3440 100644 --- a/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c +++ b/iarm_query_powerstate/IARM_Bus_CheckPowerStatus.c @@ -15,122 +15,134 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ +*/ +#include #include +#include #include -#include -#include -#include #include - -/*#include "libIBus.h"*/ +#include +#include +#include "libIBus.h" #include "pwrMgr.h" -#include "powermanager_client.h" #define PADDING_SIZE 32 /*LED settings*/ -typedef struct _PWRMgr_LED_Settings_t { +typedef struct _PWRMgr_LED_Settings_t{ unsigned int brightness; unsigned int color; -} PWRMgr_LED_Settings_t; +}PWRMgr_LED_Settings_t; typedef struct _PWRMgr_Settings_t { uint32_t magic; uint32_t version; uint32_t length; IARM_Bus_PWRMgr_PowerState_t powerState; - PWRMgr_LED_Settings_t ledSettings; - uint32_t deep_sleep_timeout; + PWRMgr_LED_Settings_t ledSettings; + uint32_t deep_sleep_timeout; char padding[PADDING_SIZE]; } PWRMgr_Settings_t; -void usage() +void usage () { - printf("\nUsage: 'QueryPowerState [CMD]'\n"); - printf("\tCMDs are,\n"); - printf("\t\t -h -> Help\n"); - printf("\t\t -c -> Box state from PowerManager plugin\n"); - printf("\t\t No CMD will read the iARM state from '/opt'\n"); - - printf("\n\tOutput will be,\n"); - printf("\t\t\t ON -> Box is in Active Mode\n"); - printf("\t\t\t STANDBY -> Box is in Standby Mode\n"); - printf("\t\t\t LIGHTSLEEP -> Box is in Light Sleep Standby Mode\n"); - printf("\t\t\t DEEPSLEEP -> Box is in Deep Sleep Standby Mode\n"); - printf("\t\t\t OFF -> Box id OFF\n"); + printf ("\nUsage: 'QueryPowerState [CMD]'\n"); + printf ("\tCMDs are,\n"); + printf ("\t\t -h -> Help\n"); + printf ("\t\t -c -> Box state from iARM Cache\n"); + printf ("\t\t No CMD will read the iARM state from '/opt'\n"); + + printf ("\n\tOutput will be,\n"); + printf ("\t\t\t ON -> Box is in Active Mode\n"); + printf ("\t\t\t STANDBY -> Box is in Standby Mode\n"); + printf ("\t\t\t LIGHTSLEEP -> Box is in Light Sleep Standby Mode\n"); + printf ("\t\t\t DEEPSLEEP -> Box is in Deep Sleep Standby Mode\n"); + printf ("\t\t\t OFF -> Box id OFF\n"); } /** * Test application to check whether the box is in standby or not. * This has been developed to resolve, XONE-4598 */ -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { + PWRMgr_Settings_t pwrSettings; int ret = 0; - - if (argc > 1) { - if (argv[1][1] == 'c') { - PowerManager_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; - + const char *settingsFile = "/opt/uimgr_settings.bin"; + + memset(&pwrSettings,0,sizeof(PWRMgr_Settings_t)); + + if (argc > 1) + { + if (argv[1][1] == 'c') + { + IARM_Bus_PWRMgr_GetPowerState_Param_t param; + + IARM_Bus_Init("iARMQueryPower_1tool"); + IARM_Bus_Connect(); + /** Query current Power state */ - if (0 == PowerManager_GetPowerState(&curState, &previousState)) { - - if (POWER_STATE_OFF == curState) { - printf("OFF"); - } else if (POWER_STATE_STANDBY == curState) { - printf("STANDBY"); - } else if (POWER_STATE_ON == curState) { - printf("ON"); - } else if (POWER_STATE_STANDBY_LIGHT_SLEEP == curState) { - printf("LIGHTSLEEP"); - } else if (POWER_STATE_STANDBY_DEEP_SLEEP == curState) { - printf("DEEPSLEEP"); - } else { - printf("Unknown"); - } - } else { - printf("Unknown"); + if (IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, + IARM_BUS_PWRMGR_API_GetPowerState, + (void *)¶m, + sizeof(param))) + { + + if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_OFF) + printf ("OFF"); + else if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) + printf ("STANDBY"); + else if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_ON) + printf ("ON"); + else if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) + printf ("LIGHTSLEEP"); + else if (param.curState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) + printf ("DEEPSLEEP"); + else + printf ("Unknown"); } - - /* Dispose closes RPC conn, do not make any power manager calls after this */ - PowerManager_Dispose(); - - } else if (argv[1][1] == 'h') { + else + printf ("Unknown"); + + IARM_Bus_Disconnect(); + IARM_Bus_Term(); + } + else if (argv[1][1] == 'h') + { usage(); } - } else { - PWRMgr_Settings_t pwrSettings; - const char* settingsFile = "/opt/uimgr_settings.bin"; - + } + else + { int fd = open(settingsFile, O_RDONLY); - memset(&pwrSettings, 0, sizeof(PWRMgr_Settings_t)); - if (fd > 0) { lseek(fd, 0, SEEK_SET); - ret = read(fd, &pwrSettings, (sizeof(PWRMgr_Settings_t) - PADDING_SIZE)); + + ret = read(fd, &pwrSettings, (sizeof(PWRMgr_Settings_t) - PADDING_SIZE) ); - close(fd); + close (fd); } - if (ret > 0) { + if (ret > 0) + { if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_OFF) - printf("OFF"); + printf ("OFF"); else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) - printf("STANDBY"); + printf ("STANDBY"); else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_ON) - printf("ON"); + printf ("ON"); else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) - printf("LIGHTSLEEP"); + printf ("LIGHTSLEEP"); else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) - printf("DEEPSLEEP"); - else - printf("Unknown Power state"); - } else - printf("Error in reading PWRMgr settings File"); + printf ("DEEPSLEEP"); + else + printf ("Unknown Power state"); + } + else + printf ("Error in reading PWRMgr settings File"); } - printf("\n"); + printf ("\n"); return 0; } diff --git a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c index 104cc19..6232e8d 100644 --- a/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c +++ b/iarm_set_powerstate/IARM_BUS_SetPowerStatus.c @@ -15,74 +15,98 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ +*/ #include #include +#include "libIBus.h" +#include "pwrMgr.h" -#include "powermanager_client.h" +const char *pPowerON = "ON"; +const char *pPowerOFF = "OFF"; +const char *pPowerStandby = "STANDBY"; +const char *pPowerLigtSleep = "LIGHTSLEEP"; +const char *pPowerDeepSleep = "DEEPSLEEP"; -const char* pPowerON = "ON"; -const char* pPowerOFF = "OFF"; -const char* pPowerStandby = "STANDBY"; -const char* pPowerLigtSleep = "LIGHTSLEEP"; -const char* pPowerDeepSleep = "DEEPSLEEP"; -void usage() +void usage () { - printf("\nUsage: 'SetPowerState [ON | STANDBY | LIGHTSLEEP | DEEPSLEEP | OFF ] with PowerManager plugin'\n"); - printf("\t\t ON -> Set to Active Mode\n"); - printf("\t\t STANDBY -> Set to Standby Mode\n"); - printf("\t\t LIGHTSLEEP -> Set to LIGHT Sleep Standby mode\n"); - printf("\t\t DEEPSLEEP -> Set to DEEP Sleep Standby mode\n"); - printf("\t\t OFF -> Set to OFF\n"); + printf ("\nUsage: 'iARM_SetPowerStatus [ON | STANDBY | LIGHTSLEEP | DEEPSLEEP | OFF ]'\n"); + printf ("\t\t ON -> Set to Active Mode\n"); + printf ("\t\t STANDBY -> Set to Standby Mode\n"); + printf ("\t\t LIGHTSLEEP -> Set to LIGHT Sleep Standby mode\n"); + printf ("\t\t DEEPSLEEP -> Set to DEEP Sleep Standby mode\n"); + printf ("\t\t OFF -> Set to OFF\n"); } +void setPowerMode(); /** * Test application to check whether the box is in standby or not. * This has been developed to resolve, XONE-4598 */ -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - PowerManager_PowerState_t powerstate = POWER_STATE_ON; + IARM_Bus_PWRMgr_SetPowerState_Param_t param; + + param.newState = IARM_BUS_PWRMGR_POWERSTATE_ON; - if (argc < 2) { + if (argc < 2) + { usage(); - } else if (strncasecmp(pPowerON, argv[1], strlen(pPowerON)) == 0) { - powerstate = POWER_STATE_ON; - printf("ON Request...\n"); - } else if (strncasecmp(pPowerStandby, argv[1], strlen(pPowerStandby)) == 0) { - powerstate = POWER_STATE_STANDBY; - printf("STANDBY Request...\n"); - } else if (strncasecmp(pPowerLigtSleep, argv[1], strlen(pPowerLigtSleep)) == 0) { - powerstate = POWER_STATE_STANDBY_LIGHT_SLEEP; - printf("Light Sleep Request...\n"); - } else if (strncasecmp(pPowerDeepSleep, argv[1], strlen(pPowerDeepSleep)) == 0) { - powerstate = POWER_STATE_STANDBY_DEEP_SLEEP; - printf("Deep Sleep Request...\n"); - } else if (strncasecmp(pPowerOFF, argv[1], strlen(pPowerOFF)) == 0) { - powerstate = POWER_STATE_OFF; - printf("OFF Request...\n"); - } else { + } + else if (strncasecmp(pPowerON, argv[1], strlen (pPowerON)) == 0) + { + printf ("ON Request...\n"); + param.newState = IARM_BUS_PWRMGR_POWERSTATE_ON; + } + else if (strncasecmp(pPowerStandby, argv[1], strlen (pPowerStandby)) == 0) + { + param.newState = IARM_BUS_PWRMGR_POWERSTATE_STANDBY; + printf ("STANDBY Request...\n"); + } + else if (strncasecmp(pPowerLigtSleep, argv[1], strlen (pPowerLigtSleep)) == 0) + { + param.newState = IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP; + printf ("Light Sleep Request...\n"); + } + else if (strncasecmp(pPowerDeepSleep, argv[1], strlen (pPowerDeepSleep)) == 0) + { + param.newState = IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP; + printf ("Deep Sleep Request...\n"); + } + else if (strncasecmp(pPowerOFF, argv[1], strlen (pPowerOFF)) == 0) + { + param.newState = IARM_BUS_PWRMGR_POWERSTATE_OFF; + printf ("OFF Request...\n"); + } + else + { usage(); } + - if ((POWER_STATE_ON == powerstate) - || (POWER_STATE_OFF == powerstate) - || (POWER_STATE_STANDBY == powerstate) - || (POWER_STATE_STANDBY_LIGHT_SLEEP == powerstate) - || (POWER_STATE_STANDBY_DEEP_SLEEP == powerstate)) { - - int keyCode = 0; + if ((param.newState == IARM_BUS_PWRMGR_POWERSTATE_ON) || + (param.newState == IARM_BUS_PWRMGR_POWERSTATE_OFF) || + (param.newState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) || + (param.newState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) || + (param.newState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + { + IARM_Bus_Init("iARMSetPower_tool"); + IARM_Bus_Connect(); /** Query current Power state */ - if (!PowerManager_SetPowerState(keyCode, powerstate, "sys_mon_tool[SetPowerState]")) { - printf("SetPowerState :: Success \n"); - } else { - printf("SetPowerState :: Failed \n"); + if (IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, + IARM_BUS_PWRMGR_API_SetPowerState, + (void *)¶m, + sizeof(param))) + { + printf ("SetPowerState :: Success \n"); } - - /* Dispose closes RPC conn, do not make any power manager calls after this */ - PowerManager_Dispose(); + else + { + printf ("SetPowerState :: Failed \n"); + } + IARM_Bus_Disconnect(); + IARM_Bus_Term(); } return 0; }