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
=== 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-15 00:15:28 +0000
@@ -338,8 +338,6 @@
338 while retry_count < retry_limit:338 while retry_count < retry_limit:
339 proc = logging_spawn(cmd, timeout=1200)339 proc = logging_spawn(cmd, timeout=1200)
340 proc.logfile_read = self.sio340 proc.logfile_read = self.sio
341 #serial can be slow, races do funny things, so increase delay
342 proc.delaybeforesend = 1
343 logging.info('Attempting to connect to device')341 logging.info('Attempting to connect to device')
344 match = proc.expect(patterns, timeout=10)342 match = proc.expect(patterns, timeout=10)
345 result = results[match]343 result = results[match]
346344
=== 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 @@
163163
164class logging_spawn(pexpect.spawn):164class logging_spawn(pexpect.spawn):
165165
166 def __init__(self, command, timeout=30, logfile=None):
167 pexpect.spawn.__init__(
168 self, command, timeout=timeout, logfile=logfile)
169
170 # serial can be slow, races do funny things, so increase delay
171 self.delaybeforesend = 0.05
172
166 def sendline(self, s=''):173 def sendline(self, s=''):
167 logging.debug("sendline : %s" % s)174 logging.debug("sendline : %s", s)
168 return super(logging_spawn, self).sendline(s)175 return super(logging_spawn, self).sendline(s)
169176
170 def send(self, *args, **kw):177 def send(self, string):
171 logging.debug("send : %s" % args[0])178 logging.debug("send : %s", string)
172 return super(logging_spawn, self).send(*args, **kw)179 sent = 0
180 for char in string:
181 sent += super(logging_spawn, self).send(char)
182 return sent
173183
174 def expect(self, *args, **kw):184 def expect(self, *args, **kw):
175 # some expect should not be logged because it is so much noise.185 # some expect should not be logged because it is so much noise.
@@ -183,9 +193,9 @@
183 timeout = self.timeout193 timeout = self.timeout
184194
185 if len(args) == 1:195 if len(args) == 1:
186 logging.debug("expect (%d): '%s'" % (timeout, args[0]))196 logging.debug("expect (%d): '%s'", timeout, args[0])
187 else:197 else:
188 logging.debug("expect (%d): '%s'" % (timeout, str(args)))198 logging.debug("expect (%d): '%s'", timeout, str(args))
189199
190 return super(logging_spawn, self).expect(*args, **kw)200 return super(logging_spawn, self).expect(*args, **kw)
191201

Subscribers

People subscribed via source and target branches