1GPSCSV(1)                     GPSD Documentation                     GPSCSV(1)
2
3
4

NAME

6       gpscsv - dump the JSON output from gpsd as CSV
7

SYNOPSIS

9       gpscsv [OPTIONS] [host[:port[:device]]]
10
11       gpscsv -h
12
13       gpscsv -V
14

DESCRIPTION

16       gpscsv is a simple Python program for reading gpsd JSON data streams
17       and outputting them in Comma Separated Values (CSV) format. It takes
18       input from a specified gpsd and reports to standard output. The program
19       runs until the gpsd dies, "-n COUNT" messages are processed, "-x
20       SECONDS" have passed, or it is interrupted by ^C or other means.
21
22       gpscsv can only collect data that your gpsd is already sending. Use
23       gpspipe to see what JSON message classes it is sending.
24
25       One good use of gpscsv is to create CSV files for use with the gnuplot
26       program.
27
28       gpscsv does not need root, but will run fine as root.
29

OPTIONS

31       The program accepts the following options:
32
33       -?, -h, --help
34           Show help information and exit.
35
36       -c MCLASS, --class MCLASS
37           Select the JSON class messages of type MCLASS. Overrides the
38           default class of TPV. See the Classes section below for more
39           information.
40
41       --cvt-isotime
42           Convert fields named "time" from ISO time to UNIX time.
43
44       -D LVL, --debug LVL
45           Set debug level to LVL. Default 0. Higher arguments than 0 produce
46           more debug output.
47
48       --device DEVICE
49           The DEVICE on the gpsd to connect to. Defaults to all.
50
51       -f FIELDS, -fields FIELDS
52           The FIELDS from the JSON message to dump to the output. Set FIELD
53           to empty ('') for all initially seen fields. Default varies by
54           CLASS.
55
56       --file FILE
57           Read JSON from FILE instead of from gpsd.
58
59       --header HEADER
60           Set header style to HEADER. 0 for no header, 1 output fields as
61           header, 2 send fields as a comment ('#'). Defaults to 1.
62
63       --host HOST
64           Connect to the gpsd on HOST. Defaults to localhost.
65
66       -n COUNT, --count COUNT
67           Exit after outputting COUNT records. Set COUNT to 0 to disable.
68           Default is 0
69
70       --port PORT
71           Use PORT to connect to gpsd. Defaults to 2947.
72
73       --separator SEPARATOR
74           Use SEPARATOR as the field separator. Default separator is a comma
75           (',').
76
77       -V, --version
78           Show gpscsv version, and exit.
79
80       -x SECONDS, --seconds SECONDS
81           Exit after SECONDS number of seconds have passed. Set SECONDS to 0
82           to disable. Default is 0
83
84       All the above individual options may be specified multiple times, but
85       t only the last one off each will be used.
86

CLASSES

