1GPSFAKE(1) GPSD Documentation GPSFAKE(1)
2
3
4
6 gpsfake - test harness for gpsd, simulating a GPS
7
9 gpsfake [-?] [--baton] [--cycle interval] [--gdb] [--help]
10 [--initcmd initcmd] [--linedump] [--lldb] [--monitor monitor]
11 [--nowait] [--options=options] [--pipe] [--port port]
12 [--predump] [--promptme] [--quiet] [--singleshot] [--slow]
13 [--speed speed] [--tcp] [--timeout timeout] [--udp] [--verbose]
14 [--version] [-1] [-b] [-c interval] [-D debuglevel] [-g] [-G]
15 [-h] [-i] [-l] [-m monitor] [-n] [-o=options] [-p] [-P port]
16 [-q] [-r initcmd] [-S] [-s speed] [-t] [-T] [-u] [-v] [-V]
17 [-W timeout] [logfile...]
18
20 gpsfake is a test harness for gpsd and its clients. It opens a pty
21 (pseudo-TTY), launches a gpsd instance that thinks the slave side of
22 the pty is its GPS device, and repeatedly feeds the contents of one or
23 more test logfiles through the master side to the GPS. If there are
24 multiple logfiles, sentences from them are interleaved in the order the
25 files are specified.
26
27 gpsfake does not require root privileges, and can be run concurrently
28 with a production gpsd instance without causing problems.
29
30 The logfiles may contain packets in any supported format, including in
31 particular NMEA, SiRF, TSIP, or Zodiac. Leading lines beginning with #
32 will be treated as comments and ignored, except in the following
33 special cases:
34
35 • a comment of the form #Date: yyyy-mm-dd (ISO8601 date format) may
36 be used to set the initial date for the log.
37
38 • a comment of the form #Serial: [0-9]* [78][NOE][12] may be used to
39 set serial parameters for the log - baud rate, word length, stop
40 bits.
41
42 • a comment of the form #Transport: UDP may be used to fake a UDP
43 source rather than the normal pty.
44
45 The gpsd instance is run in foreground. The thread sending fake GPS
46 data to the daemon is run in background.
47
49 -?, -h, --help
50 Print a usage message and exit.
51
52 -1, --singleshot
53 The logfile is interpreted once only rather than repeatedly. This
54 option is intended to facilitate regression testing.
55
56 -b, --baton
57 Enable a twirling-baton progress indicator on standard error. At
58 termination, it reports elapsed time.
59
60 -c COUNT, --cycle COUNT
61 Sets the delay between sentences in seconds. Fractional values of
62 seconds are legal. The default is zero (no delay).
63
64 -d LVL, --debug LVL
65 Pass a -D option to the daemon: thus -D 4 is shorthand for -o="-D
66 4".
67
68 -g, -G, --gdb, --lldb
69 Use the monitor facility to run the gpsd instance within gpsfake
70 under control of gdb or lldb, respectively. They also disable the
71 timeout on daemon inactivity, to allow for breakpointing. If
72 necessary, the timeout can be reenabled by a subsequent -W or
73 --wait . If xterm and $DISPLAY are available, these options launch
74 the debugger in a separate xterm window, to separate the debugger
75 dialog from the program output, but otherwise run it directly. In
76 the gdb case, -tui is used with xterm but not otherwise, since
77 curses and program output don't play nicely together. Although lldb
78 lacks an equivalent option, some versions have a 'gui' command.
79
80 -i, --promptme
81 Single-step through logfiles. It dumps the line or packet number
82 (and the sentence if the protocol is textual) followed by "? ".
83 Only when the user keys Enter is the line actually fed to gpsd.
84
85 -l, --linedump
86 Print a line or packet number just before each sentence is fed to
87 the daemon. If the sentence is textual (e.g. NMEA), the text is
88 printed as well. If not, the packet will be printed in hexadecimal
89 (except for RTCM packets, which aren't dumped at all). This option
90 is useful for checking that gpsfake is getting packet boundaries
91 right.
92
93 -m PROG, --monitor PROG
94 Specify a monitor program (PROG) inside which the daemon should be
95 run. This option is intended to be used with valgrind(1), gdb(1)
96 and similar programs.
97
98 -n, --nowait
99 Pass -n to the daemon to start the daemon reading the GPS without
100 waiting for a client (equivalent to -o="-n").
101
102 -o="OPTS", --option="OPTS"
103 Specify options to pass to the daemon. The equal sign (=) and
104 quotes are required so that gpsd options are not confused with
105 gpsfake options. To start the daemon reading the GPS without
106 waiting for a client use -o="-n" (equivalent to the -n) which
107 passes -n to the gpsd daemon. The option -o="-D 4" passes a -D 4 to
108 the daemon, equivalent to the using -D 4.
109
110 -p, --pipe
111 Sets watcher mode and dump the NMEA and GPSD notifications
112 generated by the log to standard output. This is useful for
113 regression-testing.
114
115 -p PORT, --port PORT
116 Sets the daemon's listening port to PORT.
117
118 -q, --quiet
119 Tell gpsfake to suppress normal progress output and thus act in a
120 quiet manner.
121
122 -r STR, --clientinit STR
123 Specify an initialization command to use in pipe mode. The default
124 is ?WATCH={"enable":true,"json":true}.
125
126 -s SPEED, --speed SPEED
127 Sets the baud rate for the slave tty. The default is 4800.
128
129 -S, --slow
130 Tells gpsfake to insert realistic delays in the test input rather
131 than trying to stuff it through the daemon as fast as possible.
132 This will make the test(s) run much slower, but avoids flaky
133 failures due to machine load and possible race conditions in the
134 pty layer.
135
136 -t, --tcp
137 Forces the test framework to use TCP rather than pty devices.
138 Besides being a test of TCP source handling, this may be useful for
139 testing from within chroot jails where access to pty devices is
140 locked out.
141
142 -T, --sysinfo
143 Makes gpsfake print some system information and then exit.
144
145 -u, --udp
146 Forces the test framework to use UDP rather than pty devices.
147 Besides being a test of UDP source handling, this may be useful for
148 testing from within chroot jails where access to pty devices is
149 locked out.
150
151 -v, --verbose
152 Enable verbose progress reports to stderr. Use multiple times to
153 increase verbosity. It is mainly useful for debugging gpsfake
154 itself.
155
156 -w SEC, --wait SEC
157 Set the timeout on daemon inactivity, in seconds. The default
158 timeout is 60 seconds, and a value of 0 suppresses the timeout
159 altogether. Note that the actual timeout is longer due to internal
160 delays, typically by about 20 seconds.
161
162 -x, --predump
163 Dump packets as gpsfake gathers them. It is mainly useful for
164 debugging gpsfake itself.
165
166 The last argument(s) must be the name of a file or files containing the
167 data to be cycled at the device. gpsfake will print a notification
168 each time it cycles.
169
170 Normally, gpsfake creates a pty for each logfile and passes the slave
171 side of the device to the daemon. If the header comment in the logfile
172 contains the string "UDP", packets are instead shipped via UDP port
173 5000 to the address 192.168.0.1.255. You can monitor them with this:
174 tcpdump -s0 -n -A -i lo udp and port 5000.
175
177 Certain magic comments in test load headers can change the conditions
178 of the test. These are:
179
180 Serial:
181 May contain a serial-port setting such as 4800 7N2 - baud rate
182 followed by 7 or 8 for byte length, N or O or E for parity and 1 or
183 2 for stop bits. The test is run with those settings on the slave
184 port that the daemon sees.
185
186 Transport:
187 Values 'TCP' and 'UDP' force the use of TCP and UDP feeds
188 respectively (the default is a pty).
189
190 Delay-Cookie:
191 Must be followed by two whitespace-separated fields, a delimiter
192 character and a numeric delay in seconds. Instead of being broken
193 up by packet boundaries, the test load is split on the delimiters.
194 The delay is performed after each feed. Can be useful for imposing
195 write boundaries in the middle of packets.
196
198 gpsfake is a trivial wrapper around a Python module, also named
199 gpsfake, that can be used to fully script sessions involving a gpsd
200 instance, any number of client sessions, and any number of fake GPSes
201 feeding the daemon instance with data from specified sentence logs.
202
203 Source and embedded documentation for this module is shipped with the
204 gpsd development tools. You can use it to torture-test either gpsd
205 itself or any gpsd-aware client application.
206
207 Logfiles for the use with gpsfake can be retrieved using gpspipe,
208 gpscat, or gpsmon from the gpsd distribution, or any other application
209 which is able to create a compatible output.
210
211 If gpsfake exits with "Cannot execute gpsd: executable not found." the
212 environment variable GPSD_HOME can be set to the path where gpsd can be
213 found. (instead of adding that folder to the PATH environment variable
214
216 For unknown reasons gpsfake may sometimes time out and fail. Set the
217 WRITE_PAD environment value to a larger value to avoid this issue. A
218 starting point might be "WRITE_PAD = 0.005". Values as large os 0.200
219 may be required.
220
222 gpsd(8), gps(1), libgps(3), libgpsmm(3), gpsctl(1), gpspipe(1),
223 gpsprof(1) gpsmon(1).
224
226 Eric S. Raymond <esr@thyrsus.com>.
227
228
229
230The GPSD Project 10 December 2020 GPSFAKE(1)