A lightweight RDS decoder
C++ Other
Latest commit 0d272d6 Feb 11, 2017 @windytan typo
Permalink
Failed to load latest commit information.
iconvpp iconvpp by unnonouno Dec 7, 2016
json use jsoncpp as serializer Nov 23, 2016
src 14B Dec 25, 2016
.travis.yml newer versions Sep 25, 2016
CHANGES.md typo Feb 11, 2017
LICENSE callsign Nov 28, 2016
Makefile.am version prerequisites etc Jun 21, 2016
README.md oneliners Feb 1, 2017
autogen.sh autogen.sh Sep 25, 2016
configure.ac 0.9.1 Feb 11, 2017
rtl-rx.sh assume redsea will be make installed Jan 25, 2017
schema.json disambiguate lat & lon Dec 11, 2016

README.md

redsea

redsea is a lightweight command-line RDS decoder for Linux/OSX. It works with any RTL-SDR USB radio stick using the rtl_fm tool. It can also decode raw ASCII bitstream, the hex format used by RDS Spy, and multiplex signals (MPX).

RDS groups are printed to the terminal as line-delimited JSON objects or, optionally, undecoded hex blocks (-x).

Redsea has been successfully compiled on Linux (Ubuntu 14.04, Raspbian Jessie) and OSX (10.10).

Build Status

Compiling

You will need git, the liquid-dsp library, and GNU autotools. On OSX/macOS you will also need XCode command-line tools (xcode-select --install).

  1. Clone the repository (unless you downloaded a release zip file):

    $ git clone https://github.com/windytan/redsea.git
    $ cd redsea
    
  2. Compile redsea:

    $ ./autogen.sh && ./configure && make
    
  3. Install:

    $ make install
    

Updating with the newest changes later:

    $ git pull
    $ ./autogen.sh && ./configure && make clean && make
    $ make install

For a slower machine it can take some time to compile the TMC support. This can be disabled (./configure --disable-tmc).

If you only need to decode hex or binary input and don't need demodulation, you can compile redsea without liquid-dsp (./configure --without-liquid).

Usage

Live decoding with rtl_fm

The full command is:

$ rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 40 -F 9 -f 87.9M | redsea

There's a shorthand shell script called rtl-rx.sh:

$ ./rtl-rx.sh -f 87.9M

Command line options to this script are passed on to rtl_fm. Station frequency (-f) is mandatory. It may also be helpful to set -p to the ppm error in the crystal. Gain is set to 40 dB by default. The script can be modified to include additional parameters to redsea as well.

For Raspberry Pi 1 it's necessary to change -A std to -A fast. This changes the arctan calculation in the FM demodulator to a fast integer approximation, so that more cycles will be left to redsea.

Note that rtl_fm will tune a bit off; this is expected behavior and is done to avoid the DC spike.

Decoding MPX from a file or via sound card

If you have sox installed, it's easy to decode audio files containing a demodulated FM carrier. Note that the file must have around 128k samples per second or more.

$ sox multiplex.wav -t .s16 -r 171k -c 1 - | redsea

If your sound card supports recording at high sample rates (e.g. 192 kHz) you can also decode the MPX output of an FM tuner or RDS encoder:

$ rec -t .s16 -r 171k -c 1 - | redsea

Tips for output formatting

The JSON output can be tidied and/or colored using jq:

$ ./rtl-rx.sh -f 87.9M | jq

It can also be used to extract only certain fields, for instance the program type:

$ ./rtl-rx.sh -f 87.9M | jq '.prog_type'

The output can be timestamped using ts, found in moreutils:

$ ./rtl-rx.sh -f 87.9M | ts

This timestamp can be formatted using strftime style format strings, see man ts and man strftime.

Full usage

radio_command | redsea [OPTIONS]

-b, --input-ascii      Input is ASCII bit stream (011010110...)
-e, --feed-through     Echo the input signal to stdout and print decoded groups
                       to stderr
-h, --input-hex        Input is hex groups in the RDS Spy format
-x, --output-hex       Output is hex groups in the RDS Spy format
-p. --show-partial     Display PS and RadioText before completely received (as
                       partial_ps, partial_radiotext)
-u, --rbds             Use RBDS (North American) program types
-l, --loctable DIR     Load TMC location table from a directory in TMC Exchange
                       format
-v, --version          Print version

By default, the input (via stdin) is demodulated FM multiplex (MPX) with 16-bit mono samples at 171 kHz. The output format defaults to newline-delimited JSON.

Requirements

  • Linux/OSX
  • C++11 compiler
  • GNU autotools
  • libiconv
  • liquid-dsp
  • rtl_fm (from rtl-sdr) or any other source that can output demodulated FM multiplex signals

Features

Redsea decodes the following basic info from RDS:

  • Program Identification code (PI)
  • Program Service name (PS)
  • RadioText (RT)
  • Traffic Program (TP) and Traffic Announcement (TA) flags
  • Music/Speech (M/S) flag
  • Program Type (PTY)
  • Alternative Frequencies (AF)
  • Clock Time and Date (CT)
  • Program Item Number (PIN)
  • Enhanced Other Networks (EON) information

And also these Open Data Applications:

  • RadioText Plus (RT+)
  • Traffic Message Channel (TMC)

Contributing

Bug reports are welcome. Also, if a station in your area is transmitting an interesting Open Data application that should be implemented in redsea, I would be happy to see a minute or two's worth of hex data using the -x switch.

Licensing

Redsea is released under the MIT license, which means it is copyrighted to Oona Räisänen OH2EIQ yet you're free to use it provided that the copyright information is not removed. (jsoncpp and iconvpp have their own licenses.) See LICENSE.