gpscsv.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!--
  3. This file is Copyright 2020 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='gpscat.1'>
  10. <refentryinfo><date>26 August 2020</date></refentryinfo>
  11. <refmeta>
  12. <refentrytitle>gpscsv</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>gpscsv</refname>
  19. <refpurpose>dump the JSON output from gpsd as CSV</refpurpose>
  20. </refnamediv>
  21. <refsynopsisdiv id='synopsis'>
  22. <cmdsynopsis>
  23. <command>gpscsv</command>
  24. <arg choice='opt'>--count<replaceable> COUNT</replaceable></arg>
  25. <arg choice='opt'>-c<replaceable> MCLASS</replaceable></arg>
  26. <arg choice='opt'>--cvt-isotime</arg>
  27. <arg choice='opt'>--device<replaceable> DEVICE</replaceable></arg>
  28. <arg choice='opt'>-D <replaceable> debuglevel</replaceable></arg>
  29. <arg choice='opt'>--fields<replaceable> FIELDS</replaceable></arg>
  30. <arg choice='opt'>-f <replaceable> FIELDS</replaceable></arg>
  31. <arg choice='opt'>-h</arg>
  32. <arg choice='opt'>--header<replaceable> HEADER</replaceable></arg>
  33. <arg choice='opt'>--help</arg>
  34. <arg choice='opt'>--host<replaceable> HOST</replaceable></arg>
  35. <arg choice='opt'>-n<replaceable> COUNT</replaceable></arg>
  36. <arg choice='opt'>--port<replaceable> PORT</replaceable></arg>
  37. <arg choice='opt'>--seconds<replaceable> FIELDS</replaceable></arg>
  38. <arg choice='opt'>--separator<replaceable> SEPARATOR</replaceable></arg>
  39. <arg choice='opt'>-V</arg>
  40. <arg choice='opt'>--version</arg>
  41. <arg choice='opt'>-x<replaceable> FIELDS</replaceable></arg>
  42. <arg choice='plain'><replaceable>[host[:port[:device]]]</replaceable></arg>
  43. </cmdsynopsis>
  44. </refsynopsisdiv>
  45. <refsect1 id='description'><title>DESCRIPTION</title>
  46. <para><application>gpscsv</application> is a simple Python program
  47. for reading a <application>gpsd</application> JSON data streams and
  48. outputting them in Comma Separated Values (CSV) format. It takes input
  49. from a specified <application>gpsd</application> and reports to standard
  50. output. The program runs until the <application>gpsd</application> dies,
  51. "-n COUNT" messages are processed, "-x SECONDS" have passed, or it is
  52. interrupted by ^C or other means.</para>
  53. <para>One good use of <application>gpscsv</application> is to create
  54. CSV files for use with the <application>gnuplot</application> program.
  55. </para>
  56. </refsect1>
  57. <refsect1 id='options'><title>OPTIONS</title>
  58. <para>The program accepts the following options:</para>
  59. <variablelist remap='TP'>
  60. <varlistentry>
  61. <term>-h, --help</term>
  62. <listitem>
  63. <para>Show help information and exit.</para>
  64. </listitem>
  65. </varlistentry>
  66. <varlistentry>
  67. <term>-c CLASS, --class CLASS</term>
  68. <listitem>
  69. <para>Select the JSON class messages of type CLASS. Default is TPV.
  70. .</para>
  71. </listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term>--cvt-isotime</term>
  75. <listitem>
  76. <para>Convert fields named "time" from ISO time to UNIX time.</para>
  77. </listitem>
  78. </varlistentry>
  79. <varlistentry>
  80. <term>-D DEBUG</term>
  81. <listitem>
  82. <para>Set debug level to DEBUG. Default 0. Higher arguments than D
  83. produce more debug output.</para>
  84. </listitem>
  85. </varlistentry>
  86. <varlistentry>
  87. <term>--device DEVICE</term>
  88. <listitem>
  89. <para>The DEVICE on the <application>gpsd</application> to connect to.
  90. Defaults to all.</para>
  91. </listitem>
  92. </varlistentry>
  93. <varlistentry>
  94. <term>-f FIELDS, --fields FIELDS</term>
  95. <listitem>
  96. <para>The FIELDS from the JSON message to dump to the output.
  97. Set FIELD to empty ('') for all fields Default varies by CLASS.</para>
  98. </listitem>
  99. </varlistentry>
  100. <varlistentry>
  101. <term>--header HEADER</term>
  102. <listitem><para>Set header style to HEADER. 0 for no header, 1 output fields as
  103. header, 2 send fields as a comment ('#').
  104. Defaults to 1.</para>
  105. </listitem>
  106. </varlistentry>
  107. <varlistentry>
  108. <term>--host HOST</term>
  109. <listitem>
  110. <para>Connect to the <application>gpsd</application> on HOST.
  111. Defaults to localhost.</para>
  112. </listitem>
  113. </varlistentry>
  114. <varlistentry>
  115. <term>-n COUNT, --count COUNT</term>
  116. <listitem>
  117. <para>Exit after outputting COUNT records.
  118. Set COUNT to 0 to disable. Default is 0</para>
  119. </listitem>
  120. </varlistentry>
  121. <varlistentry>
  122. <term>--port PORT</term>
  123. <listitem>
  124. <para>Use PORT to connect to <application>gpsd</application>.
  125. Defaults to 2947.</para>
  126. </listitem>
  127. </varlistentry>
  128. <varlistentry>
  129. <term>--separator SEPARATOR</term>
  130. <listitem>
  131. <para>Use SEPARATOR as the field separator.
  132. Default separator is a comma (',').</para>
  133. </listitem>
  134. </varlistentry>
  135. <varlistentry>
  136. <term>-V, --version</term>
  137. <listitem>
  138. <para>Show <application>gpscsv</application> version, and exit.</para>
  139. </listitem>
  140. </varlistentry>
  141. <varlistentry>
  142. <term>-x SECONDS, --seconds SECONDS</term>
  143. <listitem>
  144. <para>Exit after SECONDS number of seconds have passed.
  145. Set SECONDS to 0 to disable. Default is 0</para>
  146. </listitem>
  147. </varlistentry>
  148. </variablelist>
  149. </refsect1>
  150. <refsect1 id='examples'><title>EXAMPLES</title>
  151. <para>Some basic examples, do them in exact order shown:</para>
  152. <para>
  153. Grab 100 samples of time,lat,lon,altHAE:
  154. </para>
  155. <programlisting>
  156. $ gpscsv -n 100 --cvt-isotime > tpv.dat
  157. </programlisting>
  158. <para>
  159. Grab 100 samples of time,epx,epy,epv,eph,sep
  160. </para>
  161. <programlisting>
  162. $ gpscsv -n 100 --cvt-isotime -f time,epx,epy,epv,eph,sep > ep.dat
  163. </programlisting>
  164. <para>
  165. Grab 100 samples of time,xdop,ydop,vdop,tdop,hdop,gdop,pdop
  166. </para>
  167. <programlisting>
  168. $ gpscsv -n 100 --cvt-isotime -c SKY > sky.dat
  169. </programlisting>
  170. <para>
  171. Grab 100 samples of time,nSat,uSat
  172. </para>
  173. <programlisting>
  174. $ gpscsv -n 100 --cvt-isotime -c SKY -f time,nSat,uSat > sat.dat
  175. </programlisting>
  176. <para>
  177. start gnuplot in interactive mode:
  178. </para>
  179. <programlisting>
  180. $ gnuplot
  181. </programlisting>
  182. <para>
  183. Some gnuplot housekeeping:
  184. </para>
  185. <programlisting>
  186. # this are csv files
  187. gnuplot> set datafile separator ','
  188. # use the first line as title
  189. gnuplot> set key autotitle columnhead
  190. # X axis is UNIT time in seconds.
  191. gnuplot> set xdata time
  192. gnuplot> set timefmt "%s"
  193. </programlisting>
  194. <para>
  195. Now to plot time vs latitude:
  196. </para>
  197. <programlisting>
  198. gnuplot> plot 'tpv.dat' using 1:2
  199. </programlisting>
  200. <para>
  201. Then to plot longitude and altHAE, in separate plots:
  202. </para>
  203. <programlisting>
  204. gnuplot> plot 'tpv.dat' using 1:3
  205. gnuplot> plot 'tpv.dat' using 1:4
  206. </programlisting>
  207. <para>
  208. Put both latitude and longitude on one plot:
  209. </para>
  210. <programlisting>
  211. gnuplot> set y2tics
  212. gnuplot> plot 'tpv.dat' using 1:2, '' using 1:3 axes x1y2
  213. </programlisting>
  214. <para>
  215. Plot epx, epy, epv, eph, and sep in one plot:
  216. </para>
  217. <programlisting>
  218. gnuplot> plot 'ep.dat' using 1:2, '' using 1:3, \
  219. '' using 1:4, '' using 1:5, '' using 1:6
  220. </programlisting>
  221. <para>
  222. Plot all the DOPs on one plot:
  223. </para>
  224. <programlisting>
  225. gnuplot> plot 'sky.dat' using 1:2, '' using 1:3, '' using 1:4, \
  226. '' using 1:5, '' using 1:6, '' using 1:7, '' using 1:8
  227. </programlisting>
  228. <para>
  229. Plot nSat and uSat together:
  230. </para>
  231. <programlisting>
  232. gnuplot> plot 'sat.dat' using 1:2, '' using 1:3
  233. </programlisting>
  234. <para>
  235. Lat/lon scatter plot:
  236. </para>
  237. <programlisting>
  238. # x is no longer time
  239. gnuplot> set xdata
  240. gnuplot> plot 'tpv.dat' using 3:2 title 'fix'
  241. </programlisting>
  242. </refsect1>
  243. <refsect1 id='see_also'><title>SEE ALSO</title>
  244. <para>
  245. <citerefentry><refentrytitle>gpsd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
  246. </para>
  247. </refsect1>
  248. <refsect1 id='maintainer'><title>AUTHOR</title>
  249. <para>Gary E. Miller <email>gem@rellim.com</email>.</para>
  250. </refsect1>
  251. </refentry>