Part 3 – Starting the Services
Now we are ready to manually launch the delta5 server. We want to manually launch the service to see if there are any errors printed out or any nodes not being detected. We will do some additional configuration changes such as editing the admin username and password, and changing the default web server port.
First, lets make sure the delta5 service is not running from the previous service created in systemctl.
sudo systemctl stop rotorhazard.service
Now, lets navigate to the server directory and manually launch the delta5 server.
Now start the delta5 service.
sudo python server.py
If all went well, we should see the following printout with no errors.
[email protected]:~/RotorHazard/src/server$ sudo python server.py Configuration file imported Node 1 found at address 8 Node 2 found at address 10 Node 3 found at address 12 Node 4 found at address 14 No node at address 16 No node at address 18 No node at address 20 No node at address 22 Node 1: API_level=18, Freq=5843, EnterAt=200, ExitAt=186 Node 2: API_level=18, Freq=5695, EnterAt=200, ExitAt=150 Node 3: API_level=18, Freq=5732, EnterAt=252, ExitAt=185 Node 4: API_level=18, Freq=5769, EnterAt=200, ExitAt=116 Language file imported LED: hardware GPIO enabled Number of nodes found: 4 Release: 2.0.1 / Server API: 23 / Latest Node API: 18 Found installed: openjdk version "11.0.3" 2019-04-16 Found installed: IMDTabler Version 1.3 Database current laps reset Set Profile to '1' Running http server at port 80
Changing HTTP Port and Password
From the src/server directory copy config-dist.json to config.json
cd RotorHazard/src/server sudo cp config-dist.json config.json
Copy the original config-dist.json to a new file, config.json. Dont rename the config-dist.json. This means if we make mistakes in the config.json file when editing, we can just delete it and copy a new one from the original config-dist.json.
Now edit the file
sudo nano config.json
You will see the following code, scroll down to the #General section and change the following values to your preference. Using port 80 for the HTTP_PORT will not require a port number to be defined when connecting with your web browser. Be sure to change only the values shown in BOLD below, removing any a single entry of syntax will cause issues.
5000, "SECRET_KEY": "secret!", "ADMIN_USERNAME": "admin", "ADMIN_PASSWORD": "rotorhazard",
Now hit ctrl+x and type Y to save.
Reboot the timer.
Some common issues you may run into are missing packages or database issues. If you have issues starting the delta5server, I suggest you try deleting the database file first, database.db in the server directory. To do this, make sure you are in the server directory.
sudo rm database.db
Then try restart the service. Additional common errors relate to the I2C baud rate being too high. If you are getting [Errno 121] Remote I/O Errors, this is most likely the cause. You need to change the baud rate of the I2C bus. To do this, edit your boot config
sudo nano /boot/config.txt
This will force the I2C bus to run at a baud of 75000.
Lastly, if you are getting errors relating to the Neopixel libraries being incompatible or something along those lines (cant remember the exact error), then follow the steps below.
sudo apt-get install python-dev git scons swig
cd ~ git clone https://github.com/jgarff/rpi_ws281x.git
cd rpi_ws281x sudo scons
cd python sudo python3 setup.py build
sudo python3 setup.py install
Now try launching the server again.
cd ~ cd RotorHazard/src/server sudo python server.py
If you are having issues with HostAPD not broadcasting the racetimer SSID, this could be to do with the wpa_supplicant. If there is a wpa_supplicant for the interface you are trying to use with HostAPD in AP mode, the wpa_supplicant will prevent HostAPD from starting and will not allow the SSID to be broadcast. Lets say for example you are using WLAN0 as your HostAPD interface then you want to make sure you do not have a wpa_supplicant.conf in your /etc/wpa_supplicant folder. Lets take the wpa_supplicant.conf and move it to wpa_supplicant-wlan1.conf, or if there is a wpa_supplicant-wlan0.conf, again move it to wpa_supplicant-wlan1.conf.
cd /etc/wpa_supplicant sudo mv wpa_supplicant.conf wpa_supplicant-wlan1.conf or sudo mv wpa_supplicant-wlan0.conf wpa_supplicant-wlan1.conf
This now means we have no wpa_supplicant.conf running on interface wlan0. We have moved the wpa_supplicant.conf to run specifically on wlan1, so if you insert a USB WiFi dongle it will appear as WLAN1 and will follow the wpa_supplicant-wlan1.conf file. This means you can edit this file to connect to your WiFi network, using another wireless interface. Now, HostAPD services will start and be able to use WLAN0 to broadcast on.
Updating the Timer
Follow the steps below to update the timer when newer releases are available. We need to find the latest version of the RotorHazard fork and replace the version in the text below before cloning. Where 2.0.1 marks the current version, visit the RotorHazard latest releases page for more information on the latest release and replace 2.0.0 with the version you want to clone. In this case we use 2.1.0-beta1, the latest version at the time this article is updated. For example
Navigate to the Assets section of the release page on github of the version you want to update to. Right click on Source Code (zip) and click copy link and replace the link with the link below, after wget and before the -o.
wget https://codeload.github.com/RotorHazard/RotorHazard/zip/2.1.0-beta.1 -O temp.zip
cd ~ wget https://codeload.github.com/RotorHazard/RotorHazard/zip/2.1.0-beta.1 -O temp.zip unzip temp.zip mv RotorHazard RotorHazard.old mv RotorHazard-2.1.0-beta.1 RotorHazard rm temp.zip cp RotorHazard.old/src/server/config.json RotorHazard/src/server cp RotorHazard.old/src/server/database.db RotorHazard/src/server
Above, we copy the old configuration file config.json to the new RotorHazard directoy, we also copy the database.db to the new directory so that all user settings and your database is restored.
Lastly, we now need to update any dependencies that may have changed. Again, we do this by using the requirements.txt file, which would have any been downloaded in the update, and will contain any new packages or additional packages to install.
cd ~/RotorHazard/src/server sudo pip install --upgrade --no-cache-dir -r requirements.txt
Now, we start the RotorHazard service.
cd RotorHazard/src/server sudo python server.py OR sudo systemctl rotorhazard start
Please refer to the RotorHazard GitHub page to see if the NANO code is required to be updated. Remember, the server is not the only thing that needs updating, the NODES may require new code to be flashed too!
Links & References
Ready to flash Image!
Below is a image I have created which is pre-configured with the latest version of RotorHazard timer software and is also running the hostapd WiFi hotspot. This is a clean image with no errors so assuming you have all hardware setup correctly, you can flash this image to your PI SD card and just boot the race timer! Connect to it via WiFi, and browse to the IP with your web browser.
Firstly, download and install Win32 Disk Imager.
Now, before running win32, insert a blank SD Card into your computer. Now launch win32 Disk Imager. Here we are flashing a pre-build rotorhazard image, however this is the same process to flash the stock buster image.
Now, select the downloaded and extracted .img file to be flashed. Also select the path of your MicroSD card, be sure to get this right! Now hit write. This will write the image to the SD and when complete, you can just throw the SD into the PI and boot!
Pre-Build RotorHazard Image (Ready To Flash)
RotorHazard v2.1.0 Beta 1 Race Timer IMG – Updated 29.12.19 Version 2.1.0
RotorHazard v2.1.1 Stable.IMG – Updated 12.04.20 Version 2.1.1
RotorHazard v2.2.0 Stable.IMG – Updated 04.07.20 Version 2.2.0
RotorHazard v2.3.2 Stable.IMG – Updated 12.02.21 Version 2.3.2
RotorHazard v3.0.0 Stable.IMG – Updated 15.09.21 Version 3.0.0
Please note to use the pre-built images you must use a 16GB SD Card or above.
To run OTA updater (Version 2.3.2 and above).
cd ~ cd RH-ota sudo python3 start_ota.py
Image Details (Advanced Users):
SSH Enabled I2C Enabled SPI Enabled Added WS2812b LED Support Added INA219 Voltage/Current Support Added BME280 Temperature Support Added Java Included OTA Updater Hostapd configured for wlan0 only - No internet access on this interface. eth0 on DHCP and for Internet access and downloading updates etc.
Default Usernames and Passwords:
SSID: racetimer Password: rotorhazard Static IP: 192.168.10.1 Web Login: Username: admin Password: rotorhazard Web server port: 80 Raspbian SU Login (default): Username: pi Password: rotorhazard (I suggest changing this, if you have others connect to the timer as you have SSH enabled. Type passwd in CLI.) Hostname: raspberrypi Share Name: \\192.168.10.1\rotorhazard Username: pi Password: rotorhazard (Suggest Changing) In version 2.1.1 I have made some changes to the image. There are two interfaces, WLAN0 and WLAN1. WLAN0 is configured for internet access as a client interface with DHCP enabled. WLAN1 is configuration as a AP with SSID racetimer. You need to enable WLAN0 in order to update the timer and to get internet access. If you do not have two wireless interfaces some changes will need to be made.I have also added SAMBA in the latest release 2.1.1. This allows you to map a drive and browse the contents of the rotorhazard directory. Version 2.1.1 also includes the latest stable release of RotorHazard OTH for over the air flashing of nodes.
2.1.0 MD5 Hash: b37c77c4a423c9421a655e99456cdc63 2.1.1 MD5 Hash: 114a6e197fbe9f5423b60dcad37bf5fc 2.2.0 MD5 Hash: 1a48852b830431b99f8a308c31f2e53a 2.3.2 MD5 Hash: 33a49e717a65e7418ea6327446632de6 3.0.0 MD5 Hash: a31bd85b427f29e0849e47216759131a