From adacc2331d51fce112bd5ad4a57d0a24f8adb11d Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Thu, 27 Dec 2018 12:51:13 -0800 Subject: 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. --- gpsfake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gpsfake') diff --git a/gpsfake b/gpsfake index e0578c48..090e5600 100755 --- a/gpsfake +++ b/gpsfake @@ -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 -- cgit v1.2.1