RedRat Hub RedRatHub on a Raspberry-Pi

RedRatHub on a Raspberry-Pi

How to get it up and running....

The Raspberry-Pi is an excellent small server on which to run RedRatHub for managing and using your RedRat devices. This guide goes through the steps needed to setup a a Raspberry-Pi running Raspberry Pi OS (formally Raspian) and using NET Core 3.1 and RedRatHub 5.11 or greater.

A online demo of RedRatHub can be seen here.

RRX and R-Pi

Install .NET Core

The ARM32 Linux version of the .NET SDK needs to be downloaded from Microsoft and installed.

As the .NET SDK and runtime is updated fairly frequently, it is easiest to find the most recent version directly from the Microsoft .NET download page. At the time of writing, the SDK is at version 3.1.402.

On the Raspberry-Pi, the .NET package is downloaded unpacked in your home directory and then unpacked in an appropriate system location:

cd ~
wget https://download.visualstudio.microsoft.com/download/pr/8f0dffe3-18f0-4d32-beb0-dbcb9a0d91a1/abe9a34e3f8916478f0bd80402b01b38/dotnet-sdk-3.1.402-linux-arm.tar.gz
sudo mkdir /opt/dotnet
sudo tar -xvf dotnet-sdk-3.1.402-linux-arm.tar.gz -C /opt/dotnet/
sudo ln -s /opt/dotnet/dotnet /usr/local/bin

Check that the setup is now OK by entering dotnet --info which should give something like:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.402
 Commit:    9b5de826fd

Runtime Environment:
 OS Name:     raspbian
 OS Version:  10
 OS Platform: Linux
 RID:         linux-arm
 Base Path:   /opt/dotnet/sdk/3.1.402/

Host (useful for support):
  Version: 3.1.8
  Commit:  9c1330dedd

.NET Core SDKs installed:
  3.1.402 [/opt/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.8 [/opt/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.8 [/opt/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Install LibUsb

This is the device driver needed for communicating with a RedRat-X plugged in via USB.

sudo apt-get install libusb-1.0-0-dev

Install RedRatHub

Download the most recent version from the RedRat website and then unpack:

cd ~
wget https://www.redrat.co.uk/downloads/RedRatHub-V5.11.zip
unzip ./RedRatHub-V5.11.zip -d rrhub

This should now have extracted RedRatHub in to the directory rrhub.

It should now be possible to test running it:

cd rrhub/
sudo dotnet RedRatHub.dll

It needs to be run with sudo so that it can access the LibUsb device driver during the scan for RedRat devices.

If you do not have any RedRat devices available, then it can be run in evaluation mode using the --eval command line switch. This adds some dummy RedRat devices to RedRatHub's internal state, allowing some basic experimentation.

sudo dotnet RedRatHub.dll --eval

Once RedRatHub is running, find the IP address of the Raspberry-Pi and point a web browser at the following URL: http://IP-Of-Raspberry-Pi:5248/, for example http://192.168.1.50:5248/.

RedRatHub Home Page

Running RedRatHub on Startup

In most situations, it is useful to have RedRatHub startup automatically when the Raspberry-Pi boots up.

This is fairly straightforward to achieve with the systemd service manager. The first step is to place the RedRatHub code in a more suitable location on the Pi:

sudo mkdir /opt/rrhub
cd /opt/rrhub
sudo cp -r ~/rrhub/* .

Next, a startup script needs to be created to instruct systemd to run RedRatHub. This is placed in /lib/systemd/system.

cd /lib/systemd/system
sudo nano rrhub.service

This brings up the Nano editor to create the rrhub.service file. Copy and paste the following text into the file:

[Unit]
Description=RedRat Hub Server
After=multi-user.target

[Service]
ExecStart=/opt/dotnet/dotnet /opt/rrhub/RedRatHub.dll
WorkingDirectory=/opt/rrhub
StandardOutput=inherit
StandardError=inherit
Restart=always

[Install]
WantedBy=multi-user.target

Once this text has been entered, then do CTRL-X followed by Y to exit Nano and save the file.

The last step is to inform systemd about our new RedRatHub service:

sudo systemctl daemon-reload
sudo systemctl enable rrhub.service
sudo systemctl start rrhub.service

RedRatHub should now be running! Even if you reboot the raspberry-Pi, it should startup again and continue to operate.

If there are problems, then errors may be shown in /var/log/daemon.log or /opt/rrhub/logs/redrathub.log.