summaryrefslogtreecommitdiff
path: root/gpsfake.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-12-06 09:49:01 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-12-06 09:49:01 +0000
commit83a21e47f081b219acb50715d471981ab558b0f0 (patch)
tree5ec979665103f1cb375a640e8ab26f982621751a /gpsfake.py
parentf5ec11f4e2fd45c70a61e0bab18a0c4495278b07 (diff)
downloadgpsd-83a21e47f081b219acb50715d471981ab558b0f0.tar.gz
Reintroduce line buffering in gps.py.
Make gpsfake.py do realistic delays so that neither the pty buffer nor gpsd's own internal buffer gerts spammed.
Diffstat (limited to 'gpsfake.py')
-rw-r--r--gpsfake.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/gpsfake.py b/gpsfake.py
index 1a3fc837..a138234a 100644
--- a/gpsfake.py
+++ b/gpsfake.py
@@ -206,12 +206,13 @@ class PacketError(exceptions.Exception):
class FakeGPS:
"A fake GPS is a pty with a test log ready to be cycled to it."
def __init__(self, logfp,
- speed=4800, databits=8, parity='N', stopbits=1,
+ speed=19200, databits=8, parity='N', stopbits=1,
verbose=False):
self.verbose = verbose
self.go_predicate = lambda: True
self.readers = 0
self.index = 0
+ self.speed = speed
baudrates = {
0: termios.B0,
50: termios.B50,
@@ -269,6 +270,9 @@ class FakeGPS:
"Feed a line from the contents of the GPS log to the daemon."
line = self.testload.sentences[self.index % len(self.testload.sentences)]
os.write(self.master_fd, line)
+ # Delay so we won't spam the buffers in the pty layer or gpsd itself.
+ # Assumptions: 1 character is 10 bits (generous; at 8N1 it will be 9).
+ time.sleep((10.0 * len(line)) / self.speed)
self.index += 1
class DaemonError(exceptions.Exception):