RDK Resources

[*ASP Wiki*]

Code Management Facility

Code Releases

RDK Forums

[RDK Conferences]

RDK Support

Archives

Papers & Presentations Archive

In the News!

Skip to end of metadata
Go to start of metadata

This page serves as a reference and source to add a New Parameter to test component's data model

In the page Adding a New Test Component a new test component was created, with parameter "TestSampleParamUlong" of ulong type. The purpose of this page is to add a new parameter "TestSampleParam" of string type to the "ccsp-testcomponent".  This parameter should be writable under "Device.TestComponent." object. We will take the example of Raspberry Pi device as reference to demonstrate the involved steps.

System Requirements

  • Raspberry Pi device
    Exercise will be executed on the Raspberry Pi device.

Steps for adding a new parameter

  1. In "TestComponent.xml" file ( build-raspberrypi-rdk-broadband/tmp/work/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/ccsp-testcomponent/1.0-r0/CcspTestComponent/scripts) and Add "TestSampleParam" writable parameter under "TestComponent" base object as below:

            <parameter> 
    		  <name>TestSampleParam</name>  
    		  <type>string(64)</type>	          
    		  <syntax>string</syntax> 
    		  <writable>true</writable>                             
            </parameter> 
  2. In "cosa_apis_testcomponentplugin.c" file (build-raspberrypi-rdk-broadband/tmp/work/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/ccsp-testcomponent/1.0-r0/CcspTestComponent/source/TestComponent)  add PSM set/get functionality for TestComponent parameter.

    The component Persistent Storage Manager(PSM) provides software interfaces and abstractions to write/read variables stored in persistent storage and read factory config variables.

    As per TR181 specification we need to derive the get/set functionality in below API's only.
    Which is configured in "TestComponent.xml" file,

    - TestComponent_GetParamStringValue
    - TestComponent_SetParamStringValue

    These two functions are defined in "cosa_apis_testcomponentplugin.c" file.


    Add the below code in "TestComponent_GetParamStringValue" API,

    TestComponent_GetParamStringValue API
    	if( AnscEqualString(pParamName, "TestSampleParam", TRUE)) 
    	{ 
    	    char* strValue = NULL;
    	    PSM_Get_Record_Value2(bus_handle,g_Subsystem, "sampletestcomponent_string", NULL, &strValue);
    		if (strValue != NULL)
    	    {
    			strcpy(pValue,strValue);
    			((CCSP_MESSAGE_BUS_INFO *)bus_handle)->freefunc(strValue);
    	    	return TRUE;  
    	    }
            else
    	    {
    	    	return FALSE;
    	    }
        }


    Add the below code in "TestComponent_SetParamStringValue" API,

    TestComponent_SetParamStringValue
    	if( AnscEqualString(pParamName, "TestSampleParam", TRUE)) 
    	{ 
    		PSM_Set_Record_Value2(bus_handle,g_Subsystem,"sampletestcomponent_string", ccsp_string, pString);
    		return TRUE; 
    	} 
  3. In "cosa_apis_testcomponentplugin.c" file, add the header file "ccsp_psm_helper.h":

    #include "ccsp_psm_helper.h"

Steps to Build the Test Component

Setup the build environment

In the <workspace dir>,  

source meta-cmf-raspberrypi/setup-environment
Select option raspberrypi-rdk-broadband.conf (option 2).

Bitbake the Test Component

Compile : bitbake -f ccsp-testcomponent -c compile
Package : bitbake ccsp-testcomponent

Copy the Compiled Binaries to Raspberry Pi device

Binary and XML file of test component will be present in: build-raspberrypi-rdk-broadband/tmp/work/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/ccsp-testcomponent/1.0-r0/image/usr/bin location

Copy test_component (Binary of ccsp-testcomponent) and TestComponent.xml to /tmp/ directory of Raspberry Pi device.

Steps to add the new parameter to system_defaults file

  1. In the Raspberry Pi device, go to path "/etc/utopia". In the file system_defaults, add the parameter "sampletestcomponent_string" associated with the value,
    Eg: $sampletestcomponent_string=Welcome
  2. Now got "/nvram" path of the device and delete the file bbhm_bak_cfg.xml, bbhm_cur_cfg.xml and syscfg.db.
  3. Reboot the device.

Steps to Run the Test Component 

Go to /tmp/ directory of Raspberry Pi 3 and start the ccsp-testcomponent
./test_component -subsys eRT.

You can check the status of the process by doing  ps in the RPi device.

Validate the parameter

1) Query the "TestSampleParam" parameter by using below command,

dmcli eRT getv Device.TestComponent.TestSampleParam

Expected Output
CR component name is: eRT.com.cisco.spvtg.ccsp.CR 
subsystem_prefix eRT. 
getv from/to component(eRT.com.cisco.spvtg.ccsp.testcomponent): Device.TestComponent.TestSampleParam 
Execution succeed. 
Parameter    1 name: Device.TestComponent.TestSampleParam 
       type:     string,    value: Welcome


2) Change the "TestSampleParam" parameter value by using below command,

dmcli eRT setv Device.TestComponent.TestSampleParam string "Hello World"

Expected Output
CR component name is: eRT.com.cisco.spvtg.ccsp.CR 
subsystem_prefix eRT. 
setv from/to component(eRT.com.cisco.spvtg.ccsp.testcomponent): Device.TestComponent.TestSampleParam
Execution succeed.


3) Now verify the value by this command,

dmcli eRT getv Device.TestComponent.TestSampleParam

Expected Output
CR component name is: eRT.com.cisco.spvtg.ccsp.CR 
subsystem_prefix eRT. 
getv from/to component(eRT.com.cisco.spvtg.ccsp.testcomponent): Device.TestComponent.TestSampleParam 
Execution succeed. 
Parameter    1 name: Device.TestComponent.TestSampleParam 
       type:     string,    value: Hello World


  • No labels