summaryrefslogtreecommitdiff
path: root/extra/usb_power
diff options
context:
space:
mode:
authorPuthikorn Voravootivat <puthik@chromium.org>2018-05-01 17:42:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-03 21:27:54 -0700
commit0a8afe10c2ba566f35a9360aeb3b302669126ad5 (patch)
tree0980708ef17d3e86827a5b5636e3c3a06308543c /extra/usb_power
parent9d4846a292fbb724617c3b63f6be79a7b8a747be (diff)
downloadchrome-ec-0a8afe10c2ba566f35a9360aeb3b302669126ad5.tar.gz
sweetberry: Make resetting USB interface more forgiving
Currently, sweetberry ocassionally throws Exception when resetting the USB interface. This CL mitigates that by - Use linearly back off algorithm with 10ms delay increment before next reset attempt to avoid flooding the sweetberry hardware with reset requests. - Increase retry amount from 10 to 100 BUG=chromium:834252 TEST=No "Exception: ('Power', 'Failed to reset')" seen Change-Id: Iaf039cb82760205d1747fd630387852b7cfd8f83 Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1038788
Diffstat (limited to 'extra/usb_power')
-rwxr-xr-xextra/usb_power/powerlog.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/extra/usb_power/powerlog.py b/extra/usb_power/powerlog.py
index 00a508691a..3f299be790 100755
--- a/extra/usb_power/powerlog.py
+++ b/extra/usb_power/powerlog.py
@@ -328,25 +328,25 @@ class Spower(object):
debuglog("Command RESET: %s" % "success" if ret == 0 else "failure")
def reset(self):
- """Try resetting the USB interface until success
+ """Try resetting the USB interface until success.
+
+ Use linear back off strategy when encounter the error with 10ms increment.
Raises:
Exception on failure.
"""
- count = 10
- while count > 0:
+ max_reset_retry = 100
+ for count in range(1, max_reset_retry + 1):
self.clear()
try:
self.send_reset()
- count = 0
+ return
except Exception as e:
self.clear()
self.clear()
- debuglog("TRY %d of 10: %s" % (count, e))
- finally:
- count -= 1
- if count == 0:
- raise Exception("Power", "Failed to reset")
+ debuglog("TRY %d of %d: %s" % (count, max_reset_retry, e))
+ time.sleep(count * 0.01)
+ raise Exception("Power", "Failed to reset")
def stop(self):
"""Stop any active data acquisition."""