Willkommen bei bytebang » The blog about all and nothing » Receive APRS stations with rtl-str and display them with Xastir

Receive APRS stations with rtl-str and display them with Xastir

Okt 26 2014

The Automated Packet Reporting System is an ham radio based system for real time tactical digital communications of information of immediate value in the local area. This means in other words that along with messages, alerts, announcements, and bulletins, the most visible aspect of APRS is its ability to be display weather stations, alerts and objects and other map-related amateur radio volunteer activities on a map.

Well - there are services like aprs.fi which are able to display such a map within your browser, but once the internet goes down this map will also dissapear. So what are the alternatives ? ... The answer is simple: Receive the aprs traffic on your own and draw them onto a offline available map. This article shows how to recieve the messages with a cheap dvbt stick, how to decode them into aprs messages and finally how to display them within Xastir (which is a program for visualizing APRS packets).

Step 1: Recieve APRS with rtl_fm

The first thing that you need to know about APRS is the frequency where you can pick up the messages. According tho the official APRS webpage the frequency within europe is 144.8MHz. Fortunately this frequency can be received with a cheap DVB-T stick (around 20€ incl. shipping) wich is supported by rtl-sdr. So the good news are: you dont need to have specialized hardware to receive the messages. Lets get it on:

Install rtl_sdr on your computer. Under ubuntu 14.04 this is really simple:

$sudo apt-get install rtl-sdr

If you are running another OS then you propaby have to download the sourcecode from the osmocom git reporitory and you have to build it by yourself. An exapmple how to do this is given on the rtl-sdr homepage.

Once you managed to install the rtl_sdr software on your machine you can connect the stick to your machine and try to receive the aprs messages:

rtl_fm -f 144.8e6  -s 200000 -r 48000 - | aplay -r 48k -f S16_LE

This command tells rtl_fm to listen on the frequency 144.8 MHz and to pipe the fm_demodulated samples to the aplay command - which picks the samples up and play them on your speakers. From time to time you should be able to hear a kind of chirp - which are the aprs packages we are interested in. If you are not hearing anything then it meight be possible that your operatingsystem has loaded a driver for the dvbt stick. Then you have to remove the driver from the kernel and try again:

gue@gue-thinkpad:~$ rtl_fm -f 144.8e6  -s 200000 -r 48000 - | aplay -r 48k -f S16_LE
Found 1 device(s):

-: (s2)

  Encoding: Signed PCM    
  Channels: 1 @ 16-bit   
Samplerate: 22050Hz      
Replaygain: off         
  Duration: unknown      

In:0.00% 00:00:00.00 [00:00:00.00] Out:0     [      |      ]        Clip:0      0:  Realtek, DVB-T Dongle, SN: 00000991

Using device 0: Dexatek DK DVB-T Dongle (Logilink VG0002A)

Kernel driver is active, or device is claimed by second instance of librtlsdr.
In the first case, please either detach or blacklist the kernel module
(dvb_usb_rtl28xxu), or enable automatic detaching at compile time.

usb_claim_interface error -6
Failed to open rtlsdr device #0.
In:0.00% 00:00:00.00 [00:00:00.00] Out:0     [      |      ]        Clip:0    
Done.
gue@gue-thinkpad:~$ sudo rmmod dvb_usb_rtl28xxu
[sudo] password for gue:
gue@gue-thinkpad:~$ 

After that you should be able to reveive fm stations around you. Here is a link to the rtl_fm_demod guide which shows what is possible with this setup.

Step 2: Decode the Packets to text with multimon-ng

The next step is to decode the received packets. This can be done with a lot of tools, but in order to reach our goal we need to do it commandline-based. This limits the choice of tools somehow. One possible candidate ist multimon which is capable of decoding the typical 1200 Baud AFSK packets into text. Lets give it a try by telling rtl_fm to output the samples again on the stdout and by telling multimon to read its sample from stdin. By piping these two processes togeter we get a lossless transfer of audio data between two processes without the use of additional software.

