summaryrefslogtreecommitdiff
path: root/gpsfake.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-06-24 16:01:10 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-06-24 16:01:10 +0000
commitef646bd459e97e18acaf134628f7f4fba2ffa131 (patch)
treecba9cb0977b57b7d3aaeea838159713dc96af24f /gpsfake.py
parent3215e5e2af0527742adbf492e0b78fc4ae618582 (diff)
downloadgpsd-ef646bd459e97e18acaf134628f7f4fba2ffa131.tar.gz
Predicate unification.
Diffstat (limited to 'gpsfake.py')
-rw-r--r--gpsfake.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/gpsfake.py b/gpsfake.py
index 793a5f63..3e7b0993 100644
--- a/gpsfake.py
+++ b/gpsfake.py
@@ -75,6 +75,7 @@ class TestLoad:
class FakeGPS:
"A fake GPS is a pty with a test log ready to be cycled to it."
def __init__(self, logfp, rate=4800):
+ self.go_predicate = lambda i, s: True
self.stopme = False
self.thread = None
baudrates = {
@@ -124,14 +125,15 @@ class FakeGPS:
session.query("w+r+")
session.set_thread_hook(lambda x: self.responses.append(x))
return True
- def __feed(self, go_predicate):
+ def __feed(self):
"Feed the contents of the GPS log to the daemon."
i = 0;
- while not self.stopme and go_predicate(i, self):
+ while not self.stopme and self.go_predicate(i, self):
os.write(self.master_fd, self.testload.sentences[i % len(self.testload.sentences)])
i += 1
- def start(self, go_predicate=lambda i,s: True, thread=False):
- self.thread = threading.Thread(self.__feed(go_predicate))
+ def start(self, thread=False):
+ self.thread = threading.Thread(self.__feed())
+ self.stopme = False
if thread:
self.thread.start() # Run asynchronously
else: