RDK Documentation (Open Sourced RDK Components)
CECCmd.cpp
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 hdmicec
23 * @{
24 * @defgroup tests
25 * @{
26 **/
27 
28 
29 #include <stdio.h>
30 #include <unistd.h>
31 #include "libIBus.h"
32 
33 #include "ccec/Messages.hpp"
34 #include "ccec/Assert.hpp"
35 #include "ccec/Connection.hpp"
36 #include "ccec/host/RDK.hpp"
37 #include "ccec/MessageEncoder.hpp"
38 #include "ccec/LibCCEC.hpp"
39 #include "ccec/drivers/iarmbus/CecIARMBusMgr.h"
40 
41 
42 //The tool is to convert the hex bytes in command line to CECFrame and send it out via IARM
43 //CECCmd <hex bytes>
44 //E.g. CECCmd 3F 82 10 00 /From Tuner To Broadcast, Active_Source
45 
46 int main(int argc, char *argv[])
47 {
48 
49  int i = 0;
50  IARM_Bus_Init("CECClient");
52 
54 
55  sleep(1);
56 
57  IARM_Result_t ret = IARM_RESULT_SUCCESS;
59  memset(&dataToSend, 0, sizeof(dataToSend));
60 
61  if (0 != argc)
62  {
63  printf("Count = %d \n Data : ", argc);
64 
65  for(i = 1; i < argc; i++)
66  {
67  printf("%x ", strtol(argv[i], NULL, 16));
68  dataToSend.data[i-1] = (int)strtol(argv[i], NULL, 16);
69  }
70 
71  dataToSend.length = (argc - 1);
72  ret = IARM_Bus_Call(IARM_BUS_CECMGR_NAME,IARM_BUS_CECMGR_API_Send,(void *)&dataToSend, sizeof(dataToSend));
73  if( IARM_RESULT_SUCCESS != ret)
74  {
75  printf("Iarm call failed retval = %d \n", ret);
76  }
77  }
78 
80 
82  IARM_Bus_Term();
83 }
84 //Note: To enable yocto build for the test app, please add the folder name 'tests' in the
85 //SUBDIRS & DIST_SUBDIRS parameters in /hdmicec/Makefile.am
86 
87 
88 /** @} */
89 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
LibCCEC::getInstance
static LibCCEC & getInstance(void)
This function is used to create the instance for CEC.
Definition: LibCCEC.cpp:61
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
LibCCEC::init
void init(const char *name=0)
This function is used to initialize CEC by starting the driver and doing host-specific initialization...
Definition: LibCCEC.cpp:84
IARM_BUS_CECMGR_NAME
#define IARM_BUS_CECMGR_NAME
Definition: CecIARMBusMgr.h:41
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_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_CECMgr_Send_Param_t
Definition: CecIARMBusMgr.h:71
LibCCEC::term
void term(void)
This function is used to stop CEC by terminating the connection and stoping the driver.
Definition: LibCCEC.cpp:111
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