# Application Development

Syrus 4 comes with the kernel 5.4.20 and has a custom Linux distro called Apex, based on the Yocto project. It has built in APIs and compatible SDKs to help you develop your application.

If you're looking to build a simple application with a small amount of requests within the device you may opt for using the API for it's easy interfacing.

However, if your application requires the consumption of a lot of resources or you need to develop something outside the Syrus you'll want to use the SDK.

# Architecture

Features:

  • SoC TI ARM Cortex-A8 core processor, AM3358 1GHz.
  • 512MB DDR3 RAM / 4GB 8-bit eMMC Flash storage
  • Micro-SD card slot can support up to 512GB of storage.
  • CAT 4 LTE Modem / Bluetooth BLE 4.2 - SBC +A2DP / WiFi
  • GNSS (GPS, Glonass)
  • Physical interfaces: CAN 1939/RS485/RS232/Ethernet
  • Software packages installed: Python 2.7.17 & Node v10.15.3

# Software

Besides the python and node development packages, you can install software packages using the apex core tool:

Core packages These are the software packages that the device comes installed with: https://apex.digitalcomtech.com/core-packages.txt

Dev packages These are the dev packages that can be installed: https://apex.digitalcomtech.com/dev-packages.txt

If your application requires software packages outside of these please contact our support team and we'll be glad to assist.

# Building an App

Syrus has a built in core system tool that allows you to manage applications and run instances of any application with different versioning. To get started you'll need to create a package.json file and an init.sh file, optional you can include a link to a repository which the core tool can use for version control.

Within the package.json you can also define a JSON schema which UI applications like the management tool interface can use to create custom forms that the application can use.

# package.json

The package.json file must contain "name", "version", "description", and "main" fields. For more information please visit docs.npmjs.com.

Other fields you can include are:

field Description example
icon Path to an image used as the main icon for the application https://images.site.com/icon.png
minApexVersion Minimum version of Apex OS that's required to run the app 20.25.00
repository Path to app repo https://www.github.com/path/to/app/

Here's an example package.json:

{
    "name": "My Application",
    "version": "1.0.0",
    "description": "My application's description",
    "main": "index.js",
    "icon": "https://image.flaticon.com/icons/svg/2948/2948003.svg",
	"minApexVersion": "20.25.00",
	"repository": "https://www.github.com/path/to/app/",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node index.js"
    },
    "keywords": [ "myapp" ],
    "author": "user@email.com",
    "license": "ISC",
    "dependencies": {}
}

Please note that the name of the application cannot be longer than 50 characters

Repository On the repository you specify you can add a file with the name: version.json, and the management tool will use it to handle versions, if it detects a newer version than the current one installed on the Syrus, then it will show button with an available upgrade.

{
    "stable": "1.22.0"
}

# init.sh

The init script is the starting script for your application. Make sure to chmod +x init.sh to make it executable:

Example init.sh file:

node index.js

# schema

The schema is an optional object that you can include which will produce forms for your application, allowing you to automatically expose input fields and information via a graphical UI for users to input rather than having them edit any json configuration file.

{
    ...
    "schema": {
        "type": "object",
        "required": [
            "api_token"
        ],
        "properties": {
            "account": {
                "label": "User Account Name",
                "description": "Name for the account used in application",
                "type": "string",
                "minLength": 3,
                "maxLength": 50
            },
            "api_token": {
                "label": "Token",
                "description": "Application token",
                "type": "string",
                "fullWidth": true
            }
        }
    }
}

For more information visit JSON Schema Format

# Sample Apps

# Python

To start using Python to develop applications you'll want to add pip to install python packages. To do this you need to add the 'dev_repo' on the device using the apx-core tool.

$ sudo apx-core add_dev_repo

Once that's done you can install packages with the following command:

python -m pip install --user PACKAGE_NAME

Example use of requests package:

python -m pip install --user requests
>>> import requests
>>> data = requests.get('http://localhost/system-info')
>>> print(data.content)
{"ram":{"total":506084,"used":140904,"free":85472,"available":346848},"cpu":{"currF":1000,"usage":22.0079,"governor":"ondemand","stats":{"300":6218.2,"600":579130.83,"720":7092.62,"800":9264.24,"1000":20422.01}},"rootfs":{"total":444018,"free":150107},"datafs":{"total":2223416,"free":2033060},"uptime":622129,"loadAvg":[0.77,1.01,1.05],"apexVersion":"apex-20.52.1","releaseDate":"20201221234751","sessionCount":14,"kernelVersion":"5.4.20-g738552d0b0","netLink":{"name":"wlan0","ip":"192.168.0.201"},"hostname":"syrus-867698041100127"}
>>> print(data.json()['kernelVersion'])
5.4.20-g738552d0b0
Last Updated: 1/19/2021, 10:27:27 PM