- Zig 97%
- Nix 3%
zig-dump1090 #
A port of FlightAware's dump1090 — a Mode S and ADS-B decoder for software defined radios — to Zig 0.16.
The API documentation is generated from the doc comments in the source and published at https://jeff.jcollie.page/zig-dump1090/.
Where it lives #
git clone https://git.jcollie.dev/jeff/zig-dump1090.git
It is mirrored on Tangled at https://tangled.org/jcollie.dev/zig-dump1090,
and it is also on Radicle, where a repository is
findable only by its ID, so here is that ID —
rad:z2N42qvZ6qBHsJsfUzv2JXDo2iUyH — and the command that fetches it:
rad clone rad:z2N42qvZ6qBHsJsfUzv2JXDo2iUyH
Status #
Complete, in the sense that everything in scope is ported and checked: the decoder, the tracker, the demodulator, the four network outputs and two network inputs, the JSON files, the statistics, the adaptive gain control, and every command-line option upstream accepts, and it has been run against real air traffic on a live radio.
Each module is checked against the C it was ported from before the next is started, by running both over the same inputs and diffing the results field by field. Where the table below says a module agrees with upstream, that is what it means.
| Module | Upstream | State |
|---|---|---|
src/modes.zig |
dump1090.h |
Frame lengths and downlink formats |
src/crc.zig |
crc.c |
Done; syndrome tables verified identical to upstream's |
src/cpr.zig |
cpr.c |
Done; 600k random decodes agree with upstream's to 1e-9 degrees |
src/bits.zig |
mode_s.h |
Field extraction, numbered from 1 as the standards are |
src/ais.zig |
ais_charset.c |
The six-bit callsign character set |
src/icao_filter.zig |
icao_filter.c |
Done |
src/mode_ac.zig |
mode_ac.c |
Done; all 69,837 conversions agree with upstream's |
src/message.zig |
dump1090.h |
The decoded-message type and its vocabulary |
src/comm_b.zig |
comm_b.c |
Done; 400k random replies decode identically to upstream |
src/mode_s.zig |
mode_s.c |
Done; 300k frames × 3 option sets decode identically to upstream |
src/track.zig |
track.c |
Done; 300k messages × 2 receiver configurations track identically to upstream |
src/dsp.zig |
dsp/ |
Done; the generated SIMD dispatch replaced by @Vector. All 65,536 table entries and 200k magnitudes identical |
src/convert.zig |
convert.c |
Done |
src/mag_buf.zig |
fifo.h |
The sample block and its overlap |
src/demod_2400.zig |
demod_2400.c |
Done; 4M samples demodulate identically, messages and counters alike |
src/fifo.zig |
fifo.c |
Done; pthreads replaced by std.Io |
src/sdr.zig |
sdr.c, sdr_ifile.c, sdr_stub.c |
Done; file, no-radio and RTL-SDR inputs |
src/output.zig |
net_io.c |
The AVR, Beast, BaseStation and Stratux wire formats |
src/fatsv.zig |
net_io.c, faup1090.c |
FlightAware's tab-separated change feed, on .outputs.fatsv |
src/net.zig |
net_io.c |
TCP output and input services, with upstream's write batching, heartbeats and Beast settings commands |
src/input.zig |
net_io.c |
Reading the Beast and AVR formats back |
src/json.zig |
net_io.c |
aircraft.json, receiver.json, stats.json and the history files |
src/stats.zig |
stats.c |
Done; the report and its windows |
src/sdr_rtlsdr.zig |
sdr_rtlsdr.c |
Done, on zig-rtlsdr rather than librtlsdr; streams from a live R820T dongle at the full 2.4 MSPS with no drops |
src/adaptive.zig |
adaptive.c |
Done; eight synthetic scenarios and a live tuner drive the gain identically to upstream, log lines included |
src/fmt.zig |
— | Printing floats the way C's printf does, ties to even |
src/display.zig |
mode_s.c |
Done; --raw, --onlyaddr and the full verbose display |
src/adept.zig |
piaware |
FlightAware's uplink, ported from PiAware's Tcl without any of its host management |
src/main.zig |
dump1090.c |
Done; every option upstream accepts is accepted, and the same lifecycle logs, signals, watchdog and exit status |
Beyond upstream #
The port matched upstream first and is now allowed to go past it, in the places where upstream's behaviour is not a contract that something downstream depends on. The wire formats stay exactly as they are; what changes is what the program can be asked to do.
Distances come from zig-geo. The
range and speed checks, and the range histogram, measure great circles with
its sphere.distance rather than upstream's haversine-or-law-of-cosines, and
on its mean radius of 6,371,008.8 metres rather than 6,371 km. The two agree
to within a metre out to 300 nautical miles, so only a position within that
of a limit can come out differently; the tracker's agreement with upstream in
the table above was measured before the change.
Outbound connections. Upstream can only be dialled — its one
outward-dialling function is used by faup1090 and view1090, never by
dump1090 itself. That leaves out every aggregator which, rather than
shipping a client that reads your Beast port, expects a receiver to dial
them and push. .connectors does that — one entry per feed, each with its
own connection and its own retry:
.connectors = .{
.{ .host = "feed.example.org", .port = 30004, .protocol = .beast_out },
.{
.host = "feed.example.org",
.port = 30004,
.protocol = .beast_reduce_plus_out,
.uuid = "<your-uuid>",
},
},
The fields are named after readsb's --net-connector, which is what the
aggregators write their instructions in terms of, so a documented
host,port,protocol line transcribes into an entry without having to be
translated. Feeding sites you can push to
directly below has the ones worth
pointing it at.
The protocols are beast_out, beast_reduce_out, beast_reduce_plus_out,
beast_verbatim_out, raw_out, sbs_out, stratux_out and fatsv_out —
the same formats the listening ports serve, and the bytes are identical to
what a reader connecting inward would receive.
Reduced Beast. beast_reduce_out sends ordinary Beast, just less of it:
an aircraft is forwarded at most once per .outputs.reduce_interval_s (an
eighth of a second by default), and a message carrying nothing about where the
aircraft is or what it is doing waits four times as long. Nothing about the
format changes, so a consumer cannot tell the difference except in volume.
beast_reduce_plus_out is the same thing plus the feed identifier, which is
the only difference between the two names.
This is the contract readsb documents rather than a port of what readsb does: its own version keeps a timer per field, sorting each into how often it deserves forwarding, threaded through an accept-data path this port has no equivalent of. On a recording replayed at real speed this keeps of the order of a tenth to a fifth of the frames. A connector retries every five seconds while the far end is unreachable, backing off to a minute, and returns to five seconds once a connection has succeeded. It says on standard error when it connects, when it drops, and once — not every retry — when it cannot get through at all, because a feeder that will not say whether it is connected is very hard to trust. The optional identifier is sent once, ahead of the first message, as the frame aggregators expect.
Configuring it #
Settings live in a file rather than in an ever-growing wall of options:
dump1090 --config /etc/dump1090.zon
The format is ZON, Zig's own object notation, which means there is no parser here to go wrong and no dependency to carry — and a field that is misspelled or of the wrong type is an error naming the line rather than a value silently ignored:
dump1090.zon:
3:10: error: unexpected field 'latitude'
3:10: note: supported: 'lat', 'lon', 'max_range_nm'
Every setting is optional, and one left out keeps the program's default, so a
file says what it changes and nothing else. Values are in the units a person
thinks in — degrees, seconds, nautical miles — rather than the milliseconds
and metres the code works in. doc/dump1090.zon is a commented example.
Anything given on the command line overrides the file, which is read first for exactly that reason.
What is left on the command line is what describes a single run rather than how the receiver is set up: which recording to read, how hard to try to decode it, what to print, and what to report. Nineteen options, down from ninety-four. Everything about a radio, a network or a feed is in the file only, and asking for one of those on the command line says so:
$ dump1090 --net-bo-port 30005
unknown option '--net-bo-port'
the receiver's settings live in a configuration file; see --help
Two deliberate differences from upstream came with this. Naming an output port opens that port and no other — upstream fills in every default the moment networking is enabled at all, so asking it for a Beast port also gets you raw output and both inputs. And the options upstream keeps only so that an old command line still runs are gone, since a trimmed command line breaks those anyway.
Feeding FlightAware directly #
FlightAware's uplink is a protocol, and this speaks it. .flightaware in the
configuration is all it takes:
.flightaware = .{
.mac = "00:11:22:33:44:55",
.feeder_id_file = "/var/lib/dump1090/feeder_id",
},
There is no PiAware here and nothing of PiAware running beside it. That is the point of it. PiAware is a small protocol client wrapped in a machine manager: it runs a decoder as a child process, restarts services it did not start, rewrites network configuration, reboots, and takes commands from FlightAware's server to update software on the host. Only the first of those was wanted, so only the first was ported.
The protocol turns out to be the format already in hand. An adept message is
one line of tab-separated keys and values; PiAware forwards tracks by
splitting a line of faup1090 output on tabs and sending the parts. So
src/fatsv.zig is not something that feeds the uplink — what it writes is
the payload, and faup1090 needed no porting because it was already here.
Nothing on this machine can be managed from FlightAware's end. The login
declares local_auto_update_enable and local_manual_update_enable as 0,
and the server only sends request_auto_update and request_manual_update
to a client that said yes; if one arrives anyway it is refused and logged.
Nothing else in the protocol reaches outside this process.
The mac is required and has no default worth inventing. It is not, though,
what identifies a site: two logins from the same MAC with no identifier were
answered with two different identifiers and two separate sites. What carries
a site across restarts is the feeder identifier, so feeder_id_file has to
point somewhere that survives one — not a temporary directory, and under the
systemd unit that means the StateDirectory described below. Lose the file
and the next login asks FlightAware for a new site rather than resuming the
old one.
The certificate is pinned, because FlightAware's server presents one from
their own private authority and nothing in the system trust store will vouch
for it. It is fetched from PiAware by the Zig build system at the commit named
in build.zig.zon rather than pasted into this repository, so the bytes being
trusted stay checkable against their published source. Only the root is
pinned: PiAware also carries the intermediate, but the copy in their tree
expired in December 2025 and the server has since rotated to a replacement, so
a client insisting on the bundled one would already be broken. The host is
verified by real wildcard matching against the name dialled, which their
DNS:*.flightaware.com satisfies — PiAware instead accepts any of four common
names and does no matching at all, which would take a certificate issued for
eyes.flightaware.com as proof of having reached piaware.flightaware.com.
Multilateration is not part of this. FlightAware's MLAT goes through
PiAware's mlat-client, which is a separate program feeding a separate
protocol; see the note under the aggregators below, which have the same
split. Feeding positions works without it.
The TLS is tls.zig, not the standard library's, and that is not a
preference. std.crypto.tls.Client has certificate_request in its
handshake-type enum and in no switch that handles one, so a server asking for
a client certificate is answered with error.TlsUnexpectedMessage before the
handshake can finish. FlightAware's server asks — openssl s_client reports
it sending "Acceptable client certificate CA names" — and PiAware supplies
none, so what is wanted is a refusal rather than a credential. tls.zig gives
one. It is pinned to the last commit that builds against Zig 0.16, since
everything after 2026-05-31 there requires 0.17-dev.
zig build test -Dtls-check adds a test that connects to FlightAware's live
server and completes the handshake, sending nothing further — no login, so no
feed is registered and nothing identifies the machine. It is off by default
because it needs the network, and it is what found the gap above.
Say where the feeder identifier is kept, or FlightAware will not make you
a site. feeder_id is not just an identifier: PiAware sends it as a
two-element Tcl list of where it came from and what it is — cache {} on
a first login, cache 2f16fb88-… afterwards — and always sends it, even with
nothing to say. The leading word is how the server knows the client can keep
an identifier it is issued. A login without the field is refused with:
creation of new feeder sites requires a newer PiAware client that supports
feeder IDs, please upgrade PiAware and try again
So feeder_id_file is what makes a first login work, not merely a
convenience: it is what lets this say cache. With an identifier written
into the configuration instead the word is config, and with neither it is
none, which no site can be created for.
A new site logs in as guest until you claim it on FlightAware's site.
Every five minutes it says how many tracks have gone out, cumulatively and across reconnects, because "connected" and "connected but sending nothing" look identical in a log otherwise. Tracks dropped because the far end could not keep up are counted separately and mentioned only when there are any.
Compression is settled: declaring no compression_version is accepted, and
every field goes over in the clear.
Feeding sites you can push to directly #
These are the sites that need no client of theirs on your machine. They
publish a host and a port, you dial them, and you send Beast. That is what
.connectors is for, and it is the half of feeding that upstream cannot do
at all.
.connectors = .{
.{
.host = "feed.airplanes.live",
.port = 30004,
.protocol = .beast_reduce_plus_out,
.uuid = "00000000-0000-0000-0000-000000000000",
},
},
Most of them speak the same dialect, because most of them are readsb behind the door, so the entries differ only in host and port:
| Site | Host | Port |
|---|---|---|
| airplanes.live | feed.airplanes.live |
30004 |
| adsb.fi | feed.adsb.fi |
30004 |
| adsb.lol | in.adsb.lol |
30004 |
| Planespotters | feed.planespotters.net |
30004 |
| TheAirTraffic | feed.theairtraffic.com |
30004 |
| ADS-B Exchange | feed1.adsbexchange.com |
30004 |
| adsb.one | feed.adsb.one |
64004 |
| AVDelphi | data.avdelphi.com |
24999 |
| Fly Italy ADSB | dati.flyitalyadsb.com |
4905 |
All of them with .protocol = .beast_reduce_plus_out. Check the site's own
page before trusting a row of that table: these endpoints move, and the two
reference configurations this was taken from — ultrafeeder and
multifeeder — already disagree about adsb.lol, one saying
in.adsb.lol,30004 and the other feed.adsb.lol,1337. The table is a
starting point and a shape, not an authority. Only the airplanes.live row has
actually been run from here.
A few things worth knowing before pointing this at a real site.
The identifier only goes out under beast_reduce_plus_out. That is the
one difference between it and beast_reduce_out, so a .uuid set on a
connector using any other protocol is silently unused — deliberately, since
sending it to a consumer that does not expect it would corrupt the stream.
Generate one with uuidgen, keep it somewhere outside the repository, and
use the same one every time: it is how a site recognises the feed as yours
across restarts, and how you claim it. Some sites want you to register that
identifier with them first and some are happy to take data from anyone.
Port 30004 on their side has nothing to do with port 30004 on yours. The example configuration listens for inbound Beast on 30004 because that is conventional, and the coincidence is only that. A connector is an outbound connection to their machine.
Multilateration is not part of this. Feeding positions is one protocol
and contributing timing for MLAT is another, and no site does the second one
over Beast. It needs mlat-client, which is a separate program that reads a
Beast port — this one will do — and talks to the site's MLAT server itself.
Its results come back on a port of its own, which this receiver can take as a
Beast input if you want multilaterated positions in your own output. Same
arrangement FlightAware's own multilateration uses, and for the same reason.
Send reduced Beast unless told otherwise. beast_reduce_plus_out is what
every one of these documents, and it is a fifth to a tenth of the bytes for
data the site can still use — see the note on reduced Beast above for what is
actually dropped. beast_out is there if a site asks for everything.
You can run as many of these at once as you like; each is an independent connection with its own retry, and a site being down does not affect the others.
Feeding sites that ship their own client #
The other half of the split. The sites above publish a host and a port and
let you dial them; these ship a program of their own that you install
beside the receiver. It connects inward to a Beast port, reads the same
bytes any other reader would, and does the uplink itself over whatever
protocol the site uses. The three usual ones are FlightRadar24's fr24feed,
AirNav RadarBox's rbfeeder, and Plane Finder's pfclient. All three are
closed source: what they send, and how, is not published, which is why none
of it can be implemented here.
Nothing needs adding for these. They are ordinary Beast readers. Run one
on the same machine, tell it during its own setup that the receiver is
external, and give it 127.0.0.1 and port 30005:
.outputs = .{
.beast = 30005,
.bind = "127.0.0.1",
},
Each client words that choice differently — "ModeS Beast (TCP)" in
pfclient, receiver type beast with an external_host and
external_port in rbfeeder's [network] section, a numbered menu in
fr24feed --signup — and the wording moves between versions, so take the
exact steps from the vendor's current instructions rather than from here.
What does not move is the shape: a TCP connection to this receiver's Beast
port, on the machine the antenna is on. Several of them can read it at once,
and they can read it alongside any number of outbound connectors and the
FlightAware uplink; the Beast output does not care how many are listening.
If the client has to run on a different machine from the radio, widen
.outputs.bind so it can reach the port — and be aware that Beast is
plaintext with no authentication, so it wants a trusted network or a tunnel
rather than the open internet.
FlightAware is not in this list, and the reason is the licence. PiAware ships a local client of the same shape, but it is published under a BSD licence, so its protocol could be read and ported — which it has been, so nothing of FlightAware's has to run here at all. See feeding FlightAware directly above.
Some useful third-party write-ups of running several of these at once: a guide on the FlightRadar24 forum and one for a remote decoder.
Installing it with Nix #
The flake builds the receiver and carries a NixOS module for it:
{
inputs.zig-dump1090.url = "git+https://git.jcollie.dev/jeff/zig-dump1090.git";
outputs = { nixpkgs, zig-dump1090, ... }: {
nixosConfigurations.receiver = nixpkgs.lib.nixosSystem {
modules = [
zig-dump1090.nixosModules.default
{
services.dump1090 = {
enable = true;
settings = {
receiver = { lat = 41.5868; lon = -93.6250; max_range_nm = 300; };
sdr = { device = ".rtlsdr"; gain = { db = 25.4; }; };
outputs = { bind = "127.0.0.1"; beast = 30005; };
flightaware.mac = "00:11:22:33:44:55";
};
};
}
];
};
};
}
settings is the configuration file written as Nix, with the same field names
doc/dump1090.zon documents. One thing has no Nix equivalent and so needs a
convention: ZON distinguishes the enum literal .rtlsdr from the string
"rtlsdr", and five settings take one — sdr.device, sdr.format,
decode.fix, json.location_accuracy and a connector's protocol. A string
that is exactly a dot and an identifier is rendered as an enum; everything
else stays a string, so paths and host names like feed.example.org need no
thought. A setting left null is omitted rather than written as null, since
an absent setting keeps the program's own default.
The module does three things worth knowing about beyond writing that file and
the unit. It blacklists dvb_usb_rtl28xxu whenever the radio is an RTL-SDR,
for the reason given below. It defaults flightaware.feeder_id_file into the
service's StateDirectory, because a login with no identifier asks for a new
site rather than resuming one. And openFirewall opens exactly the ports
named under outputs and inputs — off by default, since every one of these
protocols is plaintext and unauthenticated and belongs on the loopback address
unless something remote genuinely needs it.
For anything the renderer cannot express, configFile takes a path and
settings is ignored.
Running it as a service #
doc/dump1090.service is an example systemd unit. It runs the receiver as a
dedicated unprivileged user in the plugdev group, which is where access to
the dongle comes from — install the udev rules from zig-rtlsdr as
/etc/udev/rules.d/10-rtl-sdr.rules first.
Blacklist the kernel's DVB driver, and treat that as required rather than tidiness:
echo 'blacklist dvb_usb_rtl28xxu' > /etc/modprobe.d/rtl-sdr.conf
The driver underneath can take the dongle from the kernel on open and give it
back on close, and usually does. But the kernel's teardown of
dvb_usb_rtl28xxu is not reliable, and when it fails it fails badly: it has
been seen here to deadlock in i2c_del_adapter, by way of rtl2832_remove
and dvb_usbv2_disconnect, leaving the receiver's own process in
uninterruptible sleep — unkillable by SIGKILL, still holding the device, and
not released by unplugging the dongle. Only a reboot cleared it. Nothing in
this program is on that stack and nothing in it can avoid the outcome; a
driver that is never bound never has to be detached, which is the whole of the
fix.
StateDirectory=dump1090 gives it /var/lib/dump1090, which is the only
place it can write and the only reason it needs one: the identifier
FlightAware issues has to outlive a restart, and ProtectSystem=strict would
otherwise leave nowhere to put it. Drop it, and .flightaware.feeder_id_file
with it, if FlightAware is not being fed.
It is confined about as far as it can be. ProtectSystem=strict,
ProtectHome, an empty capability set, SystemCallFilter=@system-service,
and only the address families it uses. PrivateDevices= is deliberately
not set, because it would hide /dev/bus/usb, which is the one device the
program needs; DevicePolicy=closed with DeviceAllow=char-usb_device rw
denies everything else instead.
The syscall filter and address-family restrictions were checked by running
the receiver under them: it opens the dongle, resolves and connects to a
feed, streams at full rate with no dropped samples, and stops cleanly on
SIGTERM. The device restrictions need root to apply and were not exercised
here.
There is no ExecReload=: the receiver does not re-read its configuration
while running, and systemctl reload would have to send a signal it does not
handle — whose default action is to kill it. systemctl restart applies a
change.
Scope #
This is not a complete parity port. It targets the RTL-SDR, the file/stdin
reader used for testing, and the no-radio stub; the bladeRF, HackRF, LimeSDR
and SoapySDR back ends are out of scope, as are --interactive, view1090
and faup1090. The options that configure those are still accepted, with a
warning, so that an existing command line keeps running. FATSV, which
upstream generates only in faup1090, is here instead: .outputs.fatsv
serves it directly, so nothing has to read this receiver's own Beast output
to produce it. What it does keep is the wire behaviour: the Beast, raw,
BaseStation and JSON outputs are meant to be byte-for-byte what upstream
produces, because that is what everything downstream of dump1090 parses.
Structurally it is not a transliteration. The generated SIMD dispatch under
upstream's dsp/ is replaced by Zig's @Vector, the pthreads and the bundled
anet.c by std.Io, and C's sentinel returns by error sets and tagged
unions. There is no C left at all: librtlsdr, the last of it, is replaced by
zig-rtlsdr, so the build links nothing and the binary is static.
Checking it against upstream #
The port is checked by running both programs over the same recording and
diffing the output. On synthetic recordings of a few million samples, with
real frames planted at every sub-sample phase and amplitude, --raw output is
byte-for-byte identical across every combination of --fix, --fix-2bit,
--no-fix, --no-fix-df, --mlat and --modeac, in both UC8 and SC16 —
including the noisy recordings where error correction changes what gets
decoded. The three network outputs are compared the same way, by attaching a
reader to each port of both programs and diffing what arrives, and the JSON
files by diffing the snapshots the two programs write, including stats.json
and the --stats report. The network inputs are
checked by feeding the same Beast or AVR stream into both as --net-only
receivers and comparing everything that comes out the other side. The Beast
settings commands are checked by connecting to the Beast output port of both
programs, sending the same commands, and diffing what each sends back: every
combination of verbatim, local and Mode A/C produces the same bytes. The
Stratux output is checked the same way over a synthetic feed of twelve
hundred frames, chosen to reach every field it reports: all 1,188 objects the
two programs emit agree apart from the wall-clock timestamp each stamps its
own run with. The
adaptive gain control cannot be driven from a recording, since it needs a gain
knob to turn, so it is checked by linking upstream's adaptive.c against a
synthetic tuner and driving both implementations through the same few hundred
blocks of samples: eight scenarios, chosen so that between them they reach
every branch of the state machine, produce the same gain steps, the same
counters, the same noise floor to six decimal places, and the same running
commentary on standard error.
Against a live radio — a Realtek RTL2838 with an R820T tuner — the port streams at the full 2.4 MSPS with no dropped samples, and reports the same tuner gain steps as upstream. The adaptive gain control, which cannot be driven from a recording at all, finds the same gain limits (0.0 to 58.6 dB across thirty steps), makes the same decision to scan upwards, stops at the same place, and logs the same lines. Its noise floor measurement agrees exactly: at a pinned gain, over repeated captures, both programs report -35.6 dBFS at 28.0 dB of gain and -30.2 dBFS at 49.6 dB. Off the air, forty-five seconds of 1090 MHz recorded from the antenna is kept as a fixture and replayed through both programs like any other recording. It is a poor location — everything arrives weak enough to need error correction — but it contains real extended squitters from real aircraft and a few hundred Mode A/C replies, and it found two things a synthetic recording never had.
The first was ours: the RSSI line was written outside the test that guards it,
so a message with no measured signal level printed -inf dBFS where upstream
prints nothing.
The second is upstream's. demodulate2400AC clears its message once per block
of samples where the Mode S loop clears it once per message, and the Mode A/C
decoder only ever sets an altitude, never clears one — so a reply whose own
code carries no altitude is reported with whatever the previous reply in that
block had. In this recording that put a wrong altitude, belonging to another
aircraft, on nineteen of the hundred and eighty-three Mode A/C replies that
reported one. This port builds a fresh message per reply and so reports no
altitude for those nineteen, which is the one place its output deliberately
differs from upstream's.
FATSV is checked against faup1090 itself: this port serves Beast on one
port and FATSV on another, faup1090 reads the Beast and writes its own
FATSV, and the two are diffed field by field. They agree exactly — the event
records byte for byte, and every track line's fields and their ages and
source letters.
That comparison only holds when each burst of frames is processed inside one scan on both sides. FATSV reports what a track looks like at the moment it is sampled, and the two programs sample at slightly different instants — one reads its own tracker, the other the same data a socket later — so under a continuous feed the lines drift apart in when they are emitted even though each is correct. The rate tiers, the ten-minute re-emission and the suppression rules are pinned by unit tests instead.
One caution about the method: --ifile stamps each block of samples with the
wall clock as it is read, and the tracker refuses an update whose message
timestamp precedes the field's last one, so a recording read at a different
speed decodes the same messages but resolves a slightly different number of
positions. Comparisons have to be made at the same optimization level, or with
--throttle, or they will show a difference that is not there.
The verbose display — every decoded field of every message, some ten thousand lines a run — matches to the column, as does position decoding when the receiver's location is configured.
Continuous integration #
A Forgejo workflow runs on every push: reuse lint, zig fmt --check,
zig build test and zig build. The formatting check excludes zig-pkg,
the in-tree cache the Zig package manager fetches dependencies into: it is
gitignored, so a fresh checkout does not have it, but a working tree does and
nobody wants to be told about the formatting of a dependency. From main, and only once the tests have
passed, it also builds the API documentation and publishes it to
https://jeff.jcollie.page/zig-dump1090/.
What the workflow cannot do is the differential testing described above, which needs upstream's C built alongside this and a good deal of scratch space; that is run by hand, and it is worth being plain that a test suite nothing runs automatically is a gap rather than a tidy-up.
Building #
zig build # build zig-out/bin/dump1090
zig build test # run the tests
zig build docs # build the API documentation into zig-out/docs
zig build docs-serve # ...and read it at http://localhost:8000/
A Nix flake provides the toolchain: nix develop puts the right Zig, reuse
and the documentation publisher on the path. There is nothing else to
install — the build has no C in it and links nothing, so what comes out is a
static binary.
Talking to the dongle is zig-rtlsdr, a port of librtlsdr onto Zig that
reaches Linux's usbfs directly rather than going through libusb. One
consequence is worth knowing: it takes the dongle away from the kernel's
dvb_usb_rtl28xxu driver when it opens the device and gives it back when it
closes, so there is no module to blacklist and no dongle to unbind by hand.
Tested on a device with that driver bound: upstream's dump1090, built against
the librtlsdr nixpkgs ships, fails with usb_claim_interface error -6 and
tells you to blacklist the module; this opens it, streams, and leaves
/dev/dvb/adapter0 working again afterwards.
Being written against usbfs makes it Linux-only, so the RTL-SDR input is
compiled in only for Linux targets. -Drtlsdr=false leaves it out
explicitly; everything else works in such a build, and asking for
--device-type rtlsdr fails with NotSupported rather than silently doing
nothing.
Licence #
dump1090 is GPL-2.0-or-later, so this port is too — a translation is a
derivative work, and no amount of retyping changes that. Some of the code
descends from Salvatore Sanfilippo's original BSD-licensed dump1090 by way of
Malcolm Robb's and Oliver Jowett's forks, and those files name him in their
copyright headers. Licensing is recorded in the
REUSE form, so reuse lint will confirm every
file's provenance.