gpsfake.xml 14 KB

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