diff options
author | Fred Wright <fw@fwright.net> | 2018-12-27 12:51:13 -0800 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2018-12-27 20:35:21 -0800 |
commit | adacc2331d51fce112bd5ad4a57d0a24f8adb11d (patch) | |
tree | a80c7e072395432fa65f2b06afa99bc0ff0ce182 /gpsfake | |
parent | 41d3943276c922aed53984b3e5948b6814b35b0d (diff) | |
download | gpsd-adacc2331d51fce112bd5ad4a57d0a24f8adb11d.tar.gz |
gpsfake: Allow timeout to be specified.
This adds an argument to allow overriding the default 60-second
timeout on gpsd's activity. A value of 0 disables the timeout
completely. Note that the timeout mechanism is somewhat sloppy, and
typically adds about 20s to the value.
TESTED:
Ran with unspecified (default) timeout, a short timeout, a long
timeout, and no timeout, all with reasonable results.
Diffstat (limited to 'gpsfake')
-rwxr-xr-x | gpsfake | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -156,13 +156,14 @@ if __name__ == '__main__': [-T] print some system information and exit [-v] verbose [-V] Version + [-W] specify timeout (default 60s), 0 means none [-x] dump packets as gpsfake gathers them """) raise SystemExit(0) try: (options, arguments) = getopt.getopt(sys.argv[1:], - "1bc:D:ghilm:no:pP:qr:s:StTuvxV") + "1bc:D:ghilm:no:pP:qr:s:StTuvxVW:") except getopt.GetoptError as msg: print("gpsfake: " + str(msg)) raise SystemExit(1) @@ -184,6 +185,7 @@ if __name__ == '__main__': verbose = 0 slow = False quiet = False + timeout = None # Really means default for (switch, val) in options: if switch == '-1': singleshot = True @@ -233,6 +235,12 @@ if __name__ == '__main__': elif switch == '-V': sys.stderr.write("gpsfake: Version %s\n" % gps_version) sys.exit(0) + elif switch == '-W': + try: + timeout = int(val) + except: + sys.stderr.write("gpsfake: bad timeout value.\n") + raise SystemExit(1) elif switch == '-x': predump = True @@ -257,7 +265,7 @@ if __name__ == '__main__': test = gpsfake.TestSession(prefix=monitor, port=port, options=doptions, tcp=tcp, udp=udp, verbose=verbose, - predump=predump, slow=slow) + predump=predump, slow=slow, timeout=timeout) if pipe: test.reporter = bytesout.write |