Merge lp:~doanac/lava-dispatcher/serial-delay into lp:lava-dispatcher

Proposed by Andy Doan
Status: Merged
Merged at revision: 501
Proposed branch: lp:~doanac/lava-dispatcher/serial-delay
Merge into: lp:lava-dispatcher
Diff against target: 55 lines (+16/-8)
2 files modified
lava_dispatcher/device/master.py (+0/-2)
lava_dispatcher/utils.py (+16/-6)
To merge this branch: bzr merge lp:~doanac/lava-dispatcher/serial-delay
Reviewer Review Type Date Requested Status
Dave Pigott Approve
Review via email: mp+140050@code.launchpad.net

Description of the change

this fixes the serial input issue with TC2 and may help other platforms as well.

tested on panda and tc2.

To post a comment you must log in.
Revision history for this message
Dave Pigott (dpigott) wrote :

+1 in general. I'm a little concerned that removing the longer initial senddelay might introduce a regression, but that's only a gut reaction.

review: Approve
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

happy to see this land if it works :)

we'll need to remember this code if we ever send large amounts of data over serial (but lets try not to do that please)

Revision history for this message
Antonio Terceiro (terceiro) wrote :

On Sat, Dec 15, 2012 at 12:16:23AM -0000, Andy Doan wrote:
> === modified file 'lava_dispatcher/utils.py'
> --- lava_dispatcher/utils.py 2012-11-26 19:30:28 +0000
> +++ lava_dispatcher/utils.py 2012-12-15 00:15:28 +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
> +

Maybe we want this to be configurable instead of hardcoded?

--
Antonio Terceiro
Software Engineer - Linaro
http://www.linaro.org

Revision history for this message
Dave Pigott (dpigott) wrote :

Agree. That way we could also experimenting to get it down to a minimum.

Sent from my Aldis Lamp

On 17 Dec 2012, at 14:34, Antonio Terceiro <email address hidden> wrote:

> On Sat, Dec 15, 2012 at 12:16:23AM -0000, Andy Doan wrote:
>> === modified file 'lava_dispatcher/utils.py'
>> --- lava_dispatcher/utils.py 2012-11-26 19:30:28 +0000
>> +++ lava_dispatcher/utils.py 2012-12-15 00:15:28 +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
>> +
>
> Maybe we want this to be configurable instead of hardcoded?
>
> --
> Antonio Terceiro
> Software Engineer - Linaro
> http://www.linaro.org
>
> https://code.launchpad.net/~doanac/lava-dispatcher/serial-delay/+merge/140050
> You are reviewing the proposed merge of lp:~doanac/lava-dispatcher/serial-delay into lp:lava-dispatcher.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Antonio Terceiro <email address hidden> writes:

> On Sat, Dec 15, 2012 at 12:16:23AM -0000, Andy Doan wrote:
>> === modified file 'lava_dispatcher/utils.py'
>> --- lava_dispatcher/utils.py 2012-11-26 19:30:28 +0000
>> +++ lava_dispatcher/utils.py 2012-12-15 00:15:28 +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
>> +
>
> Maybe we want this to be configurable instead of hardcoded?

I'll review that branch really quickly!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/device/master.py'
2--- lava_dispatcher/device/master.py 2012-12-13 21:23:55 +0000
3+++ lava_dispatcher/device/master.py 2012-12-15 00:15:28 +0000
4@@ -338,8 +338,6 @@
5 while retry_count < retry_limit:
6 proc = logging_spawn(cmd, timeout=1200)
7 proc.logfile_read = self.sio
8- #serial can be slow, races do funny things, so increase delay
9- proc.delaybeforesend = 1
10 logging.info('Attempting to connect to device')
11 match = proc.expect(patterns, timeout=10)
12 result = results[match]
13
14=== modified file 'lava_dispatcher/utils.py'
15--- lava_dispatcher/utils.py 2012-11-26 19:30:28 +0000
16+++ lava_dispatcher/utils.py 2012-12-15 00:15:28 +0000
17@@ -163,13 +163,23 @@
18
19 class logging_spawn(pexpect.spawn):
20
21+ def __init__(self, command, timeout=30, logfile=None):
22+ pexpect.spawn.__init__(
23+ self, command, timeout=timeout, logfile=logfile)
24+
25+ # serial can be slow, races do funny things, so increase delay
26+ self.delaybeforesend = 0.05
27+
28 def sendline(self, s=''):
29- logging.debug("sendline : %s" % s)
30+ logging.debug("sendline : %s", s)
31 return super(logging_spawn, self).sendline(s)
32
33- def send(self, *args, **kw):
34- logging.debug("send : %s" % args[0])
35- return super(logging_spawn, self).send(*args, **kw)
36+ def send(self, string):
37+ logging.debug("send : %s", string)
38+ sent = 0
39+ for char in string:
40+ sent += super(logging_spawn, self).send(char)
41+ return sent
42
43 def expect(self, *args, **kw):
44 # some expect should not be logged because it is so much noise.
45@@ -183,9 +193,9 @@
46 timeout = self.timeout
47
48 if len(args) == 1:
49- logging.debug("expect (%d): '%s'" % (timeout, args[0]))
50+ logging.debug("expect (%d): '%s'", timeout, args[0])
51 else:
52- logging.debug("expect (%d): '%s'" % (timeout, str(args)))
53+ logging.debug("expect (%d): '%s'", timeout, str(args))
54
55 return super(logging_spawn, self).expect(*args, **kw)
56

Subscribers

People subscribed via source and target branches