gpsfake.xml 12 KB

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