Reading with gpspipe
Outcome: fixes out of a running daemon as plain text you can pipe, save, and inspect — and the same daemon handing the NMEA stream back out to anyone who prefers it raw.
The dumb pipe is the honest client
gpspipe does almost nothing, and that is its virtue. It connects to a daemon, asks for a watch (chapter 8 shows the asking), and prints what comes back, one JSON object per line, until you stop it or a limit you set runs out. With the feeder from chapter 6 running:
$ gpspipe -w -n 12 127.0.0.1:2947
-w asks for the daemon's native JSON; -n 12 exits
after twelve packets, which is what makes a clean
transcript. The run (transcript
gpsd-lab/transcripts/t03-gpspipe.txt) opens with the same
three objects every client meets — VERSION (release
3.26.1: the right daemon, chapter 3's check), DEVICES (one
device, /dev/pts/2, driver NMEA0183), WATCH (the echo of
the request) — and then settles into the report stream:
{"class":"TPV","device":"/dev/pts/2","mode":3,
"time":"2026-06-15T12:00:02.000Z","ept":0.005,
"lat":39.500000000,"lon":-98.499813333,"altHAE":305.0000,
"altMSL":320.0000,"alt":320.0000,"epx":10.231,"epy":11.734,
"epv":29.900,"track":90.0000,"magtrack":88.5000,
"magvar":-1.5,"speed":8.000,"climb":0.000,"eps":23.47,
"epc":59.80,"geoidSep":-15.000,"eph":17.100,"sep":30.400}
Two seconds into the route, the longitude has moved east
from -98.500000000 to -98.499813333 — about 17 metres of
travel at this latitude, which is 8.0 m/s for the seconds
since the epoch before, plus the assembly rounding the
stream makes visible. Read a TPV like a form, not a blob:
identity (class, device), the claim (mode), the
moment (time), the place (lat, lon, the three
altitudes), the motion (speed, track, climb), and the
doubts (ept, epx, epy, epv, eph, sep). Nothing
in it is unitless: metres, metres per second, degrees.
Interleaved SKY reports fill most of the twelve packets —
remember chapter 5's arithmetic: the sky picture updates
several times per epoch, the full fix once. A reader who
wants only fixes learns to filter by "class":"TPV", which
is exactly what the Python client in chapter 9 does in code
instead of in a pipeline.
The stream, back out: gpspipe -r
Some consumers were written for NMEA and will never speak JSON — an old chart program, a piece of test gear, your own script from before gpsd. The daemon accommodates them: ask for the NMEA view instead, and gpspipe prints pseudo-NMEA — sentences regenerated by the daemon from what the receiver sent:
$ gpspipe -r -n 8 127.0.0.1:2947
$GPGSV,3,1,11,05,43,060,43,07,64,110,44,09,31,155,37,12,55,200,42*74
$GPRMC,120004.00,A,3930.0000,N,09829.9776,W,15.55,90.0,150626,1.5,W,A*01
$GPGGA,120005.00,A,3930.0000,N,09829.9721,W,1,09,0.9,320.0,M,-15.0,M,,*5E
"Pseudo" is the honest word and the guide keeps it: these
are the daemon's sentences, assembled from its picture of
the stream — checksums recomputed, fields normalised — not
a bit-for-bit replay of the wire. The WATCH echo in t03
shows the swap ("json":false,"nmea":true): one daemon,
two dialects out, chosen per connection. A client that
needs the truly raw binary stream asks for raw mode
instead; gpsmon in chapter 9 does, and the difference
matters there.
Two working habits gpspipe rewards: give every exploratory
run a -n count or a timeout, because a watching client
otherwise runs until stopped — the stream has no end; and
when you save output to a file (-o), record the feeder and
the daemon version beside it, because a JSON log without its
VERSION line cannot later prove which daemon produced it.
Check: run both forms against the feeder. From -w, quote
one TPV's time, lat, lon, speed, and track. From
-r, find the RMC sentence for the same second and confirm
the speed in knots (15.55) is the same motion in older
units.