Giter Club home page Giter Club logo

rbus's Introduction

Rbus

RDK Bus (RBus) is a lightweight, fast and efficient bus messaging system. It allows interprocess communication (IPC) and remote procedure call (RPC) between multiple process running on a hardware device. It supports the creation and use of a data model, which is a hierarchical tree of named objects with properties, events, and methods.

Desktop Build (Linux)

export RBUS_ROOT=${HOME}/rbus
export RBUS_INSTALL_DIR=${RBUS_ROOT}/install
export RBUS_BRANCH=2105_sprint
mkdir -p $RBUS_INSTALL_DIR
cd $RBUS_ROOT

Build rbus and dependencies

git clone https://github.com/rdkcentral/rbus
cmake -Hrbus -Bbuild/rbus -DCMAKE_INSTALL_PREFIX=${RBUS_INSTALL_DIR}/usr -DBUILD_FOR_DESKTOP=ON -DCMAKE_BUILD_TYPE=Debug
make -C build/rbus && make -C build/rbus install

Run Rbus Apps

Setup 3 terminals:

export RBUS_ROOT=${HOME}/rbus && \
export RBUS_INSTALL_DIR=${RBUS_ROOT}/install && \
export PATH=${RBUS_INSTALL_DIR}/usr/bin:${PATH} && \
export LD_LIBRARY_PATH=${RBUS_INSTALL_DIR}/usr/lib:${LD_LIBRARY_PATH}

Start rtrouted

In terminal 1, run rtrouted. This deamon must be running for rbus apps to communicate.

rtrouted -f -l DEBUG

Note that if at any point in the future you want to restart rtrouted you can run this.

killall -9 rtrouted; rm -fr /tmp/rtroute*; rtrouted -f -l DEBUG

Run a sample app

Note that all sample apps come with both a provider and a consumer app. The provider must be started first and then quickly, before the provider times out, the consumer should be started.

In terminal 2, run the sample provider.

rbusSampleProvider

In terminal 3, run the sample consumer.

rbusSampleConsumer

Here is the list of all samples:

  1. rbusSampleProvider / rbusSampleConsumer
  2. rbusEventProvider / rbusEventConsumer
  3. rbusEventProvider / rbusEventConsumer
  4. rbusGeneralEventProvider / rbusGeneralEventConsumer
  5. rbusValueChangeProvider / rbusValueChangeConsumer
  6. rbusMethodProvider / rbusMethodConsumer
  7. rbusTableProvider / rbusTableConsumer

Playing with rbuscli

The rbuscli utility app allows the user to register a data model and interact with it, exercising the rbus api both from a provider and consumer perspective.

In terminal 2, run rbuscli

rbuscli -i

Register a property as a provider would

    > reg prop A.B

In terminal 3, run rbuscli and set/get the property, registered by the first rbuscli, as a consumer would.

rbuscli -i
    > set A.B string "hello"
    > get A.B

In terminal 3, enable event logging and subscribe to a value-change event.

    > log events
    > sub A.B

In terminal 2, change the value so that a value-change event is generated.

    > set A.B string "hello again"

In terminal 3, logs should appear showing a value change event was received.

There's a lot more you can do with rbuscli. Enter help to get a full list of commands. When your done, enter quit to exit rbuscli.

Run the test harness

In terminal 2, run the test provider

rbusTestProvider

In terminal 3, run the test consumer

rbusTestConsumer -a

The test takes about 5-10 minutes. Check for errors in the summary table at the end. To get more details for any error, rerun the test passing -l debug to both the provider and consumer.

Run with valgrind

Valgrind is an important tool to help find both memory leaks and memory related bugs.

In terminal 2, run a sample provider using valgrind.

valgrind --leak-check=full --show-leak-kinds=all rbusSampleProvider

In terminal 3, run a sample consumer using valgrind.

valgrind --leak-check=full --show-leak-kinds=all rbusSampleConsumer

rbus's People

Contributors

