Application deployment on QEMU

Now that the application is ready, let’s test it with a deployment scenario close to a real world usage. Since redpesk supports cross-compilation, we can use either a x86_64 or a aarch64 architecture to deploy the application. In this demo, we will see the deployment on an emulated x86_64 QEMU board, and on a real aarch64 board. Both of them will run a redpesk OS image.

Emulated deployment (QEMU: x86_64 image)

Refer to the main documentation of redpesk for the installation of a redpesk image through QEMU.

Then launch the QEMU redpesk virtual machine (through the command line starting with qemu-system-x86_64 -hda "Redpesk-OS.img")

Installing the packages

Before installing packages of your application, add its repository on the virtual machine. To do so, use the following command from your host system:

rp-cli projects get industrial-demo-project --repository

Then, in the virtual machine, use the curl command given (according to the redpesk distribution running in your VM):

curl -fsSL [...] | bash

You can now install the required packages. The package anenometer-industrial-demo installs all the other packages as dependencies, and puts the right config files in the right directories. It also installs a configuration file to be used with the Modbus simulator. The package modbus-binding-simulation would be required to use the Modbus simulator.

sudo dnf install anemometer-industrial-demo modbus-binding-simulation

Starting the simulation

In order to start the simulation, we first need to launch the Modbus simulator.

In a dedicated terminal (e.g. through an SSH connection to the QEMU virtual machine), start the Modbus simulator on the port 5003:

modbus-simulation -a 127.0.0.1 -p 5003

This should output the following lines:

	--- Starting modbus tcp server at 127.0.0.1:5003 ---

TCP server ready for incoming client ...

We first need to make sure Redis is launched. Let’s type the following lines to do so:

systemctl enable redis
systemctl start redis

In another terminal, let’s launch our Python binding with:

CONTROL_CONFIG_PATH=/usr/redpesk/redis-tsdb-binding/etc/ /usr/bin/anemometer_industrial_demo.py -c /etc/gateway/anemometer_simu.json

The CONTROL_CONFIG_PATH is required by redis-tsdb-binding to setup itself.

We should see lots of setup debug information in the terminal following by a block similar to this one each second:

    DEBUG: [API redis] redis_add: { "key": "wind_direction_deg", "timestamp": "1713261521445", "value": 3.179830119864234 }
     INFO: [API redis] redisSendCmd: cmd result type INTEGER, str (null)
     INFO: [API redis] redisSendCmd: ret 1713261521445

It validates that our binding is able to read from a Modbus device.

Check results in Redis

With a Redis common line interface we can check that some values are written to a Redis Timeseries.

[root@localhost ~]# redis-cli
127.0.0.1:6379> ts.info wind_direction_deg
 1) totalSamples
 2) (integer) 17
 3) memoryUsage
 4) (integer) 4184
 5) firstTimestamp
 6) (integer) 1713260007953
 7) lastTimestamp
 8) (integer) 1713261525446
 9) retentionTime
10) (integer) 0
11) chunkCount
12) (integer) 1
13) chunkSize
14) (integer) 4096
15) chunkType
16) compressed
17) duplicatePolicy
18) (nil)
19) labels
20) (empty array)
21) sourceKey
22) (nil)
23) rules
24) (empty array)

127.0.0.1:6379> ts.range wind_direction_deg 1713260007953 1713261525446
 1) 1) (integer) 1713260007953
    2) 3.17983
 2) 1) (integer) 1713260007954
    2) 4.236395
 3) 1) (integer) 1713260009953
    2) 2.121096
 4) 1) (integer) 1713260010954
    2) 3.17983
 5) 1) (integer) 1713260012953
    2) 3.12213
 6) 1) (integer) 1713260013953
    2) 3.17983
 7) 1) (integer) 1713260568908
    2) 3.17983
 8) 1) (integer) 1713260568909
    2) 2.121096
 9) 1) (integer) 1713260569908
    2) 2.161079
10) 1) (integer) 1713260569911
    2) 3.2397
11) 1) (integer) 1713261521445
    2) 3.17983
12) 1) (integer) 1713261521446
    2) 4.236395
13) 1) (integer) 1713261522445
    2) 4.316028
14) 1) (integer) 1713261523446
    2) 4.159642
15) 1) (integer) 1713261524445
    2) 4.316028
16) 1) (integer) 1713261524447
    2) 2.161079
17) 1) (integer) 1713261525446
    2) 2.121096