In this small guide we will be installing FM-DX Webserver.
This will be executed on a Raspberry Pi 2, but will be useful/usable for most other Debian derived distributions.
We expect that we have set up a fresh installation and we have a user named fmdx
with sudo permissions available to run our commands.
You will need a Linux supported (usb) audio device and a FM-DX Webserver supported tuner.
We will assume your Tuner is on /dev/ttyUSB0.
ssh fmdx@rpi2
Linux rpi2 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Feb 3 08:08:29 2024 from 192.168.78.182
fmdx@rpi2:~ $ mkdir build
fmdx@rpi2:~ $ cd build
fmdx@rpi2:~/build $
fmdx@rpi2:~/build $ sudo apt install git -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 4.704 kB of archives.
After this operation, 31,1 MB of additional disk space will be used.
Get:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf git armhf 1:2.30.2-1+deb11u2 [4.704 kB]
Fetched 4.704 kB in 1s (4.867 kB/s)
Selecting previously unselected package git.
(Reading database ... 46357 files and directories currently installed.)
Preparing to unpack .../git_1%3a2.30.2-1+deb11u2_armhf.deb ...
Unpacking git (1:2.30.2-1+deb11u2) ...
Setting up git (1:2.30.2-1+deb11u2) ...
Installation of xdrd
fmdx@rpi2:~/build $ git clone https://github.com/kkonradpl/xdrd.git
Cloning into 'xdrd'...
remote: Enumerating objects: 79, done.
remote: Total 79 (delta 0), reused 0 (delta 0), pack-reused 79
Receiving objects: 100% (79/79), 171.77 KiB | 1.97 MiB/s, done.
Resolving deltas: 100% (38/38), done.
fmdx@rpi2:~/build/xdrd $ sudo apt install libssl-dev pkgconf -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
libssl-doc
The following NEW packages will be installed:
libssl-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1.601 kB of archives.
After this operation, 6.011 kB of additional disk space will be used.
Get:1 http://archive.raspberrypi.org/debian bullseye/main armhf libssl-dev armhf 1.1.1w-0+deb11u1+rpt1 [1.601 kB]
Fetched 1.601 kB in 0s (4.957 kB/s)
Selecting previously unselected package libssl-dev:armhf.
(Reading database ... 47161 files and directories currently installed.)
Preparing to unpack .../libssl-dev_1.1.1w-0+deb11u1+rpt1_armhf.deb ...
Unpacking libssl-dev:armhf (1.1.1w-0+deb11u1+rpt1) ...
Setting up libssl-dev:armhf (1.1.1w-0+deb11u1+rpt1) ...
fmdx@rpi2:~/build $ cd xdrd/
fmdx@rpi2:~/build/xdrd $ make
gcc -Wall -pedantic -std=c99 -c -O2 -D_GNU_SOURCE xdrd.c
xdrd.c:30: warning: "_GNU_SOURCE" redefined
30 | #define _GNU_SOURCE
|
<command-line>: note: this is the location of the previous definition
gcc -o xdrd xdrd.o -lpthread -lcrypto
fmdx@rpi2:~/build/xdrd $ sudo make install
install -c xdrd /usr/bin/xdrd
Before we can run xdrd we need to make sure our user is allowed to use serial ports, we can do this ny adding the user to the dialout
group.
fmdx@rpi2:~/build/xdrd $ sudo adduser $(whoami) dialout
Adding user `fmdx' to group `dialout' ...
Adding user fmdx to group dialout
Done.
Attaching the group to the user without logging out and in again.
fmdx@rpi2:~/build/xdrd $ newgrp dialout
To have xdrd start on boot we need to setup this.
Create /etc/systemd/system/xdrd.service
sudo vi /etc/systemd/system/xdrd.service
If you don't speak vi, use editor
instead.
If needed you can specify a different serial port with for example -s /dev/ttyUSB1
, if you have multiple serial ports, you might better use a /dev/serial/by-id/ device node.
[Unit]
Description=xdrd
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/xdrd -p password
User=fmdx
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=xdrd
[Install]
WantedBy=multi-user.target
Enable and start xdrd.service
sudo chmod 644 /etc/systemd/system/xdrd.service
sudo systemctl daemon-reload
sudo systemctl start xdrd
sudo systemctl enable xdrd
Test xdrd by connecting to your machine with xdr-gtk
fmdx@rpi2:~/build/librdsparser/build $ cd ../..
fmdx@rpi2:~/build $ git clone https://github.com/NoobishSVK/fm-dx-webserver.git
Cloning into 'fm-dx-webserver'...
remote: Enumerating objects: 420, done.
remote: Counting objects: 100% (165/165), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 420 (delta 83), reused 93 (delta 42), pack-reused 255
Receiving objects: 100% (420/420), 765.91 KiB | 3.83 MiB/s, done.
Resolving deltas: 100% (209/209), done.
fmdx@rpi2:~/build/fm-dx-webserver $ sudo apt install ffmpeg nodejs npm -y
fmdx@rpi2:~/build/fm-dx-webserver $ npm install
fmdx@rpi2:~/build/fm-dx-webserver $ node .
[09:04] [INFO] Web server is running at http://0.0.0.0:8080.
[09:04] [INFO] Connection to xdrd established successfully.
[09:04] [INFO] An existing installation of ffmpeg found, enabling audio stream.
[09:04] [INFO] Launching audio stream on port 8081.
[09:04] [INFO] Authentication with xdrd successful.
With your browser check your system for the FM-DX Webserver interface
If this works, break the process with ctrl-c
Add your user to be able to use the audio devices
fmdx@rpi2:~/build/fm-dx-webserver $ sudo addgroup $(whoami) audio
Adding user `fmdx' to group `audio' ...
Adding user fmdx to group audio
Done.
Attaching the group to the user without logging out and in again.
fmdx@rpi2:~/build/xdrd $ newgrp audio
Test startup
fmdx@rpi2:~/build/fm-dx-webserver $ node .
[09:18] [INFO] Web server is running at http://0.0.0.0:8080.
[09:18] [INFO] Connection to xdrd established successfully.
[09:18] [INFO] An existing installation of ffmpeg found, enabling audio stream.
[09:18] [INFO] Launching audio stream on port 8081.
[09:18] [INFO] Authentication with xdrd successful.
[09:19] [INFO] Web client connected (192.168.123.123) [1]
Press ctrl-c to stop.
To have FM-DX Webserver start on boot we need to setup this.
Create /etc/systemd/system/fm-dx-webserver.service
sudo vi /etc/systemd/system/fm-dx-webserver.service
If you don't speak vi, use editor
instead.
[Unit]
Description=FM-DX Webserver
After=network-online.target xdrd.service
Requires=xdrd.service
[Service]
ExecStart=npm run webserver
WorkingDirectory=/home/fmdx/build/fm-dx-webserver
User=fmdx
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fm-dx-webserver
[Install]
WantedBy=multi-user.target
Enable and start fm-dx-webserver.service
sudo chmod 644 /etc/systemd/system/fm-dx-webserver.service
sudo systemctl daemon-reload
sudo systemctl start fm-dx-webserver
sudo systemctl enable fm-dx-webserver