diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2008-07-12 10:23:37 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2008-07-12 10:23:37 +0000 |
commit | 16b377799019ecac59ee12aa3d725200b8095499 (patch) | |
tree | 7b43c47bf82b14b7452caa413808af243e241538 | |
parent | 86caadedb470a56d72c557b4f7fa73919a8b50e6 (diff) | |
download | gpsd-16b377799019ecac59ee12aa3d725200b8095499.tar.gz |
Add verbosity option to gpscat.
-rwxr-xr-x | gpscat | 14 | ||||
-rw-r--r-- | gpscat.xml | 10 | ||||
-rw-r--r-- | gpspacket.c | 2 |
3 files changed, 24 insertions, 2 deletions
@@ -8,6 +8,9 @@ import gpspacket # The spec says 82, but some receivers (TN-200, GSW 2.3.2) output 86 characters NMEA_MAX = 86 +# Lowest debug level at which packet getter begins to emit messages, minus one +BASELEVEL = 5 + def hexdump(str): dmp = "" for (i, ch) in enumerate(str): @@ -21,11 +24,17 @@ def hexdump(str): dmp += "\\x%02x" % ord(ch) return dmp +debuglevel = 0 + +def reporter(errlevel, msg): + if errlevel <= debuglevel: + sys.stdout.write(msg) + if __name__ == '__main__': buf = "" try: try: - (options, arguments) = getopt.getopt(sys.argv[1:], "hps:V") + (options, arguments) = getopt.getopt(sys.argv[1:], "hps:v:V") except getopt.GetoptError, msg: print "gpscat: " + str(msg) raise SystemExit, 1 @@ -47,6 +56,8 @@ if __name__ == '__main__': elif switch == 't': typeflag = True rawmode = False + elif switch == '-v': + debuglevel = BASELEVEL + int(val) elif switch == '-h': sys.stderr.write("usage: gpscat [-s speed] serial-port\n") raise SystemExit, 0 @@ -86,6 +97,7 @@ if __name__ == '__main__': buf = "" if not rawmode: getter = gpspacket.new() + gpspacket.register_report(reporter) while True: (fd, event) = poller.poll()[0] if fd == tty and event == select.POLLIN: @@ -19,6 +19,7 @@ <arg choice='opt'>-s <replaceable>speed</replaceable></arg> <arg choice='opt'>-p</arg> <arg choice='opt'>-t</arg> + <arg choice='opt'>-v <replaceable>debuglevel</replaceable></arg> <arg choice='plain'><replaceable>serial-port</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> @@ -85,6 +86,15 @@ a colon on each line.</para> </varlistentry> <varlistentry> +<term>-v</term> +<listitem> +<para>In packetizer mode, enable progress messages from the packet +getter. Probably only of interest to developers testing packet +getter changes.</para> +</listitem> +</varlistentry> + +<varlistentry> <term>-h</term> <listitem> <para>Display program usage and exit.</para> diff --git a/gpspacket.c b/gpspacket.c index af31b25b..85f208b6 100644 --- a/gpspacket.c +++ b/gpspacket.c @@ -12,7 +12,7 @@ static PyObject *ErrorObject = NULL; static PyObject *report_callback = NULL; -void gpsd_report(int errlevel UNUSED, const char *fmt, ... ) +void gpsd_report(int errlevel, const char *fmt, ... ) { char buf[BUFSIZ]; PyObject *args; |