util: ec3po: Change interrogation timeouts.

In testing, it was found that certain ECs couldn't respond to the EC_SYN
in less than 0.1s.  Therefore, this commit changes the interrogation
timeouts.  For non-enhanced EC images, the timeout has been increased to
0.3 seconds.  This is small enough that there's not too much of a delay,
but long enough that enhanced EC images can respond in time.  With an
enhanced EC image on veyron_jerry, EC_ACKs were arriving after ~0.2s.

BUG=None
BRANCH=None
TEST=Flash enhanced EC image on veyron_jerry, start console/interpreter
pair and verify that the console is functional.
TEST=util/ec3po/run_tests.sh

Change-Id: I4931aaee908653ae302a8e57941444e5f0b6ce2b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/320594
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Aseda Aboagye
2016-01-05 10:07:33 -08:00
committed by chrome-bot
parent 077e545662
commit 5f18982f67
2 changed files with 34 additions and 6 deletions

View File

@@ -29,6 +29,20 @@ PROMPT = '> '
CONSOLE_INPUT_LINE_SIZE = 80 # Taken from the CONFIG_* with the same name.
CONSOLE_MAX_READ = 100 # Max bytes to read at a time from the user.
# The timeouts are really only useful for enhanced EC images, but otherwise just
# serve as a delay for non-enhanced EC images. Therefore, we can keep this
# value small enough so that there's not too much of a delay, but long enough
# that enhanced EC images can respond in time. Once we've detected an enhanced
# EC image, we can increase the timeout for stability just in case it takes a
# bit longer to receive an ACK for some reason.
NON_ENHANCED_EC_INTERROGATION_TIMEOUT = 0.3 # Maximum number of seconds to wait
# for a response to an
# interrogation of a non-enhanced
# EC image.
ENHANCED_EC_INTERROGATION_TIMEOUT = 1.0 # Maximum number of seconds to wait for
# a response to an interrogation of an
# enhanced EC image.
class EscState(object):
"""Class which contains an enumeration for states of ESC sequences."""
@@ -88,6 +102,8 @@ class Console(object):
communicating with is enhanced or not. Enhanced EC images will support
packed commands and host commands over the UART. This defaults to False
until we perform some handshaking.
interrogation_timeout: A float representing the current maximum seconds to
wait for a response to an interrogation.
"""
def __init__(self, master_pty, user_pty, cmd_pipe, dbg_pipe):
@@ -118,6 +134,7 @@ class Console(object):
self.history_pos = 0
self.prompt = PROMPT
self.enhanced_ec = False
self.interrogation_timeout = NON_ENHANCED_EC_INTERROGATION_TIMEOUT
def __str__(self):
"""Show internal state of Console object as a string."""
@@ -385,22 +402,35 @@ class Console(object):
assume that the current EC image that we are talking to is not enhanced.
Returns:
A boolean indicating whether the EC responded to the interrogation
correctly.
is_enhanced: A boolean indicating whether the EC responded to the
interrogation correctly.
"""
# Send interrogation byte and wait for the response.
self.logger.debug('Performing interrogation.')
self.cmd_pipe.send(interpreter.EC_SYN)
response = ''
if self.dbg_pipe.poll(interpreter.EC_INTERROGATION_TIMEOUT):
if self.dbg_pipe.poll(self.interrogation_timeout):
response = self.dbg_pipe.recv()
self.logger.debug('response: \'%s\'', binascii.hexlify(response))
else:
self.logger.debug('Timed out waiting for EC_ACK')
# Verify the acknowledgment.
return response == interpreter.EC_ACK
is_enhanced = response == interpreter.EC_ACK
if is_enhanced:
# Increase the interrogation timeout for stability purposes.
self.interrogation_timeout = ENHANCED_EC_INTERROGATION_TIMEOUT
self.logger.debug('Increasing interrogation timeout to %rs.',
self.interrogation_timeout)
else:
# Reduce the timeout in order to reduce the perceivable delay.
self.interrogation_timeout = NON_ENHANCED_EC_INTERROGATION_TIMEOUT
self.logger.debug('Reducing interrogation timeout to %rs.',
self.interrogation_timeout)
return is_enhanced
def HandleChar(self, byte):
"""HandleChar does a certain action when it receives a character.

View File

@@ -27,8 +27,6 @@ COMMAND_RETRIES = 3 # Number of attempts to retry a command.
EC_MAX_READ = 1024 # Max bytes to read at a time from the EC.
EC_SYN = '\xec' # Byte indicating EC interrogation.
EC_ACK = '\xc0' # Byte representing correct EC response to interrogation.
EC_INTERROGATION_TIMEOUT = 0.1 # Maximum number of seconds to wait for a
# response to an interrogation.
class Interpreter(object):