Kern IoT megoldások és rendszerek. 4G LTE NB-IoT LoRa GPS Bluetooth

kkl4pywahslvhsm7t9mb69k5rfki80

Robustel SDK

23.07.19 09:10 AM Comment(s) By peterkelecsenyi

Getting started with ROS development

Robustel’s series router allows 3rd party to develop their own applications. We provide a Software Development Kit (SDK) which offers a simple and fast way to implement customer-specific functions and applications.

If you have any problems in the programming process and you want to receive all the files for developing, please email to support@kern.hu. We will provide technical support in various aspects. 

Supported programming languages
  • C/C++
  • Linux Shell Script
  • Python 2.7.3 (available for R3000)
Recommended host operating systems
  • CentOS 6.5 (32 bits)
  • CentOS 7 (64 bits)
C library
  • uClibs
  • glibs

Getting started

Preparation for development

  1. Development environment is designed for the Linux systems. Virtual Machine is efficient way for using it, if you are not Linux user on the daily basis. In my specific case, I’m using Ubuntu 16.04 with VM. Worth to mention that VM is almost unavoidable part in my job, since there is an SDKs for IoT devices with GUI based on the usage of VM (for example, SDK for Legato OS of Sierra Wireless). Since VM might be used for different purposes (If not - don’t consider this remark), I would advise to allocate at least 80-90 GB of memory for VM.  Most widely used OS for IoT devices is Yocto, and if you want to try to build an image it requires a system with approximately 60 GB of memory. 
  2. Ones, you have got a Linux OS, the SKD can be installed. The cross-compile toolchain is distributed with SDK library, packed into a compressed file. The SDK is named as ROS-SDK-YY-XX.tar.bz2, where the “XX” represents the version number and YY the product series. You can extract the SDK to any place you like, for example:The cross-compile toolchain is distributed with SDK library, packed into a compressed file. The SDK is named as ROS-SDK-YY-XX.tar.bz2, where the “XX” represents the version number and YY the product series. You can extract the SDK to any place you like, for example:
$ tar jxf ROS-SDK-r3000-XX.tar.bz2 /opt
    There are many benefits to integrate the toolchain with the SDK. You will automatically get the same compile flags with the                firmware. And you do not need to specify the included path and link path for the SDK header and library files, which greatly                saves your efforts.

    There are some examples distributed with the SDK. You can build an SDK example for test after installation, for example:

$ cd /opt/ROS-SDK-r3000-XX

$ make package/example1/install

    Directory structure:

ROS-SDK-r3000-0.9.0

├── bin

│ └── r3000

├── build_dir

│ └── target-r3000

├── include

│ ├── configure.mk

│ ├── package.mk

│ ├── quilt.mk

│ ├── rpkg-build.sh

│ ├── rstrip.sh

│ ├── unpack.mk

│ └── web_language_js_gen

├── Makefile

├── package

│ ├── example1

│ ├── example2

│ └── Makefile

├── rules.mk

├── staging_dir

│ ├── host

│ └── target-r3000

└── tarball

  • bin – Where the .ipk files will be generated.
  • build_dir – Where all packages will be cross-com
  • include – Some common Makefiles and scripts used for package management.
  • package – Some common Makefiles and patches for all packages. The ROS Makefile has its own syntax.
  • staging_dir/host – Where the host tools needed for cross-compilation will be installed.
  • staging_dir/target-<platform> - Where to install the cross-compilation tools, the executable binary files, the library files, and the header files. Cross-compilation will search headers and library files from this directory.
  •  tarball – Where to store the compressed source codes.

Without moving further with investigating of the SDK structure, with simple steps performed previously we can start to write our first application. We can write our first application.

Creating an ROS Application

1) Create helloworld package

$ tar jxf ROS-SDK-r3000-XX.tar.bz2 /opt

$ cd /opt

$ mkdir package/helloworld

$ mkdir package/helloworld/src

2) Add source code:

Edit helloworld.c and save it in /opt/package/helloworld/src

#include <syslog.h>

int main()

{

syslog(LOG_DEBUG, “hello world”);

return 0;

}

Edit Makefile and save it in /opt/package/helloworld/src/

helloworld:

$(CC) helloword.c -o helloworld

3) Add SDK script:

In addition to compile the program, you should write an SDK script to tell the router system how to start and stop the program. The SDK provides some functions in order that you can more easily do the script, which located in usr/lib/functions. There are several commands you should support in the script.

  • start – start the program.
  • stop – stop the program.
  • restart – stop and restart the program.
  • status – check the program running or stopped.
  • on_startup – run on the system startup.
  • on_reboot – run before system reboot.
  • on_link_up – run when primary link is up.
  • on_link_down – run when primary link is down.
  • status_sync – (optional) run when someone query status, used for sync status from another file to usi format.

Add an SDK script to tell the router how to start or stop the application:

$ mkdir package/helloworld/files

$ cp package/example2/files/sdk.sh package/helloworld/files/

$ vi package/helloworld/files/sdk.sh

Edit sdk.sh based on the example, just change PROG variable

#!/bin/sh

. /usr/lib/functions

RETVAL=0

PROG=helloworld

start() {

  ${PROG}

return $?

}

stop() {

killproc ${PROG}

RETVAL=$?

return $RETVAL

}

restart() {

stop

start

}

status() {

pidof -o %PPID ${PROG} >/dev/null 2>&1

RETVAL=$?

[ $RETVAL -eq 0 ] && echo ${PROG} is running || echo ${PROG} is stopped

return $RETVAL

}

status_sync() {

return 0

}

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

restart

;;

status)

status

;;

on_startup)

start

;;

on_link_up)

stop

start

;;

on_link_down)

stop

;;

on_reboot)

stop

;;

status_sync)

status_sync

;;

*)

echo $"Usage: $0 {start|stop|restart|status|on_startup|on_link_up|on_link_down|on_reboot|status_sync}"

exit 2

esac

exit $?

4) Edit Makefile for SDK building

 $ cp package/example2/Makefile package/helloworld/

$ vi package/helloworld/Makefile

 include $(TOPDIR)/rules.mk

PKG_NAME:=hellworld

PKG_VERSION:=1.0

PKG_DESC:=helloworld example

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_UNPACK:=cp -rf src/* $(PKG_BUILD_DIR)

PKG_BUILD_PARALLEL:=1

PKG_BUILD_DEPENDS:=

include $(INCLUDE_DIR)/package.mk

define Package/Install

$(INSTALL_DIR) $(1)/usr/bin/

$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin/

$(INSTALL_DIR) $(1)/etc/sdk/

$(INSTALL_BIN) files/sdk.sh $(1)/etc/sdk/$(PKG_NAME) endef

$(eval $(call BuildPackage))

5) Build helloworld package (it's important from which directory to execute it)

 $ make package/helloworld/install

6)  Last part is to install APP to the router using GUI of ROS in the browser. The file which should be installed to the router is located in bin/target-<platform>/packages/

After that the file should be uploaded and installed in the “App center” on the device. 

Conclusion

As a result, we have an application which outputs “hello world” to the debug when it’s executed. By this article we could have seen how simple is to start your development.

  1.  Prepare environment (what takes couple minutes)
  2.   After first step you can immediately start developing.
  3.  To install application just transfer and install compiled file of the Application to the router.
  4.  And you have running application on the field device.

Next topic will be Serial connectivity management where I will solve more complex task and we can see GUI ROS development for web browser.

Share -

Date/Time: