36 #include <uuid/uuid.h>
42 #include <sys/syscall.h>
50 static IARM_Result_t _GetTRMDiagInfo(
void *arg);
54 #include "trm/MessageProcessor.h"
55 #include "trm/Activity.h"
56 #include "trm/JsonEncoder.h"
57 #include "trm/JsonDecoder.h"
58 #include "safec_lib.h"
61 static char responseMsg[MAX_PAYLOAD_LEN];
62 static pthread_mutex_t trmMgr_mutex;
68 pthread_mutex_lock(&trmMgr_mutex);
71 pthread_mutex_unlock(&trmMgr_mutex);
75 #define TRMMgrLock() TRMMgrLock_ t()
86 static IARM_Result_t _GetTRMDiagInfo(
void *arg)
91 DIAG_TRACE((
"Enter %s():%d \r\n" , __FUNCTION__, __LINE__));
96 uint32_t errCount = 0;
98 errno_t safec_rc = -1;
100 safec_rc = memset_s(responseMsg,
sizeof(responseMsg), 0,
sizeof(responseMsg));
103 if (NULL == infoParam)
105 DIAG_WARN((
"Error in %s : NULL Arguments Passed \r\n",__FUNCTION__));
106 return IARM_RESULT_INVALID_PARAM;
110 infoParam->numOfTuner = 0;
111 infoParam->numOfTRMError = 0;
112 infoParam->bufLen = 0;
113 infoParam->retCode = TRMMgr_ERR_NONE;
116 switch (infoParam->msgType)
118 case TRMMgr_MSG_TYPE_GET_NUM_IN_BAND_TUNERS:
120 DIAG_WARN((
"%s : GET_NUM_IN_BAND_TUNERS \r\n",__FUNCTION__));
122 infoParam->numOfTuner = NUM_OF_TUNERS;
124 infoParam->numOfTRMError = 6;
125 infoParam->retCode = TRMMgr_ERR_FAILED;
127 DIAG_TRACE((
"%s : Num of Tuner Supported = %d \r\n",__FUNCTION__,infoParam->numOfTuner));
131 case TRMMgr_MSG_TYPE_GET_CONN_DEVICE_IDS:
133 DIAG_WARN((
"%s : GET_CONN_DEVICE_IDS \r\n",__FUNCTION__));
138 infoParam->bufLen = length;
139 safec_rc = memcpy_s(infoParam->buf,
sizeof(infoParam->buf), responseMsg, length);
143 infoParam->retCode = TRMMgr_ERR_FAILED;
144 infoParam->bufLen = 0;
147 DIAG_TRACE((
"%s() Length of TRM Message is %d \r\n",__FUNCTION__,length));
151 infoParam->retCode = TRMMgr_ERR_FAILED;
152 DIAG_WARN((
"Failed to Get Diag Info for GET_CONN_DEVICE_IDS \r\n"));
157 case TRMMgr_MSG_TYPE_GET_TUNER_RESERVATION:
159 DIAG_WARN((
"%s : GET_TUNER_RESERVATION \r\n",__FUNCTION__));
164 infoParam->bufLen = length;
165 safec_rc = memcpy_s(infoParam->buf,
sizeof(infoParam->buf), responseMsg, length);
169 infoParam->retCode = TRMMgr_ERR_FAILED;
170 infoParam->bufLen = 0;
174 DIAG_TRACE((
"%s() Length of TRM Message is %d \r\n",__FUNCTION__,length));
178 infoParam->retCode = TRMMgr_ERR_FAILED;
179 DIAG_WARN((
"Failed to Get Diag Info for GET_TUNER_RESERVATION \r\n"));
184 case TRMMgr_MSG_TYPE_GET_NUM_TRM_ERRORS:
186 DIAG_WARN((
"%s : GET_NUM_TRM_ERRORS \r\n",__FUNCTION__));
190 infoParam->numOfTRMError = errCount;
191 DIAG_TRACE((
"%s() Num of TRM Errors are %d \r\n",__FUNCTION__,errCount));
195 infoParam->retCode = TRMMgr_ERR_FAILED;
196 DIAG_WARN((
"Failed to Get Diag Info for GET_CONNECTION_ERRORS \r\n"));
201 case TRMMgr_MSG_TYPE_GET_CONNECTION_ERRORS:
203 DIAG_WARN((
"%s : GET_CONNECTION_ERRORS \r\n",__FUNCTION__));
207 infoParam->bufLen = length;
208 safec_rc = memcpy_s(infoParam->buf,
sizeof(infoParam->buf), responseMsg, length);
212 infoParam->retCode = TRMMgr_ERR_FAILED;
213 infoParam->bufLen = 0;
217 DIAG_TRACE((
"%s() Length of TRM Message is %d \r\n",__FUNCTION__,length));
221 infoParam->retCode = TRMMgr_ERR_FAILED;
222 DIAG_WARN((
"Failed to Get Diag Info for GET_CONNECTION_ERRORS \r\n"));
228 case TRMMgr_MSG_TYPE_GET_TUNER_CONFLICTS:
230 DIAG_WARN((
"%s : GET_TUNER_CONFLICTS \r\n",__FUNCTION__));
234 infoParam->bufLen = length;
235 safec_rc = memcpy_s(infoParam->buf,
sizeof(infoParam->buf), responseMsg, length);
239 infoParam->retCode = TRMMgr_ERR_FAILED;
240 infoParam->bufLen = 0;
244 DIAG_TRACE((
"%s() Length of TRM Message is %d \r\n",__FUNCTION__,length));
249 infoParam->retCode = TRMMgr_ERR_FAILED;
250 DIAG_WARN((
"Failed to Get Diag Info for GET_TUNER_CONFLICTS \r\n"));
255 case TRMMgr_MSG_TYPE_GET_TRM_VERSION:
257 DIAG_WARN((
"%s : GET_TRM_VERSION \r\n",__FUNCTION__));
263 infoParam->bufLen = length;
264 safec_rc = memcpy_s(infoParam->buf,
sizeof(infoParam->buf), responseMsg, length);
268 infoParam->retCode = TRMMgr_ERR_FAILED;
269 infoParam->bufLen = 0;
272 DIAG_TRACE((
"%s() Length of TRM Message is %d \r\n",__FUNCTION__,length));
276 DIAG_WARN((
"%s() Failed to Get Diag Info for GET_TRM_VERSION \r\n",__FUNCTION__));
283 DIAG_WARN((
"%s Error: Diag Info not supported \r\n",__FUNCTION__));
284 infoParam->retCode = TRMMgr_ERR_INVALID_PARAM;
289 DIAG_TRACE((
"Exit %s():%d with %s \r\n" , __FUNCTION__, __LINE__,ret?
"sucess":
"failure"));
291 return IARM_RESULT_SUCCESS;
301 int main(
int argc,
char *argv[])
305 errno_t safec_rc = -1;
308 setvbuf(stdout, NULL, _IOLBF, 0);
311 DIAG_TRACE((
"TRM Manager Enter %s():%d \r\n" , __FUNCTION__, __LINE__));
320 pthread_mutex_init(&trmMgr_mutex, NULL);
326 safec_rc = memset_s(responseMsg,
sizeof(responseMsg), 0 ,
sizeof(responseMsg));
333 DIAG_WARN((
"HeartBeat : TRM Manager !!\r\n"));
340 DIAG_TRACE((
"TRM Manager Exit %s():%d \r\n" , __FUNCTION__, __LINE__));