Kunbus Revolution Pi RevPi Core 3 and DIO module

Hello,
I’ve been able to install balenaOS on this device and run a simple service, but now I would like to interact with the IO module. Has someone ever been able to do something like that?

I’ve added the Kunbus repos and installed the pi* stuff but I can’t get the module to work, neither access to Pictory.

Cheers,
Matteo

Hi @mcomisso
I will have to ask the team if we have any prior experience with the Kunbus Revolution Pi and its modular infrastructure.
After taking a look at what the device does it seems that Pictory is a peace of software that needs to run on the device to set up the installed modules. On Balena this would have to be set up in a container. Next step would be to provide the required kernel_modules / drivers for the attached hardware module.
Altogether it sounds like it might be a challenging setup. I will come back to you when I have heard from the devices team.

Hi. You can use the demo test example from here: https://github.com/balena-io-playground/revpi-core3-test

You can follow these steps:

  1. Download an OS image from dashboard and provision the board with it
    Clone the test application:
    git clone https://github.com/resin-io-projects/revpi-core3-test

Before booting the board copy the config.rsc file from the cloned application in the resin-boot partition.

Push the application to your board:
git remote add balena <your_app_repo>
git push balena

  1. Enter the application’s container and run:
    piControl/piTest/piTest -w O_1,1

  2. Enter the application’s container and run:
    piControl/piTest/piTest -w O_1,0

And the expected results are these:

The board should appear as online in the dashboard and running the application

The pin O_1 of the DIO module should have 24V.

The pin O_1 of the DIO module should now have 0V.

Hi Florin,
not sure to understand what you mean with this line:

Before booting the board copy the config.rsc file from the cloned application in the resin-boot partition.

Right now this is my Dockerfile.template:

# base-image for node on any machine using a template variable,
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/#dockerfile-templates
# and about balena base images here: https://www.balena.io/docs/reference/base-images/base-images/
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:stretch-run

# use `install_packages` if you need to install dependencies,
# for instance if you need git, just uncomment the line below.
# RUN install_packages git

RUN export DEBIAN_FRONTEND=noninteractive
RUN echo "deb http://packages.revolutionpi.de/ stretch main contrib" > /etc/apt/sources.list.d/revpi.list && echo "deb http://packages.revolutionpi.de/ updates/" >> /etc/apt/sources.list.d/revpi.list && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A217345D3B70E7CE && apt-get update

RUN install_packages python3
RUN install_packages systemd
RUN install_packages python3-revpimodio2 pitest revpi-firmware revpi-tools pictory

# Defines our working directory in container
WORKDIR /usr/src/app

COPY config.rsc /etc/revpi/config.rsc

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.
ENV UDEV=1

# server.js will run when container starts up on the device
CMD ["python3", "app.py"]

The config.rsc has been generated by me using Pictory on this device before flashing it with balenaOS.

Problem is that the DIO module appears not configured.

root@ab3ba30:/usr/src/app# piTest -d
Found 2 devices:

Address: 0 module type: 95 (0x5f) RevPi Core V1.2
Module is present
     input offset: 0 length: 6
    output offset: 6 length: 5

Address: 32 module type: 96 (0x60) RevPi DIO V1.4
Module is present, but NOT CONFIGURED!!!
     input offset: 11 length: 70
    output offset: 81 length: 18

Any help is appreciated.

Cheers,
Matteo

Hi @mcomisso
I think that Florin mean that after you provision the device with the OS image but before booting it, you should mount the resin-boot partition and manually add the config.rsc of the link repository there.

Hi guys,
I’ve managed to have it working.

So, if someone will ever need to do the same:

  1. Flash your RevPi Core with the BalenaOS
  2. Clone the test application: git clone https://github.com/resin-io-projects/revpi-core3-test
  3. Based on how you connect the DIO module, change the “position” to “32” (if the module is on the right of the RevPi Core) or “31” (if the module is on the left of the RevPi Core) inside the file config.rsc contained inside the test application
  4. Connect the RevPi Core via USB, mount the resin-boot partition and copy the config.rsc file in it
  5. Enjoy!

I’ve done some tests and it looks like the GUID, name, bmk and offset values inside the config.rsc file are not that useful: I’ve changed them to random values and I’m still able to read and write inputs and outputs.

Thanks a lot for the support!

Regards,
Matteo

Hi @mcomisso,

Great to hear that it works for you now and thank you very much for sharing your results here.

Regards,

Just to complete this thread: this is my final Dockerfile:

# Use the raspberrypi3 type, not the revpi-core-3
FROM balenalib/armv7hf-debian:jessie-run
LABEL io.balena.device-type="raspberrypi3"

ENV LANG C.UTF-8

# Add the RevolutionPi repository
RUN export DEBIAN_FRONTEND=noninteractive
RUN echo "deb http://packages.revolutionpi.de/ stretch main contrib" > /etc/apt/sources.list.d/revpi.list && echo "deb http://packages.revolutionpi.de/ updates/" >> /etc/apt/sources.list.d/revpi.list && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A217345D3B70E7CE && apt-get update

# Install build tools and remove layer cache afterwards
RUN apt-get -q update && apt-get install -yq --no-install-recommends \
	build-essential \
    python3 \
	git \
	systemd \
	python3-revpimodio2 \
	pitest \
	python3-pip \
	&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip3 install paho-mqtt

# Defines our working directory in container
WORKDIR /usr/src/app

# Clone and compile Kunbus's piTest binary
RUN git clone https://github.com/RevolutionPi/piControl
RUN cd /usr/src/app/piControl/piTest && make

# This will copy all files in our root to the working  directory in the container
# The same config.rsc file must be put both in the resin-boot partition and inside the container!
COPY config.rsc /etv/revpi/config.rsc
COPY . ./

#switch on systemd init system in container
ENV INITSYSTEM on

# Enable udevd so that plugged dynamic hardware devices show up in our container.
ENV UDEV=1

CMD ["python3", "app.py"]

With this setup I’ve been able to run a really simple Python script that publish via MQTT the status of one input, like this one:

import revpimodio2
import paho.mqtt.client as mqttClient

def on_connect(client, userdata, flags, rc):
  if rc == 0:
    print("Connected to broker")
    global Connected
    Connected = True
  else:
    print("Connection failed")

Connected=False
broker_address="my-mqtt-broker"
port=1883

client = mqttClient.Client("RevolutionPi")

def EventFunction(ioname, iovalue):
    """Event function, which is executed when the value changes."""
    print("Input {} now has value {}".format(ioname, iovalue))
    client.on_connect = on_connect
    client.connect(broker_address, port=port)
    client.publish("topic",'{ "RevolutionPi": { "I_1": "' + str(iovalue) + '" } }')

# Instantiates RevPiModIO
rpi = revpimodio2.RevPiModIO(autorefresh=True, configrsc="config.rsc")

# Catch Strg+C signal and exit program clean
rpi.handlesignalend()

rpi.cycletime=500

# Register input events
rpi.io.I_1.reg_event(EventFunction)

# Start event processing (program will block here)
print("Start mainloop")
rpi.mainloop()

I hope this could be useful!

Regards,
Matteo

Hi, I’am trying to reproduce this in my own setup.
Is it a typo or intention in the path /etv/… ?

HI foks,

I have setup of kunbus revolution pi Revpi core 3 and DIO module connected to sensor.
The value of the sensor I am able to read on I_14.
I need to write bash script or python script to publish and subscribe to access the sensor data using MQTT.
i am new to kunbus rev pi need guidance.
your help is appreciated ASAP

Thanks in advance