88       Some of the gpsd JSON message classes include sub-classes. gpscsv
89       allows direct access to them using a meta-class (MCLASS).
90
91       ┌──────────┬──────────┬─────────────────────┐
92       │          │          │                     │
93       │MCLASS    │ Class    │ Description         │
94       ├──────────┼──────────┼─────────────────────┤
95       │          │          │                     │
96       │ALMANAC   │ SUBFRAME │ ALMANAC from        │
97       │          │          │ SUBFRAME JSON       │
98       ├──────────┼──────────┼─────────────────────┤
99       │          │          │                     │
100       │HEALTH    │ SUBFRAME │ HEALTH from         │
101       │          │          │ SUBFRAME JSON       │
102       ├──────────┼──────────┼─────────────────────┤
103       │          │          │                     │
104       │HEALTH2   │ SUBFRAME │ HEALTH2 from        │
105       │          │          │ SUBFRAME JSON       │
106       ├──────────┼──────────┼─────────────────────┤
107       │          │          │                     │
108       │IONO      │ SUBFRAME │ IONO from SUBFRAME  │
109       │          │          │ JSON                │
110       ├──────────┼──────────┼─────────────────────┤
111       │          │          │                     │
112       │NMCT      │ SUBFRAME │ NMCT from SUBFRAME  │
113       │          │          │ JSON                │
114       ├──────────┼──────────┼─────────────────────┤
115       │          │          │                     │
116       │SUBFRAME1 │ SUBFRAME │ SUBFRAME1           │
117       │          │          │ (Ephemeris 1) from  │
118       │          │          │ SUBFRAME JSON       │
119       ├──────────┼──────────┼─────────────────────┤
120       │          │          │                     │
121       │SUBFRAME2 │ SUBFRAME │ SUBFRAME2           │
122       │          │          │ (Ephemeris 2) from  │
123       │          │          │ SUBFRAME JSON       │
124       ├──────────┼──────────┼─────────────────────┤
125       │          │          │                     │
126       │SUBFRAME3 │ SUBFRAME │ SUBFRAME3           │
127       │          │          │ (Ephemeris 3) from  │
128       │          │          │ SUBFRAME JSON       │
129       ├──────────┼──────────┼─────────────────────┤
130       │          │          │                     │
131       │SAT       │ SKY      │ Individual          │
132       │          │          │ satellites from SKY │
133       ├──────────┼──────────┼─────────────────────┤
134       │          │          │                     │
135       │SKY       │ SKY      │ The basic parts of  │
136       │          │          │ SKY JSON            │
137       ├──────────┼──────────┼─────────────────────┤
138       │          │          │                     │
139       │TPV       │ TPV      │ The basic parts of  │
140       │          │          │ TPV JSON            │
141       └──────────┴──────────┴─────────────────────┘
142

ARGUMENTS

144       By default, clients collect data from the local gpsd daemon running on
145       localhost, using the default GPSD port 2947. The optional argument to
146       any client may override this behavior: [server[:port[:device]]]
147
148       For further explanation, and examples, see the ARGUMENTS section in the
149       gps(1) man page
150

EXAMPLES

