Startup scripts, systemd services, and supporting scripts and config files that deploy the systemd services for the 5G Testbed RaspberryPi hardware.
Instructions tested on RaspberryPi OS 64bit, on a RaspberryPi 4B.
Clone this repository to the RaspberryPi's home directory.
cd $HOME
git clone https://github.com/frontiersi/5gtb-rpi.git
The scripts require stty
from coreutils and str2str
from RTKLIB:
sudo apt install coreutils rtklib
The startup scripts also require the SUPL LPP Client to connect to a location server and generate RTCM from LPP messages.
Install it by following the instructions in the GitHub Repository.
Ensure that the SUPL LPP Client can be executed from anywhere.
Make a copy of config_sample.cfg
called config.cfg
.
cp $HOME/5gtb-rpi/config_sample.cfg $HOME/5gtb-rpi/config.cfg
In the config.cfg
file add arguments for each parameter. The following explains each parameter:
The username of the current user on the Raspberry Pi is required to properly configure the user that executes the startup script on boot. This simplifies path names in the startup script.
# Username
user=pi # Username for executing as user in service
Determines how the script should operate given the hardware configuration, there are two modes:
positioning
: Executes the SUPL LPP Client which outputs RTCM corrections to the serial port and a file, and logs NMEA from the serial port to a file and streams to a TCP server. Use when a RaspberryPi GNSS HAT is connected.correction
: Executes the SUPL LPP Client which outputs RTCM corrections to a serial port, and saves output RTCM messages to a file. Use when an independent GNSS receiver is connected by serial port.
# Script mode
mode=positioning # Operation mode (positioning or correction)
Determines the GNSS device to stream RTCM to, and log NMEA from (if in positioning
mode). An optional USB serial port is also provided for SBF (raw GNSS data) logging, leave blank if not required.
# GNSS Device
uart_serial_port=/dev/ttyAMA0 # GNSS device UART serial port
usb_serial_port=/dev/ttyACM0 # (Optional) GNSS device USB serial port
baud_rate=115200 # Device baud rate
Determines the output directory to log data to.
# Output Directory
output_dir=~/output/ # Directory for output NMEA/RTCM/SBF and log files
Determines the location server network parameters. Sample parameters are provided in the example below.
# Location Server
host=192.0.2.1 # Location server hostname or IP
port=1000 # Location server port
mcc=001 # Location server mobile country code
mnc=1 # Location server mobile network code
tac=1 # Location server tracking area code
cell_id=1 # Location server cell ID - determines the mountpoint
Two systemd services are deployed:
wait-for-network.service
: Pings a server on the internet until it becomes reachable.5gtb-daemon.service
: Executes the 5G Testbed script (5gtb_startup.sh
) on startup, executed oncewait-for-network.service
is successful.
Deploy the systemd service by running:
$HOME/5gtb-rpi/deploy_services.sh
The systemd services execute the scripts at startup, so they should work when the RaspberryPi is booted.
Alternatively, the startup script can be run manually, which may be useful for development or debugging:
$HOME/5gtb-rpi/startup/5gtb_startup.sh
Note: The systemd services should be disabled when running manually, as the serial port will be already in use.
NMEA (.nmea
) and RTCM (.rtcm
) files logged by the services can be found in the folder set in the Output Directory config.
When the services are running, NMEA messages are also streamed over a TCP server on port 29471
. The stream can be interfaced over the net with netcat
, gpsd
, or similar.
NMEA (.nmea
) and RTCM (.rtcm
) files are named with an ISO time date format (YYYYMMDD-hhmmss
). These timestamps are in the Australian Eastern Standard Time (AEST) timezone. Please note that the timestamps in the NMEA data is in the Coordinated Universal Time (UTC) timezone.
Diagnostic scripts are located in the scripts/
folder and include the following:
ping_test.sh
: Pings the Google DNS every 200ms and logs to file in the Output Directory.temp_test.sh
: Querys the Raspberry Pi temperature every second and logs to file in the Output Directory.
To access the logs of a session, you can do so through journalctl
:
journalctl -u 5gtb-daemon.service
Logs of the SUPL LPP client stdout (.log
) are also saved to file in the folder set in the Output Directory config.
During development, it may be convenient to stop the startup daemon to halt data logging, and free up resources and serial ports.
To stop the daemon run:
$HOME/5gtb-rpi/disable_services.sh