APRS and Common Lisp

de SM6VYF/Arne.

Introduction

When λgtk (It's GTK in a Lispy way) appeared and as McCLIM didn't seem to fulfill my wishes, I finally had some tools to use to implement a graphical APRS client in Lisp (SBCL), using GTK+ under Linux. Since I've previously written a small APRS Internet server most of the parser code was already there, as were the KISS-mode code. However, I had to take on GTK+ for the first time.

Note: This is a work in progress (so far, so good), which means it might never be finished - and, of course, the source files should be made available.

Get SBCL!

So far...

General

Using APRS usually means watching icons representing stations heard over radio/internet being plotted on a map. An other obvious use is to send positions using radio/internet. Different APRS software have been developed over the years, starting with APRSdos and then WinAPRS & MacAPRS. One commonly used application today is UI-View. An open-source variant is Xastir. For my own part I've been doing some APRS software in both C and Perl/Tk, as well as Lisp.

Main window with map and station list.

Seeing that Lisp is a perfect tool to handle APRS data and given the abovementioned other tools a basic APRS implementation in Lisp is possible. In this implementation only one map can be used at a time. However, multiple interfaces can be accessed simultaneously; such as TNC:s and internet servers. Received data can be viewed in different lists and dialog boxes. It is also possible to create several stations, objects etc. and have data sent for them (N.Y.I.). Given Lisp other features are quite easily implemented.

Implementation

Main window

The picture to the right shows an expedia map that is displayed in the main window. Below the map there is a text scroll area to display incoming traffic, and two fields for information display. On top is the station list - other available lists include bulletin, telemetry, dx, weather. Topmost is the about dialog box.

Icons are displayed on the map using a GtkLayout object and the functions layout-put and layout-move. The icons are clickable (N.Y.I.) and can have (N.Y.I.) vectors to indicate speeds. To make the icons clickable transparent event boxes are probably needed and for the vectors...

The text scroll area displays incoming APRS data and the name of what interface the data came from. Every successfully parsed station or object position is displayed in the position information field and plotted on the map.

Menus

The menu allows the user to select edit own stations/objects data, select interfaces and map as well as to send position reports, messages etc.. The goal is to be able to send any of the following: Position, Object, Item, Weather, Telemetry, Message, Bulletin, Announcement, Capabilities, Query, Status, and User defined (most N.Y.I.).

Voice

Voice enables the announcement of newly heard stations using the Festival speech synthesis system (It's in there, but needs some tweaking...).

Interfaces

There is one subclass of interface for each of the two types of interfaces: ip and device. These two are combined with the three subclasses for the different formats: TNC2, AEA and the AX.25 KISS-mode. These classes have methods for set/reset, connect/disconnect, read/write and parse.

The init file contains a name for each interface, a host name, a port number, the interface type, and the format of the interface.

A possible addition would be to make an AFSK-demodulator in Lisp. I've already ported a FSK-demodulator to Lisp, but maybe it would be too tricky to make this work in real time here.

Maps

Maps can have a couple of different types and formats; image formats are the ones the gdk-pixbuf library handles. The maps are described in an init file including their type and this type's required parameters. The parameter values are loaded into an association list and used in a make-instance call. Map types implemented so far are:

Meteosat/GOES images from Dundee Satellite Receiving Station.
Linear images (e.g. some radar images).
Import of GpsDrive maps (e.g. expedia maps).
Swedish maps and orthophotos in RT 90 2.5 gon V 0:-15.
Horizons, e.g. photographic panoramas (cf. APRS & LiveGraphics3D).

New map formats are implemented defining subclasses to aprsmap and defining the three methods needed.

(defclass my-aprsmap (aprsmap)
  ((myslot :initarg :myslot :reader myslot :type float)
   ...))

(defmethod map-corners ((mapref my-aprsmap))
  ...)
(defmethod to-xy ((mapref my-aprsmap) lon lat)
  ...)
(defmethod to-ll ((mapref my-aprsmap) x y)
  ...)

map-corners is used to set up filter coordinates for APRS-IS connections. to-ll is only needed to translate from window coordinates to lat/lon. The important one is to-xy, used to plot on the screen.

Below is an example of the horizon map mode, where stations are plotted at the horizon according to bearing.

Horizon map mode

Lists

Data are presented in different lists: Position, bulletin, telemetry, dx, weather. Lists are clickable and, e.g., from the position list full data for the station will be displayed. The weather list is similar to the positioon list but displays weather data only. The other lists displays more or less raw data.

There are two implementation types of lists, one that appends data and one that inserts data (position and weather). Data for the insertion type lists are held in hash tables. Plain lists are used for the append type of lists.

Parser

The parser is the intricate Lisp/APRS meetplace. APRS packets read from the interfaces are parsed into an association list. The whole thing is really a hack, but considering the APRS syntax - could it be any different?

A simple example:

(parse-server-string "SM6VYF>APZ001,TCPIP,qAC,SM6VYF:!5743.60N/01146.43E-lambdaAPRS (SBCL v0.9.0)")

((:PATH "SM6VYF" "APZ001" ("TCPIP" "qAC" "SM6VYF"))
 (:SOFTWARE "Experimental" "001")
 (:PACKET . "!5743.60N/01146.43E-lambdaAPRS (SBCL v0.9.0)")
 (:TYPE . "Position without timestamp (no APRS messaging)") (:SYMBOL #\/ #\-)
 (:POS 57.726665 11.773833) (:COMMENT . "lambdaAPRS (SBCL v0.9.0)"))

Configuration

Fonts, colors and such settings are primarily handled using a GTK resource file. Interfaces and maps are described as mentioned above. On the system level there are also the asdf file and a top level configuration functions file for paths to resources, like the GpsDrive maps.

To come...

Lots, but mainly: last touch to messaging, clickable station icons on map, vector/track plotting, and automated position (and other) transmits. Not forgetting things marked N.Y.I. above.

This page was created from XML using libxslt.

Validate me!

CVS: $Date: 2005/06/30 18:15:51 $