diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 501: introduce global delay in our serial console send routine

Message ID 20121215181413.3590.14211.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Dec. 15, 2012, 6:14 p.m. UTC
------------------------------------------------------------
revno: 501
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Fri 2012-12-14 10:37:42 -0600
message:
  introduce global delay in our serial console send routine
  
  We've seen issues where sending things like 16 byte or bigger strings
  can often get messed up in serial console implementations. This has
  been seen with our PS1 prompt on panda and seems to be fairly consistent
  on TC2 in a couple of places.
  
  Introducing a small .05 second delay seems to make things work well
  on TC2 and is small enough to not really annoy anyone. So this seems
  worth fixing in general.
  
  I also fixed a few pylint warnings in this class while I was looking
  at it.
modified:
  lava_dispatcher/device/master.py
  lava_dispatcher/utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/device/master.py'
--- lava_dispatcher/device/master.py	2012-12-13 21:23:55 +0000
+++ lava_dispatcher/device/master.py	2012-12-14 16:37:42 +0000
@@ -338,8 +338,6 @@ 
         while retry_count < retry_limit:
             proc = logging_spawn(cmd, timeout=1200)
             proc.logfile_read = self.sio
-            #serial can be slow, races do funny things, so increase delay
-            proc.delaybeforesend = 1
             logging.info('Attempting to connect to device')
             match = proc.expect(patterns, timeout=10)
             result = results[match]

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2012-11-26 19:30:28 +0000
+++ lava_dispatcher/utils.py	2012-12-14 16:37:42 +0000
@@ -163,13 +163,23 @@ 
 
 class logging_spawn(pexpect.spawn):
 
+    def __init__(self, command, timeout=30, logfile=None):
+        pexpect.spawn.__init__(
+            self, command, timeout=timeout, logfile=logfile)
+
+        # serial can be slow, races do funny things, so increase delay
+        self.delaybeforesend = 0.05
+
     def sendline(self, s=''):
-        logging.debug("sendline : %s" % s)
+        logging.debug("sendline : %s", s)
         return super(logging_spawn, self).sendline(s)
 
-    def send(self, *args, **kw):
-        logging.debug("send : %s" % args[0])
-        return super(logging_spawn, self).send(*args, **kw)
+    def send(self, string):
+        logging.debug("send : %s", string)
+        sent = 0
+        for char in string:
+            sent += super(logging_spawn, self).send(char)
+        return sent
 
     def expect(self, *args, **kw):
         # some expect should not be logged because it is so much noise.
@@ -183,9 +193,9 @@ 
             timeout = self.timeout
 
         if len(args) == 1:
-            logging.debug("expect (%d): '%s'" % (timeout, args[0]))
+            logging.debug("expect (%d): '%s'", timeout, args[0])
         else:
-            logging.debug("expect (%d): '%s'" % (timeout, str(args)))
+            logging.debug("expect (%d): '%s'", timeout, str(args))
 
         return super(logging_spawn, self).expect(*args, **kw)