Radarcape:Acarsdec: Difference between revisions

From Beast Wiki
Jump to navigation Jump to search
imported>Dl4mea
imported>Dl4mea
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
=acarsdec on the Radarcape=
=acarsdec on the Radarcape=


acarsdec is a software which uses a DVB-T stick in order to decode up to 4 channels ACARS signals within a 1MHz band segment. The Radarcape's front panel extension port may be used to plug such a DVB-T stick.<br>The decoding process requires some mathematical functions and obtains plenty of processing resources. Due to that it is not guaranteed to run on a heavily loaded Radarcape and/or together with Mode-AC or FR24 feeder. You may need to disable some features.
acarsdec is a software which uses a DVB-T stick in order to decode up to 4 channel with ACARS signals within a 1MHz band segment. The front panel extension port of the Radarcape may be used to plug such a DVB-T stick.<br>The decoding process requires some mathematical functions and obtains plenty of processing resources. Due to that it is not guaranteed to run on a heavily loaded Radarcape and/or together with Mode-AC or FR24 feeder. You may need to disable some features.  


Installation requires some skills in handling a console but at the end is easy.
Installation requires some skills in handling a console but at the end is easy.


The original places where to find the used components are<br>
The original places where to find the used components are
* [http://sdr.osmocom.org/trac/wiki/rtl-sdr OsmoSDR and librtlsdr]<br>
* [http://www.satsignal.eu/raspberry-pi/acars-decoder.html ACARS decoder for Raspberry Pi]<br>
* [http://sourceforge.net/projects/acarsdec/ Acarsdec]
* [http://sourceforge.net/projects/acarsdec/ Acarsdec]
* [http://askubuntu.com/questions/110341/how-to-blacklist-kernel-modules How to blacklist kernel modules]
* [https://community.arm.com/groups/tools/blog/2013/04/15/arm-cortex-a-processors-and-gcc-command-lines ARM Cortex-A Processors and GCC Command Lines]
Installation requires some skills in handling a console and edit files, but at the end is easy.


You may need to use the command '''lsb_release -a''' in order to distinguish which Linux distribution is running on your Radarcape.
==Installation on a Debian distribution based Radarcape==


==Installation on an Angstrom distribution based Radarcape==


===Prepare Installation===
===Prepare Installation (Debian)===


First, you need to install build tools on the Radarcape.
First, you need to install build tools on the Radarcape. You may need to enter one line after the other separately.
<source lang="bash">
<source lang="bash">
opkg update
apt-get update
opkg install packagegroup-core-buildessential
apt-get upgrade -y
opkg install cmake
apt-get install -y build-essential cmake git libusb-1.0-0-dev
opkg install libusb-1.0-dev
opkg install libsndfile-dev
sync
sync
</source>
</source>
This will take some time.
This will take some time.


If problems appear somehow around something that is led_aging or so, mind this link
[https://www.mail-archive.com/[email protected]/msg15617.html https://www.mail-archive.com/[email protected]/msg15617.html]
===Install librtlsdr===


Download one of the [https://github.com/steve-m/librtlsdr/releases packaged releases]: Look for the eventually greyed .tar.gz text, cut & paste the link of it and fetch it with wget on your Radarcape (in this case it is version 0.5.3, which was current while writing this descrition):
===Install librtlsdr (Debian)===


Install rtl-sdr library. You need to blacklist the kernel DVB-T stick driver before using this new driver.
<source lang="bash">
<source lang="bash">
wget --no-check-certificate https://github.com/steve-m/librtlsdr/archive/v0.5.3.tar.gz
echo blacklist dvb_usb_rtl28xxu >> /etc/modprobe.d/fbdev-blacklist.conf
</source>
</source>


Untar/unpack it. Note that the filename eventually may differ for your download
Then you are ready to build and install the library.
<source lang="bash">
tar xvf v0.5.3.tar.gz
</source>
 
As described [http://sdr.osmocom.org/trac/wiki/rtl-sdr here], navigate to ' ''Building with cmake:'' ' and follow these steps. You don't need sudo, as you are already root user on your Radarcape. The first command 'cd' must be adopted to what you have got as folder when unpacking your archive in the latest step.


<source lang="bash">
<source lang="bash">
cd librtlsdr-0.5.3
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
mkdir build
cd build
cd build
cmake ../
cmake ../ -DINSTALL_UDEV_RULES=ON
make
make
make install
make install
ldconfig
ldconfig -v
cd ..
cp -v rtl-sdr.rules /etc/udev/rules.d/
sync
</source>
 
 
After this step, reboot your Radarcape without DVB-T stick connected. Wait a few 10 seconds, plug your stick and check with command dmesg if the stick became recognized correctly:
 
[[File:acarsdec1.png|none|Relevant dmesg output after DVB-T stick was plugged]]
 
 
Next, check with the command rtl_test if it works:
 
<source lang="bash">
root@rc66:~# rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001
 
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.
 
Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.
 
Reading samples in async mode...
lost at least 232 bytes
</source>
</source>
One 'lost' message is ok during startup, but there should none appear later.


===Install acarsdec===
===Install acarsdec (Debian)===


acarsdec source package can be found [http://sourceforge.net/projects/acarsdec on sourceforge]. There is a nice green button with the latest version, click on it and then look for the ' ''direct link'' ', which you should cut & paste, edit and execute with wget like shown below.<br>But '''before''', with a simple '''cd''', go back into your root folder. After uncompressing the archive, change to the folder that became created by tar
With a simple '''cd''' command, go back into your root folder.
 
acarsdec source package can be found on [https://sourceforge.net/projects/acarsdec/files/acarsdec/ sourceforge]. There is a green button with the latest version, click on it and then look for the ' ''direct link'' ', which you should cut & paste, edit and execute with wget like shown below.After uncompressing the archive, change to the folder that became created by tar.
 
Note that at the time of writing version 3.2 was latest, it might be different sometimes later.


<source lang="bash">
<source lang="bash">
cd
cd
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/3.0/acarsdec-3.0.tar.gz
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/3.2/acarsdec-3.2.tar.gz
tar xvf acarsdec-3.0.tar.gz
tar xvf acarsdec-3.2.tar.gz
cd acarsdec-3.0
cd acarsdec-3.2
</source>
</source>


Now it comes... the complicated part is that ALSA lib is not necessary for the build here, and it seems that the Angstrom distribution that is used on the Radarcape has a different library structure.<br>That means you need to edit the Makefile:
Now it comes... the complicated part is that ALSA lib is not necessary for the build here, and it seems that the Angstrom distribution that is used on the Radarcape has a different library structure.<br>That means you need to edit the Makefile:


* remove -D WITH_ALSA from the CFLAGS line. Next, I found that with some other compiler options the CPU load is about one third of the original ones.  
* comment out all lines with CFLAGS with a # sign in the first column.
* insert a new CFLAGS line
 
<source lang="bash">
<source lang="bash">
original: CFLAGS= -g -Ofast -ftree-vectorize -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE -D WITH_ALSA<br>
CFLAGS= -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL
modified: CFLAGS= -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE
</source>
</source>


* add the library librt to the linker libraries:
* in the line showing LDLIBS, remove -lasound, so it looks like
<source lang="bash">
<source lang="bash">
original: LDLIBS=  -lm -pthread  -lrtlsdr -lsndfile -lasound
modified: LDLIBS=  -lm -pthread  -lrtlsdr
modified: LDLIBS=  -lm -pthread  -lrtlsdr -lsndfile -lasound -lrt
</source>
</source>


For your convenience, I've put a modified MakefileRC onto my server, fetch that and execute it with make
Start compilation with the command ''make''
 
<source lang="bash">
wget http://www.modesbeast.com/resources/MakefileRC
make -f MakefileRC
</source>


You then should see some output like this:
You then should see some output like this:
<source lang="text">
root@radarcape:~/acarsdec-2.4#make -f MakefileRC
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o main.o main.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o acars.o acars.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o msk.o msk.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o rtl.o rtl.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o output.o output.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o soundfile.o soundfile.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE  -c -o alsa.o alsa.c
cc main.o acars.o msk.o rtl.o output.o soundfile.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr -lsndfile -lasound -lrt
root@radarcape:~/acarsdec-2.4#
</source>
In order to execute it for the first, time you should set LD_LIBRARY_PATH. For later restarts, one time write /usr/local/lib into /etc/ld.so.conf, which will be active after the next reboot. (see: [http://www.linux-praxis.de/lpic1/lpi101/1.102.4.html])
<source lang="bash">
<source lang="bash">
echo "/usr/local/lib" > /etc/ld.so.conf
root@radarcape:~/acarsdec-3.2# make
ldconfig
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o acarsdec.o acarsdec.c
export LD_LIBRARY_PATH=/usr/local/lib
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o acars.o acars.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o msk.o msk.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o rtl.o rtl.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o air.o air.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o output.o output.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE  -c -o alsa.o alsa.c
cc acarsdec.o acars.o msk.o rtl.o air.o output.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr
</source>
</source>


Execute acarsdec. My stick has +79ppm offset and the gain is fixed to 40dB. With the 3 channels that are active within the decodeable 1MHz segment here, the CPU load is just 35%. That fits to a running Radarcape, if not too busy with Mode-AC. In case of doubts, open another ssh terminal and execute htop command there.
Execute acarsdec. It might be good if you don't see messages from specific frequency to leave them out from decoding. The command also needs to be modified for networking according to its original description if you like to send decoded messages to other computers.
 
The command needs to be modified for networking according to its original description if you like to send decoded messages to other computers.


<source lang="bash">
<source lang="bash">
./acarsdec -o1 -v -p 79 -g 400 -r 0 131.525 131.725 131.825
./acarsdec -o1 -v -p 79 -g 400 -r 0 131.725  
</source>
</source>


Line 119: Line 135:


<source lang="text">
<source lang="text">
root@radarcape:~/acarsdec-3.2# ./acarsdec -o1 -v -p 79 -g 400 -r 0 131.525 131.725 131.825       
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001
Using device 0: Generic RTL2832U OEM
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Found Rafael Micro R820T tuner
Tuner gain : 40.200000
Tuner gain : 40.200000
Set center freq. to 131850000Hz
Set center freq. to 131750000Hz
Exact sample rate is: 1000000.026491 Hz
Exact sample rate is: 2500000.107620 Hz
Decoding 3 channels
Decoding 1 channels
#2 too many parity errors
#1 (L:-32 E:0) 08/09/2016 10:34:58 .A6-EDU EK0015 2 Q0 S76A
#3 (L:-21 E:0) 02/01/2000 04:25:07 .OY-KBH SK0610 2 B9 M36A /EKCH.TI2/040EKCHAC5B3
#1 (L:-38 E:0) 08/09/2016 10:34:59 .PH-BXK KL1652 G 10 M67A ETA93A08103456KLM1652 LIPZEHA
#1 (L:-20 E:0) 02/01/2000 04:25:12 .D-AILA LH03RV R 1L M74A 02467226782VUYY93,EBB*14GK0
#1 too many parity errors
#2 parity error(s): 2
#1 (L:-33 E:0) 08/09/2016 10:35:06 .A6-EDU EK0015 2 Q0 S76A
#2 crc error
#2 not able to fix errors
#3 (L:-21 E:0) 02/01/2000 04:25:14 .OY-KBH SK0610 2 _d S88A
#1 (L:-25 E:0) 02/01/2000 04:25:17 .G-BNWM BA0155 2 Q0 S09A
#1 (L:-20 E:0) 02/01/2000 04:25:18 .D-AILA LH03RV R _d S35A
#1 (L:-19 E:0) 02/01/2000 04:25:21 .D-AILA LH03RV R _d S36A
#2 (L:-28 E:0) 02/01/2000 04:25:22 .D-AICC DE03FC X _d S58A
#2 (L: -3 E:0) 02/01/2000 04:25:29 .PH-TFC OR0717 E Q0 S11A
#3 (L:-22 E:0) 02/01/2000 04:25:29 .OY-KBH SK0610 2 _d S89A
</source>
</source>


==Installation on a Debian distribution based Radarcape==


===Prepare Installation===
===Tweaking (Debian)===
 
Probably it makes sense to disable automatic power savings on the CPU.
<source lang="bash">
apt-get update
apt-get install -y cpufrequtils
cpufreq-set -g performance
</source>
This is not automatically permanent.
 
 
 
 
==Installation on an Angstrom distribution based Radarcape (may work)==
 
Angstrom is outdated and this description is only hold for completeness. Especially because Debian is able to use the floating point unit of the ARM, for Acarsdec Debian is strongly recommended.
 
===Prepare Installation (Angstrom)===


First, you need to install build tools on the Radarcape.
First, you need to install build tools on the Radarcape.
<source lang="bash">
<source lang="bash">
apt-get update
opkg update
apt-get upgrade
opkg install packagegroup-core-buildessential
apt-get install build-essential
opkg install cmake
apt-get install cmake
opkg install libusb-1.0-dev
apt-get install libusb-1.0-0-dev
opkg install libsndfile-dev
apt-get install libsndfile1-dev
sync
sync


Line 157: Line 183:
This will take some time.
This will take some time.


===Install librtlsdr===
If problems appear somehow around something that is led_aging or so, mind this link
[https://www.mail-archive.com/[email protected]/msg15617.html https://www.mail-archive.com/[email protected]/msg15617.html]
 
===Install librtlsdr (Angstrom)===


Download one of the [https://github.com/steve-m/librtlsdr/releases packaged releases]: Look for the eventually greyed .tar.gz text, cut & paste the link of it and fetch it with wget on your Radarcape (in this case it is version 0.5.3, which was current while writing this descrition):
Download one of the [https://github.com/steve-m/librtlsdr/releases packaged releases]: Look for the eventually greyed .tar.gz text, cut & paste the link of it and fetch it with wget on your Radarcape (in this case it is version 0.5.3, which was current while writing this descrition):
Line 182: Line 211:
</source>
</source>


===Install acarsdec===
===Install acarsdec (Angstrom)===


acarsdec source package can be found [http://sourceforge.net/projects/acarsdec on sourceforge]. There is a nice green button with the latest version, click on it and then look for the ' ''direct link'' ', which you should cut & paste, edit and execute with wget like shown below.<br>But '''before''', with a simple '''cd''', go back into your root folder. After uncompressing the archive, change to the folder that became created by tar
acarsdec source package can be found [http://sourceforge.net/projects/acarsdec on sourceforge]. There is a nice green button with the latest version, click on it and then look for the ' ''direct link'' ', which you should cut & paste, edit and execute with wget like shown below.<br>But '''before''', with a simple '''cd''', go back into your root folder. After uncompressing the archive, change to the folder that became created by tar
Line 188: Line 217:
<source lang="bash">
<source lang="bash">
cd
cd
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/2.4/acarsdec-2.4.tar.gz
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/3.0/acarsdec-3.0.tar.gz
tar xvf acarsdec-2.4.tar.gz
tar xvf acarsdec-3.0.tar.gz
cd acarsdec-2.4
cd acarsdec-3.0
</source>
</source>


Now it comes... the complicated part is that ALSA lib is not necessary for the build here, and it seems that the Angstrom distribution that is used on the Radarcape has a different library structure.<br>That means you need to edit the Makefile:
Now it comes... the complicated part is that ALSA lib is not necessary for the build here. Remove -D WITH_ALSA from the CFLAGS line. Next, I found that with different compiler options the CPU load is about one third of the original ones.  
 
* remove -D WITH_ALSA from the CFLAGS line. Next, I found that with some other compiler options the CPU load is about one third of the original ones.  
<source lang="bash">
original: CFLAGS= -g -Ofast -ftree-vectorize -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE -D WITH_ALSA<br>
modified: CFLAGS= -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE
</source>
 
* add the library librt to the linker libraries:
<source lang="bash">
original: LDLIBS=  -lm -pthread  -lrtlsdr -lsndfile -lasound
modified: LDLIBS=  -lm -pthread  -lrtlsdr -lsndfile -lasound -lrt
</source>
 
For your convenience, I've put a modified MakefileRC onto my server, fetch that and execute it with make
 
<source lang="bash">
<source lang="bash">
wget http://www.modesbeast.com/resources/MakefileRC
original: CFLAGS= -g -Ofast -ftree-vectorize -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE -D WITH_ALSA
make -f MakefileRC
modified: CFLAGS= -g -O3 -flto -funroll-loops -ffast-math -pthread -D WITH_RTL -D WITH_SNDFILE 
</source>
</source>


You then should see some output like this:
You then should see some output like this:
<source lang="text">
<source lang="text">
root@radarcape:~/acarsdec-2.4#make -f MakefileRC
root@beaglebone:~/acarsdec-3.0# make
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o main.o main.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o acarsdec.o acarsdec.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o acars.o acars.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o acars.o acars.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o msk.o msk.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o msk.o msk.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o rtl.o rtl.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o rtl.o rtl.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o output.o output.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o output.o output.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o soundfile.o soundfile.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o soundfile.o soundfile.c
cc -flto -O3 -ffast-math -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=neon -D WITH_RTL -D WITH_SNDFILE   -c -o alsa.o alsa.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o alsa.o alsa.c
cc main.o acars.o msk.o rtl.o output.o soundfile.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr -lsndfile -lasound -lrt
cc acarsdec.o acars.o msk.o rtl.o output.o soundfile.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr -lsndfile -lasound
root@radarcape:~/acarsdec-2.4#
</source>
</source>


In order to execute it for the first, time you should set LD_LIBRARY_PATH. For later restarts, one time write /usr/local/lib into /etc/ld.so.conf, which will be active after the next reboot. (see: [http://www.linux-praxis.de/lpic1/lpi101/1.102.4.html])
In order to execute it for the first, time you need to set LD_LIBRARY_PATH. For later restarts, this one time write /usr/local/lib into /etc/ld.so.conf, which will be active after the next reboot. (see: [http://www.linux-praxis.de/lpic1/lpi101/1.102.4.html])
<source lang="bash">
<source lang="bash">
echo "/usr/local/lib" > /etc/ld.so.conf
echo "/usr/local/lib" > /etc/ld.so.conf

Latest revision as of 18:15, 15 September 2016


acarsdec on the Radarcape

acarsdec is a software which uses a DVB-T stick in order to decode up to 4 channel with ACARS signals within a 1MHz band segment. The front panel extension port of the Radarcape may be used to plug such a DVB-T stick.
The decoding process requires some mathematical functions and obtains plenty of processing resources. Due to that it is not guaranteed to run on a heavily loaded Radarcape and/or together with Mode-AC or FR24 feeder. You may need to disable some features.

Installation requires some skills in handling a console but at the end is easy.

The original places where to find the used components are

Installation requires some skills in handling a console and edit files, but at the end is easy.


Installation on a Debian distribution based Radarcape

Prepare Installation (Debian)

First, you need to install build tools on the Radarcape. You may need to enter one line after the other separately.

apt-get update
apt-get upgrade -y
apt-get install -y build-essential cmake git libusb-1.0-0-dev
sync

This will take some time.


Install librtlsdr (Debian)

Install rtl-sdr library. You need to blacklist the kernel DVB-T stick driver before using this new driver.

echo blacklist dvb_usb_rtl28xxu >> /etc/modprobe.d/fbdev-blacklist.conf

Then you are ready to build and install the library.

git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
make install
ldconfig -v
cd ..
cp -v rtl-sdr.rules /etc/udev/rules.d/
sync


After this step, reboot your Radarcape without DVB-T stick connected. Wait a few 10 seconds, plug your stick and check with command dmesg if the stick became recognized correctly:

Relevant dmesg output after DVB-T stick was plugged
Relevant dmesg output after DVB-T stick was plugged


Next, check with the command rtl_test if it works:

root@rc66:~# rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
lost at least 232 bytes

One 'lost' message is ok during startup, but there should none appear later.

Install acarsdec (Debian)

With a simple cd command, go back into your root folder.

acarsdec source package can be found on sourceforge. There is a green button with the latest version, click on it and then look for the ' direct link ', which you should cut & paste, edit and execute with wget like shown below.After uncompressing the archive, change to the folder that became created by tar.

Note that at the time of writing version 3.2 was latest, it might be different sometimes later.

cd
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/3.2/acarsdec-3.2.tar.gz
tar xvf acarsdec-3.2.tar.gz
cd acarsdec-3.2


Now it comes... the complicated part is that ALSA lib is not necessary for the build here, and it seems that the Angstrom distribution that is used on the Radarcape has a different library structure.
That means you need to edit the Makefile:

  • comment out all lines with CFLAGS with a # sign in the first column.
  • insert a new CFLAGS line
CFLAGS= -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL
  • in the line showing LDLIBS, remove -lasound, so it looks like
modified: LDLIBS=  -lm -pthread  -lrtlsdr

Start compilation with the command make

You then should see some output like this:

root@radarcape:~/acarsdec-3.2# make
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o acarsdec.o acarsdec.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o acars.o acars.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o msk.o msk.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o rtl.o rtl.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o air.o air.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o output.o output.c
cc -g -O3 -flto -mcpu=cortex-a8 -mfpu=vfpv3 -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE   -c -o alsa.o alsa.c
cc acarsdec.o acars.o msk.o rtl.o air.o output.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr

Execute acarsdec. It might be good if you don't see messages from specific frequency to leave them out from decoding. The command also needs to be modified for networking according to its original description if you like to send decoded messages to other computers.

./acarsdec -o1 -v -p 79 -g 400 -r 0 131.725

And now you will see its output.

root@radarcape:~/acarsdec-3.2# ./acarsdec -o1 -v -p 79 -g 400 -r 0 131.525 131.725 131.825        
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain : 40.200000
Set center freq. to 131750000Hz
Exact sample rate is: 2500000.107620 Hz
Decoding 1 channels
#1 (L:-32 E:0) 08/09/2016 10:34:58 .A6-EDU EK0015 2 Q0 S76A 
#1 (L:-38 E:0) 08/09/2016 10:34:59 .PH-BXK KL1652 G 10 M67A ETA93A08103456KLM1652 LIPZEHA
#1 too many parity errors
#1 (L:-33 E:0) 08/09/2016 10:35:06 .A6-EDU EK0015 2 Q0 S76A


Tweaking (Debian)

Probably it makes sense to disable automatic power savings on the CPU.

apt-get update
apt-get install -y cpufrequtils
cpufreq-set -g performance

This is not automatically permanent.



Installation on an Angstrom distribution based Radarcape (may work)

Angstrom is outdated and this description is only hold for completeness. Especially because Debian is able to use the floating point unit of the ARM, for Acarsdec Debian is strongly recommended.

Prepare Installation (Angstrom)

First, you need to install build tools on the Radarcape.

opkg update
opkg install packagegroup-core-buildessential
opkg install cmake
opkg install libusb-1.0-dev
opkg install libsndfile-dev
sync

This will take some time.

If problems appear somehow around something that is led_aging or so, mind this link https://www.mail-archive.com/[email protected]/msg15617.html

Install librtlsdr (Angstrom)

Download one of the packaged releases: Look for the eventually greyed .tar.gz text, cut & paste the link of it and fetch it with wget on your Radarcape (in this case it is version 0.5.3, which was current while writing this descrition):

wget --no-check-certificate https://github.com/steve-m/librtlsdr/archive/v0.5.3.tar.gz

Untar/unpack it. Note that the filename eventually may differ for your download

tar xvf v0.5.3.tar.gz

As described here, navigate to ' Building with cmake: ' and follow these steps. You don't need sudo, as you are already root user on your Radarcape. The first command 'cd' must be adopted to what you have got as folder when unpacking your archive in the latest step.

cd librtlsdr-0.5.3
mkdir build
cd build
cmake ../
make
make install
ldconfig

Install acarsdec (Angstrom)

acarsdec source package can be found on sourceforge. There is a nice green button with the latest version, click on it and then look for the ' direct link ', which you should cut & paste, edit and execute with wget like shown below.
But before, with a simple cd, go back into your root folder. After uncompressing the archive, change to the folder that became created by tar

cd
wget http://downloads.sourceforge.net/project/acarsdec/acarsdec/3.0/acarsdec-3.0.tar.gz
tar xvf acarsdec-3.0.tar.gz
cd acarsdec-3.0

Now it comes... the complicated part is that ALSA lib is not necessary for the build here. Remove -D WITH_ALSA from the CFLAGS line. Next, I found that with different compiler options the CPU load is about one third of the original ones.

original: CFLAGS= -g -Ofast -ftree-vectorize -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE -D WITH_ALSA
modified: CFLAGS= -g -O3 -flto -funroll-loops -ffast-math -pthread -D WITH_RTL -D WITH_SNDFILE

You then should see some output like this:

root@beaglebone:~/acarsdec-3.0# make
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o acarsdec.o acarsdec.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o acars.o acars.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o msk.o msk.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o rtl.o rtl.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o output.o output.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o soundfile.o soundfile.c
cc -O3 -flto -ffast-math -funroll-loops -pthread -D WITH_RTL -D WITH_SNDFILE     -c -o alsa.o alsa.c
cc acarsdec.o acars.o msk.o rtl.o output.o soundfile.o alsa.o -o acarsdec -lm -pthread  -lrtlsdr -lsndfile -lasound

In order to execute it for the first, time you need to set LD_LIBRARY_PATH. For later restarts, this one time write /usr/local/lib into /etc/ld.so.conf, which will be active after the next reboot. (see: [1])

echo "/usr/local/lib" > /etc/ld.so.conf
ldconfig
export LD_LIBRARY_PATH=/usr/local/lib

Execute acarsdec. My stick has +79ppm offset and the gain is fixed to 40dB. With the 3 channels that are active within the decodeable 1MHz segment here, the CPU load is just 35%. That fits to a running Radarcape, if not too busy with Mode-AC. In case of doubts, open another ssh terminal and execute htop command there.

The command needs to be modified for networking according to its original description if you like to send decoded messages to other computers.

./acarsdec -o1 -v -p 79 -g 400 -r 0 131.525 131.725 131.825

And now you will see its output.

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain : 40.200000
Set center freq. to 131850000Hz
Exact sample rate is: 1000000.026491 Hz
Decoding 3 channels
#2 too many parity errors
#3 (L:-21 E:0) 02/01/2000 04:25:07 .OY-KBH SK0610 2 B9 M36A /EKCH.TI2/040EKCHAC5B3
#1 (L:-20 E:0) 02/01/2000 04:25:12 .D-AILA LH03RV R 1L M74A 02467226782VUYY93,EBB*14GK0
#2 parity error(s): 2
#2 crc error
#2 not able to fix errors
#3 (L:-21 E:0) 02/01/2000 04:25:14 .OY-KBH SK0610 2 _d S88A 
#1 (L:-25 E:0) 02/01/2000 04:25:17 .G-BNWM BA0155 2 Q0 S09A 
#1 (L:-20 E:0) 02/01/2000 04:25:18 .D-AILA LH03RV R _d S35A 
#1 (L:-19 E:0) 02/01/2000 04:25:21 .D-AILA LH03RV R _d S36A 
#2 (L:-28 E:0) 02/01/2000 04:25:22 .D-AICC DE03FC X _d S58A 
#2 (L: -3 E:0) 02/01/2000 04:25:29 .PH-TFC OR0717 E Q0 S11A 
#3 (L:-22 E:0) 02/01/2000 04:25:29 .OY-KBH SK0610 2 _d S89A