152       Some basic standalone examples:
153
154       Grab three cycles of TPV data:
155
156           $ gpscsv -c TPV -n 3
157           time,lat,lon,altHAE
158           2021-07-28T22:38:37.000Z,44.0688638,-121.3140643,1108.223
159           2021-07-26T22:38:37.000Z,44.068863833,-121.314064333,1108.3
160           2021-07-28T22:38:38.000Z,44.0688637,-121.314065,1108.363
161
162       Grab one set of satellite data:
163
164           $ gpscsv -c SAT -n 1
165           time,gnssid,svid,PRN,az,el,ss,used,health
166           2021-07-28T22:37:46.000Z,0,8,8,311.0,28.0,33.0,True,1
167           2021-07-28T22:37:46.000Z,0,10,10,290.0,74.0,50.0,True,1
168           2021-07-28T22:37:46.000Z,0,15,15,45.0,18.0,31.0,False,1
169           2021-07-28T22:37:46.000Z,0,16,16,244.0,7.0,23.0,True,1
170           2021-07-28T22:37:46.000Z,0,18,18,109.0,43.0,37.0,True,1
171           2021-07-28T22:37:46.000Z,0,23,23,49.0,62.0,38.0,True,1
172           2021-07-28T22:37:46.000Z,0,24,24,87.0,16.0,28.0,True,1
173           2021-07-28T22:37:46.000Z,0,27,27,280.0,52.0,42.0,True,1
174           2021-07-28T22:37:46.000Z,0,32,32,188.0,32.0,42.0,True,1
175           2021-07-28T22:37:46.000Z,5,3,195,305.0,6.0,13.0,False,1
176           2021-07-28T22:37:46.000Z,6,2,66,38.0,8.0,21.0,False,1
177           2021-07-28T22:37:46.000Z,6,3,67,34.0,60.0,32.0,True,1
178           2021-07-28T22:37:46.000Z,6,4,68,226.0,63.0,34.0,True,1
179           2021-07-28T22:37:46.000Z,6,5,69,220.0,12.0,32.0,True,1
180           2021-07-28T22:37:46.000Z,6,11,75,-999,4.0,0.0,False,2
181           2021-07-28T22:37:46.000Z,6,12,76,47.0,0.0,0.0,False,1
182           2021-07-28T22:37:46.000Z,6,17,81,142.0,8.0,31.0,True,1
183           2021-07-28T22:37:46.000Z,6,18,82,138.0,57.0,40.0,True,1
184           2021-07-28T22:37:46.000Z,6,19,83,333.0,70.0,29.0,True,1
185           2021-07-28T22:37:46.000Z,6,20,84,323.0,10.0,0.0,False,1
186
187   Plot Examples
188       Some plot examples, do them in exact order shown:
189
190       Grab 100 samples of time,lat,lon,altHAE:
191
192             $ gpscsv -n 100 --cvt-isotime  > tpv.dat
193
194       Grab 100 samples of time,epx,epy,epv,eph,sep
195
196             $ gpscsv -n 100 --cvt-isotime -f time,epx,epy,epv,eph,sep > ep.dat
197
198       Grab 100 samples of time,xdop,ydop,vdop,tdop,hdop,gdop,pdop
199
200             $ gpscsv -n 100 --cvt-isotime -c SKY  > sky.dat
201
202       Grab 100 samples of time,nSat,uSat
203
204             $ gpscsv -n 100 --cvt-isotime -c SKY -f time,nSat,uSat  > sat.dat
205
206   Viewing CSV data with gnuplot
207       Start gnuplot in interactive mode:
208
209             $ gnuplot
210
211       Some gnuplot housekeeping:
212
213             # this are csv files
214             gnuplot> set datafile separator ','
215             # use the first line as title
216             gnuplot> set key autotitle columnhead
217             # X axis is UNIT time in seconds.
218             gnuplot> set xdata time
219             gnuplot> set timefmt "%s"
220
221       Now to plot time vs latitude, using tpv.dat from above:
222
223             gnuplot> plot 'tpv.dat' using 1:2
224
225       Then to plot longitude and altHAE, in separate plots:
226
227             gnuplot> plot 'tpv.dat' using 1:3
228             gnuplot> plot 'tpv.dat' using 1:4
229
230       Put both latitude and longitude on one plot:
231
232             gnuplot> set y2tics
233             gnuplot> plot 'tpv.dat' using 1:2, '' using 1:3 axes x1y2
234
235       Plot epx, epy, epv, eph, and sep in one plot, using ep.dat from above:
236
237             gnuplot> plot 'ep.dat' using 1:2, '' using 1:3, \
238                      '' using 1:4, '' using 1:5, '' using 1:6
239
240       Plot all the DOPs on one plot, from sky.dat above:
241
242             gnuplot> plot 'sky.dat' using 1:2, '' using 1:3, '' using 1:4, \
243                      '' using 1:5, '' using 1:6, '' using 1:7, '' using 1:8
244
245       Plot nSat and uSat together:
246
247             gnuplot> plot 'sat.dat' using 1:2, '' using 1:3
248
249       Lat/lon scatter plot:
250
251             # x is no longer time
252             gnuplot> set xdata
253             gnuplot> plot 'tpv.dat' using 3:2 title 'fix'
254

RETURN VALUES

256       0
257           on success.
258
259       1
260           on failure
261

SEE ALSO

263       gpspipe(1), gpsd_json(5), gpsd(8), gnuplot(1)
264

RESOURCES

266       Project web site: https://gpsd.io/
267

COPYING

269       This file is Copyright 2020 by the GPSD project
270       SPDX-License-Identifier: BSD-2-clause
271

AUTHOR

273       Gary E. Miller
274
275
276
277GPSD, Version 3.24                2021-09-20                         GPSCSV(1)
Impressum