Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

275 lines
12 KiB

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!--
  3. This file is Copyright (c) 2010 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>12 Feb 2005</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
  110. monitor facility to run the <application>gpsd</application> instance
  111. within gpsfake under control of gdb or lldb, respectively. They also
  112. disable the timeout on daemon inactivity, to allow for breakpointing. If
  113. necessary, the timeout can be reenabled by a subsequent
  114. <option>-W</option>.</para>
  115. <para>The <option>-o</option> specifies options to pass to the daemon. The -n
  116. option passes -n to start the daemon reading the GPS without waiting
  117. for a client (equivalent to -o "-n"). The <option>-D</option> passes a -D
  118. option to the daemon: thus -D 4 is shorthand for -o "-D 4".</para>
  119. <para>The -p ("pipe") option sets watcher mode and dumps the NMEA and GPSD
  120. notifications generated by the log to standard output. This is useful
  121. for regression-testing.</para>
  122. <para>The -P ("port") option sets the daemon's listening port.</para>
  123. <para>The <option>-q</option> tells gpsfake to suppress normal progress
  124. output and thus act in a quiet manner.</para>
  125. <para>The <option>-r</option> specifies an initialization command to use in pipe mode.
  126. The default is <command>?WATCH={"enable":true,"json":true}</command>.</para>
  127. <para>The <option>-s</option> sets the baud rate for the slave tty. The
  128. default is 4800.</para>
  129. <para>The option -S tells gpsfake to insert realistic delays in the
  130. test input rather than trying to stuff it through the daemon as fast
  131. as possible. This will make the test(s) run much slower, but avoids
  132. flaky failures due to machine lode and possible race conditions in
  133. the pty layer.</para>
  134. <para>The <option>-t</option> forces the test framework to use TCP
  135. rather than pty devices. Besides being a test of TCP source handling,
  136. this may be useful for testing from within chroot jails where access
  137. to pty devices is locked out.</para>
  138. <para>The <option>-T</option> makes <application>gpsfake</application> print
  139. some system information and then exits.</para>
  140. <para>The <option>-u</option> forces the test framework to use UDP
  141. rather than pty devices. Besides being a test of UDP source handling,
  142. this may be useful for testing from within chroot jails where access
  143. to pty devices is locked out.</para>
  144. <para>The <option>-v</option> enables verbose progress reports to stderr. It is
  145. mainly useful for debugging <application>gpsfake</application>
  146. itself.</para>
  147. <para>The <option>-W</option> ("wait") option sets the timeout on daemon
  148. inactivity, in seconds. The default timeout is 60 seconds, and a value
  149. of 0 suppresses the timeout altogether. Note that the actual timeout is
  150. longer due to internal delays, typically by about 20 seconds.</para>
  151. <para>The <option>-x</option> dumps packets as
  152. <application>gpsfake</application> gathers them. It is mainly useful
  153. for debugging <application>gpsfake</application> itself.</para>
  154. <para>The <option>-h</option> makes <application>gpsfake</application> print
  155. a usage message and exit.</para>
  156. <para>The argument must be the name of a file containing the
  157. data to be cycled at the device. <application>gpsfake</application>
  158. will print a notification each time it cycles.</para>
  159. <para>Normally, gpsfake creates a pty for each logfile and passes the
  160. slave side of the device to the daemon. If the header comment in the
  161. logfile contains the string "UDP", packets are instead shipped via UDP
  162. port 5000 to the address 192.168.0.1.255. You can monitor them with
  163. this: <command>tcpdump -s0 -n -A -i lo udp and port 5000</command>.</para>
  164. </refsect1>
  165. <refsect1 id='magic'><title>MAGIC COMMENTS</title>
  166. <para>Certain magic comments in test load headers can change the
  167. conditions of the test. These are:</para>
  168. <variablelist>
  169. <varlistentry>
  170. <term>Serial:</term>
  171. <listitem><para>May contain a serial-port setting such as 4800 7N2 -
  172. baud rate followed by 7 or 8 for byte length, N or O or E for parity
  173. and 1 or 2 for stop bits. The test is run with those settings on the
  174. slave port that the daemon sees.</para></listitem>
  175. </varlistentry>
  176. <varlistentry>
  177. <term>Transport:</term>
  178. <listitem><para>Values 'TCP' and 'UDP' force the use of TCP and
  179. UDP feeds respectively (the default is a pty).</para></listitem>
  180. </varlistentry>
  181. <varlistentry>
  182. <term>Delay-Cookie:</term>
  183. <listitem><para>Must be followed by two whitespace-separated fields, a
  184. delimiter character and a numeric delay in seconds. Instead of being
  185. broken up by packet boundaries, the test load is split on the
  186. delimiters. The delay is performed after each feed. Can be useful
  187. for imposing write boundaries in the middle of packets.
  188. </para></listitem>
  189. </varlistentry>
  190. </variablelist>
  191. </refsect1>
  192. <refsect1 id='custom'><title>CUSTOM TESTS</title>
  193. <para><application>gpsfake</application> is a trivial wrapper around a
  194. Python module, also named gpsfake, that can be used to fully script
  195. sessions involving a <application>gpsd</application> instance, any
  196. number of client sessions, and any number of fake GPSes feeding the
  197. daemon instance with data from specified sentence logs.</para>
  198. <para>Source and embedded documentation for this module is shipped with the
  199. <application>gpsd</application> development tools. You can use it to
  200. torture-test either <application>gpsd</application> itself or any
  201. <application>gpsd</application>-aware client application.</para>
  202. <para>Logfiles for the use with <application>gpsfake</application> can
  203. be retrieved using <application>gpspipe</application>,
  204. <application>gpscat</application>, or
  205. <application>gpsmon</application> from the gpsd distribution, or any
  206. other application which is able to create a compatible output.</para>
  207. <para>If <application>gpsfake</application> exits with "Cannot execute
  208. gpsd: executable not found." the environment variable GPSD_HOME can be
  209. set to the path where gpsd can be found. (instead of adding that folder
  210. to the PATH environment variable</para>
  211. </refsect1>
  212. <refsect1 id='see_also'><title>SEE ALSO</title>
  213. <para>
  214. <citerefentry><refentrytitle>gpsd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
  215. <citerefentry><refentrytitle>gps</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
  216. <citerefentry><refentrytitle>libgps</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
  217. <citerefentry><refentrytitle>libgpsmm</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
  218. <citerefentry><refentrytitle>gpsctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
  219. <citerefentry><refentrytitle>gpspipe</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
  220. <citerefentry><refentrytitle>gpsprof</refentrytitle><manvolnum>1</manvolnum></citerefentry>
  221. <citerefentry><refentrytitle>gpsmon</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
  222. </para>
  223. </refsect1>
  224. <refsect1 id='maintainer'><title>AUTHOR</title>
  225. <para>Eric S. Raymond <email>esr@thyrsus.com</email>.</para>
  226. </refsect1>
  227. </refentry>