Packet Radio: AX25, Direwolf and Linpac on a Raspberry Pi

I’ve been playing around trying to get a working config for using Direwolf as a soundcard modem for packet radio on the Raspberry Pi. I’ve played with getting ax25 and Direwolf running on Ubuntu (see here), and then I tried to copy across what I’d learnt to the Pi (running Raspbian).

The trouble with a lot of this stuff is there’s not much in the way of docs (although the Direwolf docs are really good), so when things don’t work you either start trying stuff randomly or just get stuck. Anyway, here’s the combination I have working:

  • Raspberry Pi (v1 model B) running Raspbian
  • RigBlaster connected via USB, connected to an Icom 880h
  • soundlevels at around 3/4 via alsamixer
  • Per ax25 on CentOS here, I used the ax25 sources from VE7FET’s github repo, compiled and installed

Most of my steps are the same as from my prior experience getting Direwolf and Linpac working on Ubuntu, so follow those steps if you’re looking to get setup, and then I’ve summarized the differences here.

The VE7FET source when you ‘sudo make install’ creates config files to /usr/local/etc/ax25 and not the default location of /etc/ax25. I’m not sure if Linpac likes this, so per a posting I found somewhere, the quick way to keep everyone happy is just create a symlink:

cd /etc/
sudo ln -s /usr/local/etc/ax25 .

Edit the axports file, add a line like:

1 KK6DCT-2 38400 253 2 2m packet

‘1’ is the portname

On the Pi I did run into the kissattach issue getting the ‘error setting line discipline’ error as described in the direwolf docs. Per the docs, I used the second of the workarounds:

sudo /usr/sbin/kissattach /dev/ptmx radio 44.56.4.118

then:

sudo mkiss /tmp/kisstnc /dev/pts/5

where the /dev/pts/5 value is returned from the kissattach step.

At this point I’m ready to go:

‘call 1 kberr’ opens a connection to my nearest node (using port 1)

And also Linpac starts up (with linpac -m), can can connect the same there with ‘:c kberr’

At some point I should probably walk through these steps with a fresh Raspbian install to confirm I didn’t change anything else along the way that was key to getting this to work, but I think this summarizes the key points.

A few other helpful points:

  • in the Mac Terminal app by default, the Alt key doesn’t work so can’t do a Alt-X to exit Linpac. There’s a tip here to enable the Option key as Alt so you can use this to cleanly exit Linpac.

Linux, Direwolf packet radio and alsa sound levels

Getting soundcard levels with alsasound on Linux dialed in for any Amateur Radio soundcard based comms can be tricky (at least in my experience).

If you’ve plugged in an additional USB soundcard device like a Rigblaster or a SignaLink, it’s important to know that the ‘master’ volume level in alsamixer applies to all soudcards. Make sure you have the master volume up, in addition to the soundcard that you have going to your transceiver.

Here’s what the default soundcard alsamixer display looks like for me – notice the master volume not muted (MM = muted), and level around 3/4:

Press F6 to switch/select the USB Rigblaster device levels.

Here’s alsamixer for Rigblaster USB soundcards, playback/output (F3) at 3/4:

Capture/input (F4) at 3/4:

Direwolf soundcard packet on Linux, with ax25 and LinPac

I’ve been playing around with Direwolf soundcard packet radio decoder on Linux. On Windows I use the packet terminal app that comes with the UZ7 soundcard modem, which you can connect to Direwolf’s AGW port over a network. The only comparable app on Linux that I’ve found seems to be LinPac.

Linpac connects over an ax25 port. To get LinPac to connect to Direwolf there’s a few steps to jump through.

Install Direwolf

Download the source from: https://home.comcast.net/~wb2osz/site/?/home/

(or after Oct 8 2015, https://github.com/wb2osz/direwolf)

Install libasound2-dev:

sudo apt-get install libasound2-dev

Compile Direwolf:

make
sudo make install

If you get this error when compiling Direwolf then you missed the libasound-dev step:

audio.c:80:28: fatal error: alsa/asoundlib.h: No such file or directory
#include <alsa/asoundlib.h>

Copy the supplied direwolf.conf file (from the downloaded source) to your home dir. To find out what input and output sound devices you have, run

aplay - l

and

arecord -l

You’ll see something like this:

**** List of CAPTURE Hardware Devices ****

card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]

  Subdevices: 1/1

  Subdevice #0: subdevice #0

card 0: NVidia [HDA NVidia], device 2: ALC1200 Alt Analog [ALC1200 Alt Analog]

  Subdevices: 1/1

  Subdevice #0: subdevice #0

Get the device numbers for the soundcard you are using and edit direwolf.conf. For device 0 subdevice 0, edit this line and set 0,0:

ADEVICE  plughw:0,0

