chrome_ec: Add delays in keypress commands.
Some tests such as firmware_ECKeyboard simulate keypresses using servo
and the EC console. These use the ec_uart_multicmd to press and release
a key. However, autotest will try to do this as fast as possible. This
can cause issues with dropped characters on the EC console.
This commit changes the chrome_ec servo driver for autotest to add some
delays in between pressing keys. This relieves the pressure on the EC
console and in turn creates more reliable test execution.
BUG=chrome-os-partner:56274
BRANCH=None
TEST=Run firmware_ECKeyboard on cyan; Verify test fails. Apply this
patch and re-emerge autotest for cyan. Verify that test succeeds.
Change-Id: I8de421fdbdc9e16154a112e9be921a7236c840f2
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/398445
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: danny chan <dchan@chromium.org>
diff --git a/server/cros/servo/chrome_ec.py b/server/cros/servo/chrome_ec.py
index 690716c..97b2b01 100644
--- a/server/cros/servo/chrome_ec.py
+++ b/server/cros/servo/chrome_ec.py
@@ -31,6 +31,9 @@
HOSTEVENT_BATTERY_SHUTDOWN = 0x00010000
HOSTEVENT_INVALID = 0x80000000
+# Time to wait after sending keypress commands.
+KEYPRESS_RECOVERY_TIME = 0.5
+
class ChromeEC(object):
"""Manages control of a Chrome EC.
@@ -149,6 +152,9 @@
'kbpress %d %d 0' %
(ec.KEYMATRIX[keyname][1], ec.KEYMATRIX[keyname][0]),
])
+ # Don't spam the EC console as fast as we can; leave some recovery time
+ # in between commands.
+ time.sleep(KEYPRESS_RECOVERY_TIME)
def send_key_string_raw(self, string):