Home
[RDK Central Wiki]
CMF
[Code Releases]
Let's introduce a ccsponrust application as a PoC evaluating a capability of interacting with CPE Data model via rbus broker.
Here's a list of basic features of the application:
The implementation showcases the flexibility and capability of Rust applications in managing and interacting with the RDKB data model, highlighting Rust's potential for developing robust and efficient system-level applications.
The project of ccsponrust could be found on: ccsponrust-main.tar.bz2
To satisfy the rbus libraries dependency in the project, a rbus_stub library is available.
This stub library includes all the functions used in ccsponrust and doesn't require dozens of rbus libraries from the RDKB image for specific architectures at the compilation stage.
This rbus_stub could be skipped if a compiler has an access to all the libraries. And new path should be set in build.rs file of the project. It is helpful then the project is a part of Yocto recipe
//build.rs
fn main() {
println!("cargo:rustc-link-search=native=/src/rbus_stub");
println!("cargo:rustc-link-lib=dylib=rbus");
}
In order to make the development easier, let's create a Dockerfile with steps to create a cross-compile environment to build Rust apps for RPi and RDK-B.
Create docker file from base image:
Docker file content:
# Use your base image
FROM javrv/ubuntu18_04_rdkb_dunfell:v1
# Install curl, Rust, and add the ARM target
RUN apt-get update && apt-get install -y curl gcc-arm-linux-gnueabihf
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup target add armv7-unknown-linux-gnueabihf
# Setup cross-compilation configuration
RUN echo "[target.armv7-unknown-linux-gnueabihf]\nlinker = \"arm-linux-gnueabihf-gcc\"" > /root/.cargo/config
WORKDIR /src
Command to create the image from Docker
docker build -t rust_rpi_rdkb_image:v1 .
Run docker image from the ccsponrust project folder. The project should be cloned from git repository
docker run -it --mount type=bind,source="$(pwd)",target=/src --rm rust_rpi_rdkb_image:v1 /bin/bash
Compile the project
cargo build --target=armv7-unknown-linux-gnueabihf --release
after the application will be built, should the strip command be ran to decrease the size of the application. The rust doesn’t do it by default.
arm-linux-gnueabihf-strip target/armv7-unknown-linux-gnueabihf/release/ccsponrust
And the application is ready for use on RPI.
Please see previous section on how to create an SD card for your RPi
Find or copy ccsponrust on Raspberry Pi.
Usage:
ccsponrust --command get|set|subscribe --component <component> --name <name> [--value <value>] [--timeout <timeout>]
Example:
ccsponrust --command get --component gl_component --name Device.WiFi.SSID.1.SSID
Example:
ccsponrust --command set --component gl_component --name Device.WiFi.SSID.1.SSID --value test_string
Example:
ccsponrust --command subscribe --component gl_component --name Device.WiFi.SSID.1.SSID --timeout 3600
root@RaspberryPi-Gateway:~# ./ccsponrust --command set --component gl_component --name Device.X_RDK_WebConfig.URL --value test_str_2
Start executing command: set; component: gl_component; name: Device.X_RDK_WebConfig.URL
open_rbus result: ok
value: test_str_2
set_rbus_value result: ok
close_rbus result: ok
root@RaspberryPi-Gateway:~# ./ccsponrust --command get --component gl_component --name Device.X_RDK_WebConfig.URL
Start executing command: get; component: gl_component; name: Device.X_RDK_WebConfig.URL
open_rbus result: ok
get_rbus_value result: ok
value: test_str_2
close_rbus result: ok
root@RaspberryPi-Gateway:~# ./ccsponrust --command subscribe --component gl_component --name Device.X_RDK_WebConfig.URL --timeout 3600
Start executing command: subscribe; component: gl_component; name: Device.X_RDK_WebConfig.URL
open_rbus result: ok
-----------Old Value:--------------
value: test_str
-----------New Value:--------------
value: test_str_2
--------------------------------
Run ccsponrust with subscribe command on RPI, and change the name of SSID of the Wi-Fi interface on RPi RDK-B Web UI.
A notification after applying on the UI will be caught by ccsponrust application.
root@RaspberryPi-Gateway:~# ./ccsponrust --command subscribe --component gl_component --name Device.WiFi.SSID.1.SSID --timeout 3600
Start executing command: subscribe; component: gl_component; name: Device.WiFi.SSID.1.SSID
open_rbus result: ok
-----------Old Value:--------------
value: GL-wifi1dddd
-----------New Value:--------------
value: GL-wifi_test
Some values of data model like Device.WiFi.SSID.1.SSID doesn’t support set in data model, and it is not possible to set new values for this parameter using rbus. It was tested with default rdkb cli apps.