Using a Rigblaster Plug and Play on Ubuntu 14.04, it was automatically recognized and showed up per the docs on /dev/ttyUSB0. Direwolf will use this for PTT on your radio. I uncommented this line to enable this:

PTT /dev/ttyUSB0 RTS

To give my current user access to ttyUSB0 (and avoid running with sudo) I had to add my user to the dialout group (per post here):

sudo usermod -a -G dialout $USER

Start up alsamixer and make sure the mic inputs and outputs are not muted (M), and the volume levels are around 3/4.

Install the ax25 network suport:

sudo apt-get install libax25 ax25-apps ax25-tools

To enable an ax25port, edit /etc/ax25/axports, I added a line like this:

1 KK6DCT-1 1200 255 2 2m packet

The first column is the port name. Start up direwolf with the -p option to enable a KISS port, you’ll see something like this (-t 0 t0 suppress the colors):

kev@kevs-ubuntu:~$ direwolf -t 0 -p
Dire Wolf version 1.2
Audio device for both receive and transmit: plughw:0,0  (channel 0)
Channel 0: 1200 baud, AFSK 1200 & 2200 Hz, E+, 44100 sample rate.
Ready to accept AGW client application 0 on port 8000 ...
Ready to accept KISS client application on port 8001 ...
Virtual KISS TNC is available on /dev/pts/0
WARNING - Dire Wolf will hang eventually if nothing is reading from it.
Created symlink /tmp/kisstnc -> /dev/pts/0

Note the /dev/pts/X value, and use this with a kissattach command to connect Direwolf to ax25:

sudo /usr/sbin/kissattach /dev/pts/0 1 44.56.4.118

The 1 value following /dev/pts/0 is the port number from the axports file.

Per the Direwolf PDF doc, if you see this error:

kissattach: Error setting line discipline: TIOCSETD: Device or resource busy
Are you sure you have enabled MKISS support in the kernel
or, if you made it a module, that the module is loaded?

Then try this instead:

sudo /usr/sbin/kissattach /dev/pts/ptmx 1 44.56.4.118

Install LinPac

Download the LinPac source. Build and install:

./configure
make
make install

The first time you startup LinPac it creates a LinPac dir in your home folder. Edit macro/init.mac in this folder and change the port value to match the port name from your axports change (1 in the above example):

;; Default port
port 1

Start LinPac with:

linpac -m

(I’m not sure what the -m option is for, I found this in a post online, but without it I get errors on startup about ax25 port not found).

Connect to a node with :c nodename

Done!

Configuring rtl_fm and Direwolf for decoding Amateur Radio Packet on the Raspberry Pi

rtl_fm is one of the utilities from the rtl_sdr package for using a TV dongle as an SDR. Head over here if you need more info on this.

Direwolf is a soundcard based packet modem.

According to the Direwolf docs, it supports using rtl_fm as an input, so I thought I would take a look at look at getting these running together.

I’ve used rtl_sdr and rtl_tcp on my Pi before, but not rtl_fm, so first to get this working.

To playback the stream from rtl_fm you need to pipe into into some audio app. This is the same way that direwolf is going to read the stream too. Following the suggestion here on the rtl_sdr page, this command works fine for a local broadcast radio station on 96.9MHz:

rtl_fm -f 96.9M -M wbfm -s 200000 -r 48000 | play -r 48000 -t s16 -L -c 1  -

I’m not sure what all these options are, but the key options seem to be -s for the sample rate, and -r for the resolution. The -r value needs to match on the rtl_fm side and on the play side.

Now to get direwolf installed on Raspbian:

– per the userguide, first install libasound-dev:

[code]sudo apt-get install libasound-dev[/code]

– download the source zip from: https://home.comcast.net/~wb2osz/site/?/page/Download/

– unzip and cd into the direwolf folder

– make with:

[code]make -f Makefile.linux

make install-conf

make install_rpi[/code]

At this point I have rtl_fm on the Pi working as it should, and direwolf working great when decoding audio input from a 2m radio input via a USB soundcard. Combining the two though is giving me issues.

I don’t thing I’m able to get a strong enough received signal on 2m on the RTL stick even with an external 1/4wave 2m antenna.

This is the combination of commands, rtl_fm, piping into Direwolf:


[code]rtl_fm -f 145048467 -M fm -s 200000 -r 32000 -g 35 | direwolf -n 1 -r 32000 -b 16 -t 0 -[/code]

I’ve allowed for the tuning offset ppm on this RTL card, but maybe I’ve calculated this wrong?

Anyway, since Direwolf by itself on the Pi is working well and what I needed for a small packet project was to be able to decode packet on the Pi, I’ll be putting rtl_fm on hold for the time being and playing with Direwolf by itself.