diff options
-rwxr-xr-x | gpsfake | 15 | ||||
-rw-r--r-- | gpsfake.xml | 74 | ||||
-rwxr-xr-x | gpsprof | 13 | ||||
-rw-r--r-- | gpsprof.xml | 9 |
4 files changed, 102 insertions, 9 deletions
@@ -6,16 +6,19 @@ import sys, os, time, signal, pty, getopt, tempfile, termios -(options, arguments) = getopt.getopt(sys.argv[1:], "i:hn") +(options, arguments) = getopt.getopt(sys.argv[1:], "i:hns:") interval = 1 +speed = 0 spawn = True for (switch, val) in options: if (switch == '-i'): interval = int(val) elif (switch == '-n'): spawn = False + elif (switch == '-s'): + speed = int(val) elif (switch == '-h'): - sys.stderr.write("usage: gpsfake [-h] [-n] [-i interval]\n") + sys.stderr.write("usage: gpsfake [-h] [-n] [-s speed] [-i interval]\n") logfile = arguments[0] try: @@ -25,9 +28,13 @@ except: sys.exit(1) slave = os.ttyname(slave_fd) +spawncmd = "gpsd -P /tmp/gpsfake%d -p %s" % (os.getpid(), slave) +if speed: + spawncmd += " -s %d" % speed + if not spawn: sys.stderr.write("gpsfake: slave tty is %s\n" % slave) -elif os.system("gpsd -P /tmp/gpsfake%d -p %s" % (os.getpid(), slave)): +elif os.system(spawncmd): sys.stderr.write("gpsfake: gpsd launch failed.\n") else: sys.stderr.write("gpsfake: gpsd launch OK.\n") @@ -49,7 +56,7 @@ try: raw[2] |= (termios.CSIZE & termios.CS8) # cflag raw[2] |= termios.CREAD | termios.CLOCAL # cflag raw[3] = 0 # lflag - raw[4] = raw[5] = termios.B4800 + raw[4] = raw[5] = eval("termios.B" + speed) termios.tcsetattr(ttyfp.fileno(), termios.TCSANOW, raw) i = 0; diff --git a/gpsfake.xml b/gpsfake.xml new file mode 100644 index 00000000..8dad1972 --- /dev/null +++ b/gpsfake.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE refentry PUBLIC + "-//OASIS//DTD DocBook XML V4.1.2//EN" + "docbook/docbookx.dtd"> +<refentry id='gpsfake.1'> +<refmeta> +<refentrytitle>gpsfake</refentrytitle> +<manvolnum>1</manvolnum> +<refmiscinfo class='date'>12 Feb 2005</refmiscinfo> +</refmeta> +<refnamediv id='name'> +<refname>gpsfake</refname> +<refpurpose>test harness for gpsd, simulating a GPS</refpurpose> +</refnamediv> +<refsynopsisdiv id='synopsis'> + +<cmdsynopsis> + <command>gpsfake</command> + <arg choice='opt'>-h</arg> + <arg choice='opt'>-i <replaceable>interval</replaceable></arg> + <arg choice='opt'>-n</arg> + <arg choice='opt'>-s <replaceable>speed</replaceable></arg> + <arg choice='opt'><replaceable>logfile</replaceable></arg> +</cmdsynopsis> +</refsynopsisdiv> + +<refsect1 id='description'><title>DESCRIPTION</title> + +<para><application>gpsfake</application> is a test harness for +<application>gpsd</application> and its clients. It opens a pty +(pseudo-TTY), launches a <application>gpsd</application> instance that +thinks the slave side of the pty is its GPS device, and repeatedly +feeds the contents of a test logfile through the master side to the +GPS.</para> + +</refsect1> +<refsect1 id='options'><title>OPTIONS</title> + +<para>The -n option suppresses launch of the daemon. Instead, +<application>gpsfake</application> will tell you the name of the slave +pty so you can launch in instance that reads it.</para> + +<para>The -s option sets the baud rate. Note, this will only work if +the chipset accepts a speed-change command (SiRF-II supports this +feature).</para> + +<para>The -h option makes <application>gpsfake</application> print +a usage message and exit.</para> + +<para>The argument must be the name of a file containing the text of +NMEA sentences to be cycled at the device.</para> + +</refsect1> +<refsect1 id='see_also'><title>SEE ALSO</title> +<para> +<citerefentry><refentrytitle>gpsd</refentrytitle><manvolnum>1</manvolnum></citerefentry> +<citerefentry><refentrytitle>libgps</refentrytitle><manvolnum>3</manvolnum></citerefentry> +<citerefentry><refentrytitle>libgpsd</refentrytitle><manvolnum>3</manvolnum></citerefentry> +<citerefentry><refentrytitle>gpsprobe</refentrytitle><manvolnum>1</manvolnum></citerefentry> +<citerefentry><refentrytitle>gpsprof</refentrytitle><manvolnum>1</manvolnum></citerefentry> +<citerefentry><refentrytitle>gnuplot</refentrytitle><manvolnum>1</manvolnum></citerefentry> +</para> +</refsect1> + +<refsect1 id='maintainer'><title>AUTHOR</title> + +<para>Eric S. Raymond <email>esr@thyrsus.com</email>. There is a +project page for <application>gpsd</application> <ulink +url="http://gpsd.berlios.de/">here</ulink>.</para> + +</refsect1> + +</refentry> + @@ -120,10 +120,11 @@ plot \\ formatters = (rawplot, stripplot, splitplot) if __name__ == '__main__': - (options, arguments) = getopt.getopt(sys.argv[1:], "f:hn:o:rt:T:") + (options, arguments) = getopt.getopt(sys.argv[1:], "f:hn:o:rs:t:T:") formatter = splitplot raw = False file = None + speed = 0 terminal = None title = time.ctime() await = 100 @@ -141,13 +142,15 @@ if __name__ == '__main__': file = val elif (switch == '-r'): raw = True + elif (switch == '-s'): + speed = int(val) elif (switch == '-t'): title = val elif (switch == '-T'): terminal = val elif (switch == '-h'): sys.stderr.write("usage: gpsprof [-h] [-r] [-n samplecount] " - + "[-f {" + "|".join(map(lambda x: x.name, formatters)) + "}] [-t title] [-o file]\n") + + "[-f {" + "|".join(map(lambda x: x.name, formatters)) + "}] [-s speed] [-t title] [-o file]\n") sys.exit(0) plotter = formatter() if file: @@ -163,7 +166,11 @@ if __name__ == '__main__': sys.stderr.write("gpsprof: gpsd unreachable.\n") sys.exit(0) try: - session.query("wbz=1") + if speed: + session.query("b=%d", speed) + if session.baudrate != speed: + sys.stderr.write("gpsprof: baud rate change failed.\n") + session.query("wz+b") plotter.header(out) while await > 0: session.poll() diff --git a/gpsprof.xml b/gpsprof.xml index 113e3e0b..35156abf 100644 --- a/gpsprof.xml +++ b/gpsprof.xml @@ -20,6 +20,7 @@ <arg choice='opt'>-n <replaceable>packetcount</replaceable></arg> <arg choice='opt'>-o <replaceable>outfile</replaceable></arg> <arg choice='opt'>-r </arg> + <arg choice='opt'>-s <replaceable>speed</replaceable></arg> <arg choice='opt'>-t <replaceable>title</replaceable></arg> <arg choice='opt'>-T <replaceable>terminal type</replaceable></arg> <arg choice='opt'>-h</arg> @@ -39,7 +40,7 @@ especially in combination with the static-precision reports from <para><application>gpsprof</application> uses instrumentation built into <application>gpsd</application> that will only be present if -it was configiured to support profiling.</para> +it was configured to support profiling.</para> <para>Graphs are generated using <citerefentry><refentrytitle>gnuplot</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> @@ -123,9 +124,13 @@ is 100.</para> <para>The -o option specifies the name of a file in which to dump the profiling data; <citerefentry><refentrytitle>gnuplot</refentrytitle><manvolnum>1</manvolnum></citerefentry> -will read ot from there. If this option is not specified, the data +will read out from there. If this option is not specified, the data will be written to a tempfile and discarded after the plot id made</para> +<para>The -s option sets the baud rate. Note, this will only work if +the chipset accepts a speed-change command (SiRF-II supports this +feature).</para> + <para>The -t option sets a text string to be included in the plot title. Specifying the GPS make and model is a good use for it.</para> |