A pocsag paging encoder for the Raspberry Pi

Also Gmail2Pager

Gascop is what I would call a 'thrown together' application. This is because it was written initially with no clear goal in mind. It is one of those applications that could really do with being rewritten, that may happen but don't hold your breath while waiting.
From here on RPi = Raspberry Pi.

UPDATE:- 30th March 2014
I do not have the time or health to carry on with this project. Therefore I am making the source code for Gascop and Gmail2Pager available to all.
Please respect me enough to give me the credit if you reuse my source code in any way at all.
Gascop depends on qt4, sdl and sdl_mixer.
You need to know how to compile Qt applications. See the qt website.
Simply you just need to run the following two commands to compile it crom the CLI.



I am NOT available for help of any kind, I am out exploring planet earth.

Gascop source gascop-2013.11.08-1sc.tar.gz
Gmail2Pager source gmail2pager-2013.11.08-1sc.tar.gz

This intructions on this page do work, I have installed from the instructions on this page and so have several other people with complete success.

So what can Gascop do?
Quite a bit for a small and simple application.
It can send immediate pages, pages for a particular date and time, repeat pages with repeat periods covering years if need be.
It can receive pages to send from any Gmail account allowing anyone with an internet connection to be able to send you a pager message.
It will efficiently stack multiple pager messages into a transmission.
It can send the pager messages to up to 8 different transmitters with individual keying for each transmitter.
It can do fast RIC/CAP code searching if you have a pager that you don't know the code of.
It displays the actual pocsag data that is sent.
It keeps a fully visible log of what is happening.
It has a database for the details of the pagers you have.
It has a database of all pager messages waiting to be sent that is always visible.
It can send 512, 1200 and 2400 baud pocsag.
Plus lots more...

I run Arch Linux ARM on my RPi, this is because I run Arch Linux on my main day to day computer as well.
If you would like help installing Arch Linux ARM on your RPi then download this text help file and follow the instructions, it will install your RPi through a series of scripts. This will also install Gascop and gmail2pager for you.
The installable package I have produced of Gascop is for Arch Linux ARM.
To install you just download the package and issue the command...

sudo pacman -U gascop-2013.11,08-1-armv6h.pkg.tar.xz
To download click here.

A picture is worth a thousand words...
Main Gascop Tab
As can be seen Gascop is a single application produced on multiple tabs. This is the main pager entry
tab. From here you can either send pages immediately or add pager messages to the database for
sending later. If the date and time are more than 30 seconds into the future then the message is sent
to the database for sending later otherwise it is sent immediately. The tiny button in the date box
resets the date and time to the current date and time.
Messages can be repeated forever or for a specific amount of times, repeat intervals can range from
minutes to years.
Any messages sent are placed into the previous message list and these can be selected for sending
again or can easily be deleted by pressing the Delete key while on an entry.

Gascop Ric Search Tab
Some pagers will show their RIC code by powering up with certain buttons pressed, but some don't.
This is where you can do fast RIC/CAP code searching. Here is a description of how to do this.
First set the time on your pager accurately by setting it on an exact minute. Set the RIC code to where
you want to start, set how many RICs you want to send in each transmission and how many
transmissions you want to make. Gascop will keep bumping the RIC code up as it goes.
You do NOT need to monitor the pager so you can leave it going over night if you wish.
When the pager goes off you will have the time that the 'tone only' page was received on the pager.
Take a look on the Gascop log tab for that time and it will tell you what RIC codes it was sending at that
time. Now set the Start RIC to the lowest RIC it could have been and check the box to 'send RIC to pager'
Start searching again and within a few transmissions the pager should go off displaying its RIC code.
Do NOT do the initial search with the 'Send RIC to pager' checked, it is much slower and will take up to
about 30 days to find a RIC whereas with it unchecked the whole seach for all possible 2 million RICs will
only take about 18 hours at 1200 baud.
The math for those interested.(This ignores the preamble time on each transmission)
2097151 RIC codes. 16 RIC codes per batch. At 1200 baud a batch + 1 sync takes 0.453 seconds.
A total of 131072 batches are required to hold 2097151 RICs. 131072x0.453=59375 seconds.
59375/60/60= 16.493 hours.

The Pocsag Data Tab
This tab shows the actual pocsag data that was sent in the last transmission. At the top it shows the
messages in the order they were taken from the database and at the bottom it shows the pages in
the order they were decoded i.e. the order they were stacked.

The Log File Tab
This is the log file and it is fully editable, only you know what you do and do not want in the log file so
remove and/or add information as you see fit.

