summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2016-01-05 10:07:33 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-01-05 21:14:42 -0800
commit5f18982f6784f1f323ae93ed88ea7b82bdb14b2b (patch)
tree6738a529661528910eb8bb8fe51b5f0d7cad2e89
parent077e545662963fc9d656bf13ed4d811e9d0590ed (diff)
downloadchrome-ec-5f18982f6784f1f323ae93ed88ea7b82bdb14b2b.tar.gz
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>
-rwxr-xr-xutil/ec3po/console.py38
-rw-r--r--util/ec3po/interpreter.py2
2 files changed, 34 insertions, 6 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 39278e343d..86a4a9be8c 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -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.
diff --git a/util/ec3po/interpreter.py b/util/ec3po/interpreter.py
index b71607f254..2d40729aaf 100644
--- a/util/ec3po/interpreter.py
+++ b/util/ec3po/interpreter.py
@@ -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):