gue@gue-thinkpad:~/Documents/cool_stuff/multimonNG/build$ rtl_fm -f 144800000 -s 22050 -o 4 -g 100 -C - |  multimon -a AFSK1200 -t raw /dev/stdin
multimod  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA
available demodulators: POCSAG512 POCSAG1200 POCSAG2400 EAS AFSK1200 AFSK2400 AFSK2400_2 HAPN4800 FSK9600 DTMF ZVEI CCIR SCOPE
Enabled demodulators: AFSK1200
Found 1 device(s):
  0:  Realtek, DVB-T Dongle, SN: 00000991

Using device 0: Dexatek DK DVB-T Dongle (Logilink VG0002A)
Found Fitipower FC0013 tuner
Oversampling input by: 12x.
Oversampling output by: 4x.
Buffer size: 7.74ms
Tuned to 145064600 Hz.
Sampling at 1058400 Hz.
Output at 22050 Hz.
Exact sample rate is: 1058400.010094 Hz
Tuner gain set to 19.70 dB.
AFSK1200: fm S50AL-7 to TV2P85-0 via S59GCD-12,WIDE-0,OE6XLR-11,WIDE2-0 UI  pid=F0
`+^ZnRw>/** op . Andi **
AFSK1200: fm S59ACM-11 to APNU19-0 via OE6XLR-11,WIDE3-1 UI^ pid=F0
!4601.34N/01354.35E#/(RELAY-UIDIGI1.9B3-)3
AFSK1200: fm OE6XAR-11 to APRSOE-0 via OE6XLR-11,WIDE1-0,WIDE2-2 UI^ pid=F0
!4715.93N/01422.72E#*** www.qth.at/oe6xar ***
AFSK1200: fm S51BJ-9 to APU25N-0 via OE6XLR-11,WIDE2-0,-0 UI  pid=F0
!4634.20N/01535.21E>070/000/A=000987m5 KRIZEVCI PRI LJUT.JOZE JN86BN
AFSK1200: fm S57R-12 to APND0Z-0 via S59GCD-12,OE6XLR-11,WIDE2-1 UIv pid=F0
=4630.83NN01511.27E#DIGI_NED: Sys s52zo, Mala Kopa-JN76OM-1524m ASL
.
.
.

OK - not bad, but it doesnt look like the specified format of APRS that is sent over the air. Those should look somehow like this. If we take a closer look then we can see that all the data is here but it would be too much effort do rebuild the original fromat from this output. So lets try another decoder: multimon-ng.

After having it downloaded, compiled and installed (like shown on their website) we can start it together with rtl_fm like that:

gue@gue-thinkpad:~$rtl_fm -f 144800000 -s 22050 -o 4 -g 100 -C - | multimon-ng -a AFSK1200 -A -t raw -
multimon-ng  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA
             (C) 2012-2014 by Elias Oenal
available demodulators: POCSAG512 POCSAG1200 POCSAG2400 EAS UFSK1200 CLIPFSK AFSK1200 AFSK2400 AFSK2400_2 AFSK2400_3 HAPN4800 FSK9600 DTMF ZVEI1
ZVEI2 ZVEI3 DZVEI PZVEI EEA EIA CCIR MORSE_CW DUMPCSV SCOPE
Enabled demodulators: AFSK1200
Found 1 device(s):
  0:  Realtek, DVB-T Dongle, SN: 00000991

Using device 0: Dexatek DK DVB-T Dongle (Logilink VG0002A)
Found Fitipower FC0013 tuner
Oversampling input by: 12x.
Oversampling output by: 4x.
Buffer size: 7.74ms
Tuned to 145064600 Hz.
Sampling at 1058400 Hz.
Output at 22050 Hz.
Exact sample rate is: 1058400.010094 Hz
Tuner gain set to 19.70 dB.
APRS: OE6XRR>APWS,OE6XLR-11*,WIDE2-1:@282340z4705.32N/01523.15E_000/000g000t041r000p000P000h91b10284v000/Weatherstation
APRS: HG5PGE-2>APNU19,OE6XTR*,OE6XLR-11*,WIDE2-1:>Uidigi v1.9b3 P:5W Ant:3dB-omni ASL:650m www.ha5kdr.hu
APRS: OE2HLM-7>4W2S24,OE6XLR-11*,WIDE1*,WIDE2-2:`*RGrr[>/`":u}OE2HLM & OE2BRN QRV 145,300 MHz             _
APRS: OK2ULQ-5>APEWX0,OE6XTR*,OE6XLR-11*,WIDE2*:!4924.02N/01746.09E_.../...g...t038; 03,5C;XPic QTH Kelcsky Javornik, 865m ASL
APRS: OE8KKK-11>APMI01,OE8XDR-11*,OE6XLR-11*,WIDE2*:@261806z4631.75N/01419.04E#100%SolarPower/Digipeater,I-Gate
.
.
.

In this output we can see two things:

  • multimon-ng is able to decode a wide range of protocols which makes it pretty versatile. If you dig deeper in the internet then you will discover that multimon-ng is used to decode pager masseges, DTMF codes, morse code and much more.
  • The output is VERY close to the original APRS format. To be more precise - we just have to strip the first 6 characters from evey line and then we are done. This can be done by invoking sed like this: sed -u -r 's/^.{6}' This instructs sed to disable buffering and to strip the first 6 characters of every line. The result looks like this:
gue@gue-thinkpad:~/Documents/cool_stuff/multimonNG/build$ rtl_fm -f 144800000 -s 22050 -o 4 -g 100 -C - | multimon-ng -a AFSK1200 -A -t raw - | sed -u -r 's/^.{6}//'
.
.
.
OK2ULQ-5>APEWX0,OE6XTR*,OE6XLR-11*,WIDE2*:!4924.02N/01746.09E_.../...g...t038; 03,6C;XPic QTH Kelcsky Javornik, 865m ASL
OK1VCF-5>APEWX0,OK4PZ-2*,WIDE1*,OE6XTR*,OE6XLR-11*,WIDE3*:!4930.59N/01426.89E_000/000g000t046b10349h94XPIC 16F628mod+12F675wx
OE8KKK-11>APMI01,OE8XDR-11*,OE6XLR-11*,WIDE2*:@261816z4631.75N/01419.04E#100%SolarPower/Digipeater,I-Gate
S59DGO-5>BEACON,OE6XLR-11*,WIDE2*:;145.625kp*261816z4546.30N/01403.20ErToff R50k
OE6XZG>APNU19-3,OE6XLR-11*,WIDE2*:!4711.87NF01527.91E# W1-1 Fill in Digi

Bingo that is the original format of the APRS packets !
Sidenote: If you dont like sed for whatever reason then you can apply this patch before you compile multimon-ng which makes the packets to appear exactly in the wanted format.

Step 3: Fire up a server where Xastir can connect to

Since we are now able to receive APRS packets in their original format we can think about setting up a network server where Xastir can connect to and grab the packets. This can be done with socat - which is a kind of netcat on stereoids. The following commandline pipes the APRS messages into a server that listens on port 14580 on the localhost.

gue@gue-thinkpad:~$ rtl_fm -f 144800000 -s 22050 -o 4 -g 100 -C - | multimon-ng -a AFSK1200 -A -t raw - | sed -u -r 's/^.{6}//' | socat STDIN TCP-LISTEN:14580,reuseaddr,fork 

While we are using socat only to setup a simple TCP/IP server it can also be used to create a PTY interface or many other useful things - including the creation of a PTY which can be accessed by all hamradio programs that are requiring a serial connection (RS232) to a device.

Step 4: Configure Xastir

Xastir can be installed from the standard repositories in ubuntu.

gue@gue-thinkpad:~$ sudo apt-get install xastir 

Once you have installed it you have to enter some initial settings like your unique HAM callsign, the location of your home QTH or the map that you want to use. While you can provide your own maps there is also the possibility to download maps on demand. I personally use the "Online/OSM_tiles_mapnik" map, because it fulfills all my needs.

The next setp is to configure Xastir to listen to your server (which you have hopefully started as shown with the commandline from step 3). This is simple: Form Xastirs point of view our server is as good as any other server on the internet that delivers plain APRS packets. Just go to Interface -> Interface Control and add a new interface:

xastir_local_server.png

After that you should be able to start the interface and watch all the stations around you to appear, If you are also interested in the weather messages (WX) then you can enable them in the File menu (WX Logging). After you have waited a few minutes you should end up with a beautiful map that shows interesting data around you.

xastir_in_action.png

73 de OE6GUE

Get Social


(c) 2017, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen
-