dm097 avatar dshett549 avatar gladish avatar gururaajar avatar karuna2git avatar mdalal705 avatar netajipanigrahi avatar paperclipstudio avatar pganna856 avatar sheabot avatar tonypickconsultred avatar

Watchers

 avatar  avatar  avatar

rbus's Issues

Stable wire protocol support

Teams need access to non-C libraries to develop modern software. Based on conversations from the RDK Summit the protocol has been intentionally undocumented to prevent any other library offering support for the protocol.

That doesn't work for many modern languages that either cannot, or should not include c code.

We need a formal wire protocol definition so that the community can maintain the libraries and infrastructure needed.

Why does providing multiple language bindings not work?

Multiple language bindings are often based on a single .so library that is wrapped with glue code, but requires the external dependency. This causes problems for languages like go that need to be independent of .so files for portability reasons.

Logging support in rbus with Tags

Add a log file for rbus transaction in /rdklogs/logs directory. eg: /rdklogs/logs/RBUS.txt.0

Every component that registers with r-bus should have a TAG.
A group of component can have same TAG.

for eg: wanmanager, dslagaent, ethagent, pppmanager, dhcpmanager can have tag - WAN

and all the GET/SET/Publish should be logged in to /rdklogs/logs/RBUS.txt.0 along with the tag.

when developer does,

`$ cat /rdklogs/logs/RBUS.txt.0       # dev should see all bus tx in the device (Local & Remote)`

`$ cat /rdklogs/logs/RBUS.txt.0 | grep "<TAG-NAME>"          # dev should be all rbus tx within the tag`

#eg: 
$ cat /rdklogs/logs/RBUS.txt.0 | grep "WAN"       # dev can see communication between all wan components.

Tags are similar to log level (INFO, DEBUG, etc ) except they are used to group components.
adding common tags between related component can help debug better in areas such as wan, wifi, gatewaymgr, lan

Log file should be included in log rotation and backing up mechanism.
Log file can be very helpful in triaging/debugging customer issues & to narrow down which component has issue instead of looking at separate component specific files.

[COVERITY] - [UNINITALIZED] - rbusBuffer_WriteDateTimeTLV