The Pager IDs Tab
This is where you add/edit/remove pager IDs. If you want to allow others to send you pager messages
from the internet then the pager must be in this database. Predefining a pagers characteristics saves
time as you can just select the pager rather than having to set the characteristics each time you want
to send a message to that pager.

The Pager Msgs Tab1
This lists all the messages in the pager messages database that are waiting to be sent.
You can watch pages arriving and being sent from this view. There are two selections when you enter
this tab as can be seen in the next picture.

The Pager Msgs Tab2
If you select OK then you can delete pages from the database here but by selecting OK you have also
stopped the Gascop auto sending system from functioning while you edit.
If you select Cancel then the auto sending system continues to function and you can watch pages
going and coming but you cannot edit the database.

The Settings Tab
This is the settings tab.
Gascop checks for pages every 2 seconds going through all six baud rates listed for each transmitter
listed. You can test the keying of a transmitter here as well.
Some transmitters can take a few hundred milliseconds to key up and if this is the case you can enter
that delay here.

The keying makes use of the wiringPi application so this needs to be installed. Fortunately this is very
easy to do. First do this...
git clone git://
then do this...
cd wiringPi
then do this...
When prompted enter your password.
See the webpage for more information here...

Slice Of Pi
The keying is done using 8 GPIO pins on the RPi using the very cost effective 'Slice Of Pi' circuit board from
The circuit diagram and pictures below shows how I did this.
The keying is done with the little FET on the left of the board, This board handles 2 transmitters.
The transistor, Scmitt trigger and presets are for turning the sound output of the RPi into TTL level data.
You can modulate your transmitter directly from the sound out I just preferred ensuring the data was good
and square.
I used 1206 surface mount resistors but standard through-hole resistors will fit just as well.

To be honest a dedicated circuit board would have been easier but I just couldn't be bothered laying one up.


This is an additional application to go with Gascop, it checks a gmail account for messages in
a particular format that is compatible with Gascop.
You require a webpage for people to go to to enter the message they want to send you, the
script that this webpage uses sends an email in the Gascop format to you Gmail account and
Gmail2Pager picks these messages up and deletes them from your account (although they
are actually just sent to the bin/trash in Gmail).
The installable package I have produced of Gmail2Pager is for Arch Linux ARM.
To install you just download the package and issue the command...

sudo pacman -U gmail2pager-2013.11.08-1-armv6h.pkg.tar.xz
To download click here.

HTML and Perl CGI script
The html and perl cgi script below were taken from
But they have been modified to do the required job.

This is the html code required for the webpage, you just need to edit your name, gmail address and pager
names, that is all the items in red.
Also you need to set the path to where the perl cgi script is. (in blue)

<title>Send Pager Message To Mr. Smith</title>
<h2 align="center">Send Pager Message To Mr. Smith</h2>
<form method="POST" action="../../cgi-bin/email.cgi">
<!-- This hidden form field contains the
        email address of the recipient, but we don't
        just blindly trust it. email.cgi
        checks email.conf. -->
<input type="hidden" name="recipient" value="">
<input type="hidden" name="email" value="">
<input type="hidden" name="content" value="Email sent by Gascop Gmail2Pager system.">
<table align="center" border="0" cellpadding="5" cellspacing="5">
<tr><td>Your Name</td>
<td><input name="name"/></td></tr>
<td><input name="subject" style="width:358px;"/></td></tr>
<tr><td>Select Pager</td><td>
<select name="pager">
<option name="pager" value="BT EasyReach 77C">Personal</option>
<option name="pager" value="Motorola 50C">Emergency</option>
<option name="pager" value="NEC Pager">Night Time</option>
<tr><td colspan="2" align="center">
<input type="submit" value="Send Email"></td></tr>

You also need a file with allowed recipient email addresses. This file is named email.conf
This file has a line for the email address followed by a line with the path to the webpage
to be displayed on success.

The success webpage is just a very simple page like this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta content="text/html; charset=ISO-8859-1"
    <big><big><b>Pager Message Sent Successfully.</b></big></big>

Finally you need the perl cgi script, this script is named email.cgi
You just need to edit the path to the email.conf file shown in red.
Also the location of sendmail(in green) may be different on your sever.


# A simple Perl-based CGI email handler.
# Copyright 2004 Boutell.Com, Inc. Compatible with our earlier C program.
# Released under the same license terms as Perl 5 itself.
# We ask, but do not require, that you link to
# when using this script or a
# variation of it.

use CGI;

my $sendmail = "/usr/sbin/sendmail";

