RDK Documentation (Open Sourced RDK Components)
pwrMgrMain.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup iarmmgrs
24 * @{
25 * @defgroup power
26 * @{
27 **/
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 #include <stdio.h>
34 #include "plat_power.h"
35 #ifdef __cplusplus
36 }
37 #endif
38 #include <sys/types.h>
39 #include <unistd.h>
40 #include "pwrMgr.h"
41 #include "pwrlogger.h"
42 #include "pwrMgrInternal.h"
43 #ifdef ENABLE_SD_NOTIFY
44 #include <systemd/sd-daemon.h>
45 #endif
46 
47 #ifdef RDK_LOGGER_ENABLED
48 
49 int b_rdk_logger_enabled = 0;
50 
51 void logCallback(const char *buff)
52 {
53  LOG("%s",buff);
54 }
55 #endif
56 int main(int argc, char *argv[])
57 {
58  const char* debugConfigFile = NULL;
59  int itr=0;
60 
61  while (itr < argc)
62  {
63  if(strcmp(argv[itr],"--debugconfig")==0)
64  {
65  itr++;
66  if (itr < argc)
67  {
68  debugConfigFile = argv[itr];
69  }
70  else
71  {
72  break;
73  }
74  }
75  itr++;
76  }
77 
78 #ifdef RDK_LOGGER_ENABLED
79 
80  if(rdk_logger_init(debugConfigFile) == 0) b_rdk_logger_enabled = 1;
81  IARM_Bus_RegisterForLog(logCallback);
82 
83 #endif
84 
85  PWRMgr_Start(argc, argv);
86  #ifdef ENABLE_SD_NOTIFY
87  sd_notifyf(0, "READY=1\n"
88  "STATUS=PWRMgr is Successfully Initialized\n"
89  "MAINPID=%lu", (unsigned long) getpid());
90  #endif
91  PWRMgr_Loop();
92  PWRMgr_Stop();
93  return 0;
94 }
95 
96 
97 
98 
99 /** @} */
100 /** @} */
pwrMgrInternal.h
pwrMgr.h
IARM-Bus Power Manager Public API.
rdk_logger_init
rdk_Error rdk_logger_init(const char *debugConfigFile)
Initialize the logger. Sets up the environment variable storage by parsing debug configuration file t...
Definition: rdk_logger_init.c:57