RDK Documentation (Open Sourced RDK Components)
test_writeImage.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 <stdio.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include "mfrMgr.h"
35 #include "safec_lib.h"
36 
37 #define SAFEC_ERR_CHECK(safec_rc) if(safec_rc != EOK) {\
38 ERR_CHK(safec_rc);\
39 goto Error; \
40 }
41 
42 
43 IARM_Result_t _callback(void *arg)
44 {
46  printf("Result :: %s \n",param->cbData);
47  return (IARM_Result_t)0;
48 }
49 
50 int main(int argc, char** argv)
51 {
52  int i = 0;
54  errno_t safec_rc = -1;
55  if(argc < 3)
56  {
57  printf("usage is : ./test_writeImage <image_path> <signed_image_name>\n");
58  return -1;
59  }
60 
61  printf("Client Entering\r\n");
62  IARM_Bus_Init("WriteImageTest");
64 
65 
66  safec_rc = strcpy_s(param.name, sizeof(param.name), argv[2]);
67  SAFEC_ERR_CHECK(safec_rc);
68 
69  safec_rc = strcpy_s(param.path, sizeof(param.path), argv[1]);
70  SAFEC_ERR_CHECK(safec_rc);
71 
72  safec_rc = strcpy_s(param.callerModuleName, sizeof(param.callerModuleName), "WriteImageTest");
73  SAFEC_ERR_CHECK(safec_rc);
74 
75  param.interval = 2;
76  param.type = mfrIMAGE_TYPE_CDL;
77  safec_rc = strcpy_s(param.cbData, sizeof(param.cbData), "Test Success");
78  SAFEC_ERR_CHECK(safec_rc);
79 
80  if(IARM_RESULT_SUCCESS == IARM_Bus_RegisterCall(IARM_BUS_MFRLIB_COMMON_API_WriteImageCb,_callback))
81  {
82  printf("Register Call Success...\n");
83  }
84  else
85  {
86  printf("Problem with registering callback \n");
87  }
88  if(IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_MFRLIB_NAME,IARM_BUS_MFRLIB_API_WriteImage,(void *)&param,sizeof(param)))
89  {
90  printf("IARM_Bus_Call Success...\n");
91  }
92  else
93  {
94  printf("Problem with IARM_Bus_Call \n");
95  }
96 
97  while(getchar()!='x') {
98  sleep(1);
99  }
100 
101 Error:
103  IARM_Bus_Term();
104  printf("Client Exiting\r\n");
105 }
106 
107 
108 
109 /** @} */
110 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
IARM_BUS_MFRLIB_API_WriteImage
#define IARM_BUS_MFRLIB_API_WriteImage
Definition: mfrMgr.h:102
_IARM_Bus_MFRLib_CommonAPI_WriteImageCb_Param_t::cbData
char cbData[255]
Definition: mfrMgr.h:184
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_MFRLib_WriteImage_Param_t::cbData
char cbData[255]
Definition: mfrMgr.h:130
IARM_BUS_MFRLIB_COMMON_API_WriteImageCb
#define IARM_BUS_MFRLIB_COMMON_API_WriteImageCb
Definition: mfrMgr.h:115
IARM_Bus_RegisterCall
IARM_Result_t IARM_Bus_RegisterCall(const char *methodName, IARM_BusCall_t handler)
This API is used to register an RPC method that can be invoked by other applications.
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...
_IARM_Bus_MFRLib_WriteImage_Param_t::callerModuleName
char callerModuleName[255]
Definition: mfrMgr.h:128
_IARM_Bus_MFRLib_CommonAPI_WriteImageCb_Param_t
Definition: mfrMgr.h:182
libIBus.h
RDK IARM-Bus API Declarations.
_IARM_Bus_MFRLib_WriteImage_Param_t
Definition: mfrMgr.h:129
_IARM_Bus_MFRLib_WriteImage_Param_t::interval
int interval
Definition: mfrMgr.h:133
_IARM_Bus_MFRLib_WriteImage_Param_t::path
char path[255]
Definition: mfrMgr.h:131
IARM_BUS_MFRLIB_NAME
#define IARM_BUS_MFRLIB_NAME
Definition: mfrMgr.h:98
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_MFRLib_WriteImage_Param_t::name
char name[255]
Definition: mfrMgr.h:130
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
_IARM_Bus_MFRLib_WriteImage_Param_t::type
mfrImageType_t type
Definition: mfrMgr.h:132