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 and using NET 8.0 and RedRatHub 8.00 or greater.

A online demo of RedRatHub can be seen here.

RRX and R-Pi

Install .NET 8.0

The Arm Linux version of .NET needs to be downloaded from Microsoft and installed, either the Arm32 or the Arm64 version, depending on whether you are using the 32-bit or 64-bit versions of Raspberry-Pi OS. Choose either the ASP.NET Core Runtime or SDK.

How can I check if my R-Pi is 32-bit or 64-bit? One way is to use the following at a command prompt:

getconf LONG_BIT

As .NET is updated fairly frequently, it is easiest to find the most recent version directly from the Microsoft .NET download page.

On the Raspberry-Pi, the 64-bit .NET package can be downloaded to your home directory and then unpacked in an appropriate system location with the following commands. These will need to be adjusted for the 32-bit download or if you want to use different file locations.

cd ~
wget https://download.visualstudio.microsoft.com/download/pr/853490db-6fd3-4c17-ad8e-9dbb61261252/3d36d7d5b861bbb219aa1a66af6e6fd2/dotnet-sdk-8.0.403-linux-arm64.tar.gz
sudo mkdir /opt/dotnet
sudo tar -xvf dotnet-sdk-8.0.403-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:


Host:
  Version:      8.0.10
  Architecture: arm64
  Commit:       81cabf2857
  RID:          linux-arm64

.NET SDKs installed:
  No SDKs were found.

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

...

Install LibUsb

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

sudo apt install libusb-1.0-0-dev

Install RedRatHub

Download the most recent version from the RedRat website and then unpack. Check the RedRat Hub page for the most recent version:

cd ~
wget https://www.redrat.co.uk/downloads/RedRatHub-V8.00.zip
unzip ./RedRatHub-V8.00.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.