void rbusBuffer_WriteDateTimeTLV(rbusBuffer_t buff, rbusDateTime_t const* tv)
233{
1. var_decl: Declaring variable temp without initializer.
234 rbusDateTime_t temp;
2. Condition NULL == tv, taking false branch.
235 VERIFY_NULL(tv);
236 temp.m_time.tm_sec = rbusHostToLittleInt32(tv->m_time.tm_sec);
237 temp.m_time.tm_min = rbusHostToLittleInt32(tv->m_time.tm_min);
238 temp.m_time.tm_hour = rbusHostToLittleInt32(tv->m_time.tm_hour);
239 temp.m_time.tm_mday = rbusHostToLittleInt32(tv->m_time.tm_mday);
240 temp.m_time.tm_mon = rbusHostToLittleInt32(tv->m_time.tm_mon);
241 temp.m_time.tm_year = rbusHostToLittleInt32(tv->m_time.tm_year);
242 temp.m_time.tm_wday = rbusHostToLittleInt32(tv->m_time.tm_wday);
243 temp.m_time.tm_yday = rbusHostToLittleInt32(tv->m_time.tm_yday);
244 temp.m_time.tm_isdst = rbusHostToLittleInt32(tv->m_time.tm_isdst);
245 temp.m_tz.m_tzhour = rbusHostToLittleInt32(tv->m_tz.m_tzhour);
246 temp.m_tz.m_tzmin = rbusHostToLittleInt32(tv->m_tz.m_tzmin);
3. Condition __uint32_identity(tv->m_tz.m_isWest), taking true branch.
247 temp.m_tz.m_isWest = rbusHostToLittleInt32(tv->m_tz.m_isWest);

CID 282224 (#1 of 1): Uninitialized scalar variable (UNINIT)
4. uninit_use_in_call: Using uninitialized value temp. Field temp.m_time.tm_gmtoff is uninitialized when calling rbusBuffer_WriteTypeLengthValue. [show details]
248 rbusBuffer_WriteTypeLengthValue(buff, RBUS_DATETIME, sizeof(temp), &temp);
249}

[COVERITY] - [LEAK] _event_callback_handler

int _event_callback_handler (char const* objectName, char const* eventName, rbusMessage message, void* userData)
1151{
1152    rbusEventSubscription_t* subscription = NULL;
1153    rbusEventHandler_t handler = NULL;
1154    rbusEvent_t event = {0};
1155    rbusFilter_t filter = NULL;
1156    int32_t componentId = 0;
1157
1158    RBUSLOG_DEBUG("Received event callback: objectName=%s eventName=%s", 
1159        objectName, eventName);
1160
1161    subscription = (rbusEventSubscription_t*)userData;
1162
    	1. Condition !subscription, taking false branch.
    	2. Condition !subscription->handle, taking false branch.
    	3. Condition !subscription->handler, taking false branch.
1163    if(!subscription || !subscription->handle || !subscription->handler)
1164    {
1165        return RBUS_ERROR_BUS_ERROR;
1166    }
1167
1168    handler = (rbusEventHandler_t)subscription->handler;
1169
    	4. alloc_arg: rbusEventData_updateFromMessage allocates memory that is stored into filter. 
    	5. [[show details](https://coverity-wc-a1.cable.comcast.com/eventId=215008955-4&modelId=215008955-0&fileInstanceId=493351412&filePath=%2Fmnt%2Fjenkins%2Fworkspace%2FTECHNICOLORXB8-Yocto-Build%2Fbuild-tchxb8%2Ftmp%2Fwork%2Fcortexa15hf-neon-rdk-linux-gnueabi%2Frbus%2F1.0-r0%2Fgit%2Fsrc%2Frbus%2Frbus.c&fileStart=699&fileEnd=725)]
1170    rbusEventData_updateFromMessage(&event, &filter, &componentId, message);
1171    
1172    (*handler)(subscription->handle, &event, subscription);
1173
1174    rbusObject_Release(event.data);
1175
    	
CID 255501 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_storage: Variable filter going out of scope leaks the storage it points to.
1176    return 0;
1177}

[COVERITY] - [LEAK] - rbusProperty_initFromMessage

rbusError_t rbusProperty_initFromMessage(rbusProperty_t* property, rbusMessage msg)
432{
433    char const* name;
434    rbusValue_t value;
435    rbusError_t err = RBUS_ERROR_SUCCESS;
436
437    rbusMessage_GetString(msg, (char const**) &name);
438#if DEBUG_SERIALIZER
439    RBUSLOG_INFO("> prop pop name=%s", name);
440#endif
   	1. alloc_fn: Storage is returned from allocation function rbusProperty_Init. 
   	2. [[show details](https://coverity-wc-a1.cable.comcast.com/eventId=215008127-0&modelId=215008127-0&fileInstanceId=493351391&filePath=%2Fmnt%2Fjenkins%2Fworkspace%2FTECHNICOLORXB8-Yocto-Build%2Fbuild-tchxb8%2Ftmp%2Fwork%2Fcortexa15hf-neon-rdk-linux-gnueabi%2Frbus%2F1.0-r0%2Fgit%2Fsrc%2Frbus%2Frbus_property.c&fileStart=37&fileEnd=48)]
   	
CID 277653 (#1 of 1): Resource leak (RESOURCE_LEAK)
3. leaked_storage: Ignoring storage allocated by rbusProperty_Init(property, name, NULL) leaks it.
441    rbusProperty_Init(property, name, NULL);
442    err= rbusValue_initFromMessage(&value, msg);
443    rbusProperty_SetValue(*property, value);
444    rbusValue_Release(value);
445    return err;
446}

Encoding, an rtMessage structure types are incorrect

The following values are not encoded as uint values, but are being encoded as signed integers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.