ESAR – Extraordinarily Simple AIS Receiver written in C

Thank you to Richard Gosiorovsky for submitting his latest SDR project called ESAR (Extraordinarily Simple AIS Receiver). AIS stands for Automatic Identification System and is used by marine vessels to broadcast their GPS locations in order to help avoid collisions and aide with rescues. An RTL-SDR with the right software can be used to receive and decode these signals, and plot ship positions on a map.

Richards code comes as raw C code, so you will need some knowledge on C code compiling to use it. Being so simple, the code is also a great resource for learning how to access data from an RTL-SDR, and write a decoder. Richard writes:

[ESAR] takes less then 300 lines of programming code and no additional software is necessary (like SDR# or audio piping).

It was intended mainly as exercise in digital signal processing.

All you need is RTL-SDR dongle with driver and rtl_tcp command. Simple dipole antenna is sufficient. If all this you have just compile C code (in the attachment) using MS Visual Studio.

Before running ESAR run rtl_tcp command with this parameters:

rtl_tcp.exe -f 162e6 -s 300000 -a 127.0.0.1 -p 2345 -g 48.0

It comes with GNU licence so converting output to NMEA format or any graphical output is free choice of other SDR enthusiasts.

Richard has shared the C code file directly with us, and it can be downloaded from our server here.

ESAR Code Screenshot
Subscribe
Notify of
guest

10 Comments
Inline Feedbacks
View all comments
handiko

thank you

Richard

Hi, you Can run rtl_tcp directly on Raspberry pi.
See here: http://graem.es/Configuring-a-Raspberry-Pi-2-to-be-a-RTL_TCP-Server
And ESAR remotly on MS Windows if you properly configure IP address and TCP port number.

Laurent

I tried to compil with my raspberry pi under Buster 32 bit ..
No working ..
gcc -o program ESAR.c
ESAR.c: In function ‘parse_AIS_message’:
ESAR.c:71:15: error: a label can only be part of a statement and a declaration i s not a statement
case 5: char csgn[16], name[32], dest[32]; // Static and voyage related vessel data
^~~~
ESAR.c: At top level:
ESAR.c:228:10: fatal error: winsock2.h: No such file or directory
#include
^~~~~~~~~~~~
compilation terminated.

Jean-Marc Paratte

As I understand, winsock2.h is a win32 library: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/
The rtl_tcp.exe is a win32 Windows program, it can’t be compiled for rapsberry pi.

Canuck

Add a { before char csgn. Add a } after 120));

cygeus

I slightly modified the code to also compile on Linux.
Please note: only compile tested.
https://gist.github.com/cygeus/5102f63a68cd1429fac8a880162e6f63

Seasalt

Great…excellent the universe is even larger.

Jean-Marc Paratte

Is it the right rtl_tcp.exe here ?

Jean-Marc Paratte

Before running ESAR run rtl_tcp command with this parameters:
rtl_tcp.exe -f 162e6 -s 300000 -a 127.0.0.1 -p 2345 -g 48.0

Please, where to download rtl_tcp.exe ?