-
Notifications
You must be signed in to change notification settings - Fork 2
RDKEMW-14517: Use IARM for PowerManager clients #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: topic/support_2.16.9_Test
Are you sure you want to change the base?
Changes from all commits
6f1190f
27d5fbc
3cea2ae
8a11efc
9501b49
d76aed1
4174411
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,133 +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 <stdio.h> | ||
| #include <fcntl.h> | ||
| #include <errno.h> | ||
| #include <stdint.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <unistd.h> | ||
|
|
||
| // 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 <string.h> | ||
| #include <stdlib.h> | ||
| #include "libIBus.h" | ||
| #include "pwrMgr.h" | ||
|
|
||
| #include "power_controller.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') { | ||
| uint32_t res = 0; | ||
| PowerController_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; | ||
|
|
||
| PowerController_Init(); | ||
|
|
||
| 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 */ | ||
| res = PowerController_GetPowerState(&curState, &previousState); | ||
|
|
||
| if (POWER_CONTROLLER_ERROR_NONE == res) { | ||
|
|
||
| if (POWER_STATE_OFF == curState) { | ||
| printf("OFF\n"); | ||
| } else if (POWER_STATE_STANDBY == curState) { | ||
| printf("STANDBY\n"); | ||
| } else if (POWER_STATE_ON == curState) { | ||
| printf("ON\n"); | ||
| } else if (POWER_STATE_STANDBY_LIGHT_SLEEP == curState) { | ||
| printf("LIGHTSLEEP\n"); | ||
| } else if (POWER_STATE_STANDBY_DEEP_SLEEP == curState) { | ||
| printf("DEEPSLEEP\n"); | ||
| } else { | ||
| printf("Unknown\n"); | ||
| } | ||
| } else if (POWER_CONTROLLER_ERROR_UNAVAILABLE == res) { | ||
| printf("Error :: PowerManager plugin unavailable\n"); | ||
| } else { | ||
| printf("Error :: Unknown\n"); | ||
| if (IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, | ||
| IARM_BUS_PWRMGR_API_GetPowerState, | ||
| (void *)¶m, | ||
| sizeof(param))) | ||
|
Comment on lines
+80
to
+89
|
||
| { | ||
|
|
||
| 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 */ | ||
| PowerController_Term(); | ||
|
|
||
| } 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 (IARM_BUS_PWRMGR_POWERSTATE_OFF == pwrSettings.powerState) { | ||
| printf("OFF"); | ||
| } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY == pwrSettings.powerState) { | ||
| printf("STANDBY"); | ||
| } else if (IARM_BUS_PWRMGR_POWERSTATE_ON == pwrSettings.powerState) { | ||
| printf("ON"); | ||
| } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP == pwrSettings.powerState) { | ||
| printf("LIGHTSLEEP"); | ||
| } else if (IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP == pwrSettings.powerState) { | ||
| printf("DEEPSLEEP"); | ||
| } else { | ||
| printf("Unknown Power state"); | ||
| } | ||
| } else { | ||
| printf("Error in reading PWRMgr settings File"); | ||
| if (ret > 0) | ||
| { | ||
| if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_OFF) | ||
| printf ("OFF"); | ||
| else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY) | ||
| printf ("STANDBY"); | ||
| else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||
| printf ("ON"); | ||
| else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP) | ||
| printf ("LIGHTSLEEP"); | ||
| else if (pwrSettings.powerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) | ||
| printf ("DEEPSLEEP"); | ||
| else | ||
| printf ("Unknown Power state"); | ||
| } | ||
|
|
||
| printf("\n"); | ||
| else | ||
| printf ("Error in reading PWRMgr settings File"); | ||
| } | ||
| printf ("\n"); | ||
| return 0; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <errno.h>is unused in this file. Please remove it to keep includes minimal and avoid suggesting errno-based error handling that isn’t implemented.