summaryrefslogtreecommitdiff
path: root/gpsfake.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-12-07 21:29:22 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-12-07 21:29:22 +0000
commita24eb42b38087aaffcf849f07c7dbbb11e04f656 (patch)
tree5631ef8c01808ab7f3f060bc5d20d2c7ebc34d56 /gpsfake.py
parent4ff462037f6b660ab44cfef40644ec6899e7ebc6 (diff)
downloadgpsd-a24eb42b38087aaffcf849f07c7dbbb11e04f656.tar.gz
Change gpsfake to flush data written from gpsd before each feed.
This may avoid hangs on OpenBSD; seems tcdrain() can hang until somebody actually reads the data on that system.
Diffstat (limited to 'gpsfake.py')
-rw-r--r--gpsfake.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/gpsfake.py b/gpsfake.py
index a138234a..2e12546f 100644
--- a/gpsfake.py
+++ b/gpsfake.py
@@ -266,6 +266,9 @@ class FakeGPS:
ispeed = ospeed = speed
termios.tcsetattr(ttyfp.fileno(), termios.TCSANOW,
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
+ def read(self):
+ "Discard control strings written by gpsd."
+ termios.tcflush(self.master_fd, termios.TCIFLUSH)
def feed(self):
"Feed a line from the contents of the GPS log to the daemon."
line = self.testload.sentences[self.index % len(self.testload.sentences)]
@@ -464,7 +467,7 @@ class TestSession:
if isinstance(chosen, FakeGPS):
# Delay a few seconds after a GPS source is exhauseted
# to remove it. This should give its subscribers time
- # to get gpsd's response before we call cleanup
+ # to get gpsd's response before we call cleanup()
if chosen.exhausted and (time.time() - chosen.exhausted > TestSession.CLOSE_DELAY):
self.remove(chosen)
self.progress("gpsfake: GPS %s removed\n" % chosen.slave)
@@ -473,6 +476,10 @@ class TestSession:
chosen.exhausted = time.time()
self.progress("gpsfake: GPS %s ran out of input\n" % chosen.slave)
else:
+ # We have to read anything that gpsd might have tried
+ # to send to the GPS here -- under OpenBSD the
+ # TIOCDRAIN will hang, otherwise.
+ chosen.read()
chosen.feed()
elif isinstance(chosen, gps.gps):
if chosen.enqueued: