RDK Documentation (Open Sourced RDK Components)
test_mfr_client.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 * @defgroup iarmmgrs
23 * @{
24 * @defgroup mfr
25 * @{
26 **/
27 
28 
29 #include "libIBus.h"
30 #include "mfrMgr.h"
31 #include <stdio.h>
32 #include <malloc.h>
33 #include "libIARMCore.h"
34 #include <stdlib.h>
35 #include <unistd.h>
36 #include <string.h>
37 #include "safec_lib.h"
38 
39 int main()
40 {
42  IARM_Result_t ret;
43  char *pTmpStr;
44  int len;
45  printf("mfrClient Entering %d\r\n", getpid());
46  IARM_Bus_Init("mfrClient");
47  int i = 0;
48  errno_t safec_rc = -1;
50 
51  do{
52  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
53 
54  param->type = mfrSERIALIZED_TYPE_MANUFACTURER;
55 
58 
59  if(ret != IARM_RESULT_SUCCESS)
60  {
61  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_MANUFACTURER",ret);
62  }
63  else
64  {
65  len = param->bufLen + 1;
66  pTmpStr = (char *)malloc(len);
67  safec_rc = memset_s(pTmpStr, len, 0, len);
68  ERR_CHK(safec_rc);
69  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
70  if(safec_rc != EOK)
71  {
72  ERR_CHK(safec_rc);
73  free(pTmpStr);
74  continue;
75  }
76 
77  printf("%s returned (%d)::%s ","mfrSERIALIZED_TYPE_MANUFACTURER",ret, pTmpStr);
78  free(pTmpStr);
79  }
80  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
81 
82  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
83  param->type = mfrSERIALIZED_TYPE_MANUFACTUREROUI;
84 
87 
88  if(ret != IARM_RESULT_SUCCESS)
89  {
90  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_MANUFACTUREROUI",ret);
91  }
92  else
93  {
94  len = param->bufLen + 1;
95  pTmpStr = (char *)malloc(len);
96  safec_rc = memset_s(pTmpStr, len, 0, len);
97  ERR_CHK(safec_rc);
98  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
99  if(safec_rc != EOK)
100  {
101  ERR_CHK(safec_rc);
102  free(pTmpStr);
103  continue;
104  }
105 
106  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_MANUFACTUREROUI",ret,pTmpStr);
107  free(pTmpStr);
108  }
109  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
110  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
111  param->type = mfrSERIALIZED_TYPE_MODELNAME;
112 
115 
116  if(ret != IARM_RESULT_SUCCESS)
117  {
118  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_MODELNAME",ret);
119  }
120  else
121  {
122  len = param->bufLen + 1;
123  pTmpStr = (char *)malloc(len);
124  safec_rc = memset_s(pTmpStr, len, 0, len);
125  ERR_CHK(safec_rc);
126  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
127  if(safec_rc != EOK)
128  {
129  ERR_CHK(safec_rc);
130  free(pTmpStr);
131  continue;
132  }
133 
134  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_MODELNAME",ret,pTmpStr);
135  free(pTmpStr);
136  }
137  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
138 
139  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
140  param->type = mfrSERIALIZED_TYPE_DESCRIPTION;
141 
144 
145  if(ret != IARM_RESULT_SUCCESS)
146  {
147  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_DESCRIPTION",ret);
148  }
149  else
150  {
151  len = param->bufLen + 1;
152  pTmpStr = (char *)malloc(len);
153  safec_rc = memset_s(pTmpStr, len, 0, len);
154  ERR_CHK(safec_rc);
155  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
156  if(safec_rc != EOK)
157  {
158  ERR_CHK(safec_rc);
159  free(pTmpStr);
160  continue;
161  }
162 
163  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_DESCRIPTION",ret,pTmpStr);
164  free(pTmpStr);
165  }
166  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
167  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
168  param->type = mfrSERIALIZED_TYPE_PRODUCTCLASS;
169 
172 
173  if(ret != IARM_RESULT_SUCCESS)
174  {
175  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_PRODUCTCLASS",ret);
176  }
177  else
178  {
179  len = param->bufLen + 1;
180  pTmpStr = (char *)malloc(len);
181  safec_rc = memset_s(pTmpStr, len, 0, len);
182  ERR_CHK(safec_rc);
183  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
184  if(safec_rc != EOK)
185  {
186  ERR_CHK(safec_rc);
187  free(pTmpStr);
188  continue;
189  }
190 
191  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_PRODUCTCLASS",ret,pTmpStr);
192  free(pTmpStr);
193  }
194  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
195  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
196  param->type = mfrSERIALIZED_TYPE_SERIALNUMBER;
197 
200 
201  if(ret != IARM_RESULT_SUCCESS)
202  {
203  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_SERIALNUMBER",ret);
204  }
205  else
206  {
207  len = param->bufLen + 1;
208  pTmpStr = (char *)malloc(len);
209  safec_rc = memset_s(pTmpStr, len, 0, len);
210  ERR_CHK(safec_rc);
211  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
212  if(safec_rc != EOK)
213  {
214  ERR_CHK(safec_rc);
215  free(pTmpStr);
216  continue;
217  }
218 
219  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_SERIALNUMBER",ret,pTmpStr);
220  free(pTmpStr);
221  }
222 
223  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
224  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
225  param->type = mfrSERIALIZED_TYPE_HARDWAREVERSION;
226 
229 
230  if(ret != IARM_RESULT_SUCCESS)
231  {
232  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_HARDWAREVERSION",ret);
233  }
234  else
235  {
236  len = param->bufLen + 1;
237  pTmpStr = (char *)malloc(len);
238  safec_rc = memset_s(pTmpStr, len, 0, len);
239  ERR_CHK(safec_rc);
240  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
241  if(safec_rc != EOK)
242  {
243  ERR_CHK(safec_rc);
244  free(pTmpStr);
245  continue;
246  }
247 
248  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_HARDWAREVERSION",ret,pTmpStr);
249  free(pTmpStr);
250  }
251  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
252  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
253  param->type = mfrSERIALIZED_TYPE_SOFTWAREVERSION;
254 
257 
258  if(ret != IARM_RESULT_SUCCESS)
259  {
260  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_SOFTWAREVERSION",ret);
261  }
262  else
263  {
264  len = param->bufLen + 1;
265  pTmpStr = (char *)malloc(len);
266  safec_rc = memset_s(pTmpStr, len, 0, len);
267  ERR_CHK(safec_rc);
268  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
269  if(safec_rc != EOK)
270  {
271  ERR_CHK(safec_rc);
272  free(pTmpStr);
273  continue;
274  }
275 
276  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_SOFTWAREVERSION",ret,pTmpStr);
277  free(pTmpStr);
278  }
279  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
280  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
281  param->type = mfrSERIALIZED_TYPE_PROVISIONINGCODE;
282 
285 
286  if(ret != IARM_RESULT_SUCCESS)
287  {
288  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_PROVISIONINGCODE",ret);
289  }
290  else
291  {
292  len = param->bufLen + 1;
293  pTmpStr = (char *)malloc(len);
294  safec_rc = memset_s(pTmpStr, len, 0, len);
295  ERR_CHK(safec_rc);
296  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
297  if(safec_rc != EOK)
298  {
299  ERR_CHK(safec_rc);
300  free(pTmpStr);
301  continue;
302  }
303 
304  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_PROVISIONINGCODE",ret,pTmpStr);
305  free(pTmpStr);
306  }
307  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
308  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
309  param->type = mfrSERIALIZED_TYPE_FIRSTUSEDATE;
310 
313 
314  if(ret != IARM_RESULT_SUCCESS)
315  {
316  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_FIRSTUSEDATE",ret);
317  }
318  else
319  {
320  len = param->bufLen + 1;
321  pTmpStr = (char *)malloc(len);
322  safec_rc = memset_s(pTmpStr, len, 0, len);
323  ERR_CHK(safec_rc);
324  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
325  if(safec_rc != EOK)
326  {
327  ERR_CHK(safec_rc);
328  free(pTmpStr);
329  continue;
330  }
331 
332  printf("%s returned (%d)::%s","mfrSERIALIZED_TYPE_FIRSTUSEDATE",ret, pTmpStr);
333  free(pTmpStr);
334  }
335  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
336  IARM_Malloc(IARM_MEMTYPE_PROCESSLOCAL, sizeof(IARM_Bus_MFRLib_GetSerializedData_Param_t), (void**)&param);
337  param->type = mfrSERIALIZED_TYPE_PDRIVERSION;
338 
341 
342  if(ret != IARM_RESULT_SUCCESS)
343  {
344  printf("Call failed for %s: error code:%d\n","mfrSERIALIZED_TYPE_PDRIVERSION",ret);
345  }
346  else
347  {
348  len = param->bufLen + 1;
349  pTmpStr = (char *)malloc(len);
350  safec_rc = memset_s(pTmpStr, len, 0, len);
351  ERR_CHK(safec_rc);
352  safec_rc = memcpy_s(pTmpStr, len, param->buffer, param->bufLen);
353  if(safec_rc != EOK)
354  {
355  ERR_CHK(safec_rc);
356  free(pTmpStr);
357  continue;
358  }
359 
360  printf("%s returned (%d)::[%s]\r\n","mfrSERIALIZED_TYPE_PDRIVERSION",ret, pTmpStr);
361  free(pTmpStr);
362  }
363  IARM_Free(IARM_MEMTYPE_PROCESSLOCAL,param);
364 
365  }while(0);
366 
368  IARM_Bus_Term();
369  printf("Client Exiting\r\n");
370 }
371 
372 
373 /** @} */
374 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
libIBus.h
RDK IARM-Bus API Declarations.
IARM_BUS_MFRLIB_API_GetSerializedData
#define IARM_BUS_MFRLIB_API_GetSerializedData
Definition: mfrMgr.h:100
IARM_BUS_MFRLIB_NAME
#define IARM_BUS_MFRLIB_NAME
Definition: mfrMgr.h:98
_IARM_Bus_MFRLib_GetSerializedData_Param_t
Definition: mfrMgr.h:118
_IARM_Bus_MFRLib_GetSerializedData_Param_t::type
mfrSerializedType_t type
Definition: mfrMgr.h:119
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38