# A text file containing a list of valid email recipients and the web pages to
# which the user should be redirected after email is sent to each, on
# alternating lines.  This allows one copy of the script to serve multiple
# purposes without the risk that the script will be abused to send spam.

my $emailConfPath = "/path/to/email.conf";

# Parse any submitted form fields and return an object we can use
# to retrieve them
my $query = new CGI;

my $name = &veryclean($query->param('name'));
my $email = &veryclean($query->param('email'));
my $recipient = &veryclean($query->param('recipient'));
my $pager = &veryclean($query->param('pager'));
my $subject = &veryclean($query->param('subject'));
#newlines allowed
my $content = &clean($query->param('content'));

#Note: subject is not mandatory, but you can easily change that
if (($name eq "") || ($pager eq "") || ($recipient eq ""))
    &error("Email Rejected",
        "Please fill out all fields provided. Back up to the " .
        "previous page to try again.");

if (!open(IN, "$emailConfPath")) {
    &error("Configuration Error",
        "The file $emailConfPath does not exist or cannot be " .
        "opened. Please read the documentation before installing " .

my $returnpage;

my $ok = 0;
while (1) {
    my $recipientc = <IN>;
    $recipientc =~ s/\s+$//;
    if ($recipientc eq "") {
    my $returnpagec = <IN>;
    $returnpagec =~ s/\s+$//;
    if ($returnpagec eq "") {
    if ($recipientc eq $recipient) {
        $ok = 1;
        $returnpage = $returnpagec;
if (!$ok) {
    &error("Email Rejected",
        "The requested destination address is not one of " .
        "the permitted email recipients. Please read the " .
        "documentation before installing email.cgi.");

# Open a pipe to the sendmail program
open(OUT, "|$sendmail -t");
# Use the highly convenient <<EOM notation to include the message
# in this script more or less as it will actually appear
print OUT <<EOM
To: $recipient
Subject: GASCOP:$pager:$name:$subject
Supposedly-From: $name

# Now redirect to the appropriate "landing" page for this recipient.
print $query->redirect($returnpage);

exit 0;

sub clean
    # Clean up any leading and trailing whitespace
    # using regular expressions.
    my $s = shift @_;
    $s =~ s/^\s+//;
    $s =~ s/\s+$//;
    return $s;

sub veryclean
    # Also forbid newlines by folding all internal whitespace to
    # single spaces. This prevents faking extra headers to cc
    # extra people.
    my $s = shift @_;
    $s = &clean($s);
    $s =~ s/\s+$/ /g;
    return $s;

sub error
    # Output a valid HTML page as an error message
    my($title, $content) = @_;
    print $query->header;
  #print "Content-type: text/html\n\n";
    print <<EOM
<h1 align="center">$title</h1>
exit 0;

Setting up a http server on your RPi to send pager messages to email.

Install lighttpd and ssmtp with...
sudo pacman -S lighttpd
sudo pacman -S ssmtp

You can download an archive containing the lighttpd.conf and ssmtp.conf files here.

Edit /etc/lighttpd/lighttpd.conf and make the file look like this...

# This is a minimal example config
# See /usr/share/doc/lighttpd
# and

server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
server.modules = ( "mod_cgi" )
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign        = (
                ".html" => "text/html",
                ".txt" => "text/plain",
                ".css" => "text/css",
                ".js" => "application/x-javascript",
                ".jpg" => "image/jpeg",
                ".jpeg" => "image/jpeg",
                ".gif" => "image/gif",
                ".png" => "image/png",
                "" => "application/octet-stream"
cgi.assign = (
                ".pl"  => "/usr/bin/perl",
                ".cgi" => "/usr/bin/perl"

$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = ( "" => "" )

Edit the file /etc/ssmtp/ssmtp.conf and make it look like this...

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named
# The example will fit if you are in and you mailhub is so named.
# Where will the mail seem to come from?
# The full hostname

Obviously changing to your gmail address
Your-Gmail-Password to your gmail password.

You need to start the lighttpd server with...
sudo systemctl start lighttpd.service
If you want the server to start each time you boot your RPi then do this...
sudo systemctl enable lighttpd.service

download this file srv-scripts.tar.gz by clicking here and unpack it with...
tar zxf srv-scripts.tar.gz
and then copy the files to the server root with...
sudo cp -r * /srv/http/

You should now be able to access the pager message entry page in a web browser from another computer on your network with...
Obviously changing the IP address to whatever the IP address is for your RPi

You MUST edit the following files in accordance with the information in the previous section above.


(c) 2012-2013 Clive Cooper