summaryrefslogtreecommitdiff
path: root/util/ec3po/interpreter.py
diff options
context:
space:
mode:
authorRuben Rodriguez Buchillon <coconutruben@chromium.org>2020-12-04 12:17:10 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-21 06:38:29 +0000
commit51a975ec8302a9b441eb5f50e1ed993956379638 (patch)
tree1525aadb3d1208cffe4a6d7c4f0a60624d21c8c8 /util/ec3po/interpreter.py
parent6719aaa6b470b1732863fd6c003fa638016c4169 (diff)
downloadchrome-ec-51a975ec8302a9b441eb5f50e1ed993956379638.tar.gz
ec3po: open without a buffer
pty's do not support seek (and tell), so we need to open with buffer=0 for this to work in py3 as well. Additionally, this requires us to use wb+ rather than ab+ (as 'a' as no meaning on a pty). BUG=b:173654272 BRANCH=None // this shown both communication to the uart and from the uart TEST=sudo servod -b scarlet dut-control ec_board ec_board:scarlet Change-Id: I7d9bff269dfda9d360ea44165c495ceab9c7f21a Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2576139 Reviewed-by: Matthew Blecker <matthewb@chromium.org>
Diffstat (limited to 'util/ec3po/interpreter.py')
-rw-r--r--util/ec3po/interpreter.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/util/ec3po/interpreter.py b/util/ec3po/interpreter.py
index 66394fe45a..7fced55e61 100644
--- a/util/ec3po/interpreter.py
+++ b/util/ec3po/interpreter.py
@@ -101,7 +101,11 @@ class Interpreter(object):
interpreter_prefix = ('%s - ' % name) if name else ''
logger = logging.getLogger('%sEC3PO.Interpreter' % interpreter_prefix)
self.logger = LoggerAdapter(logger, {'pty': ec_uart_pty})
- self.ec_uart_pty = open(ec_uart_pty, 'ab+')
+ # TODO(https://crbug.com/1162189): revist the 2 TODOs below
+ # TODO(https://bugs.python.org/issue27805, python3.7+): revert to ab+
+ # TODO(https://bugs.python.org/issue20074): removing buffering=0 if/when
+ # that gets fixed, or keep two pty: one for reading and one for writing
+ self.ec_uart_pty = open(ec_uart_pty, 'r+b', buffering=0)
self.ec_uart_pty_name = ec_uart_pty
self.cmd_pipe = cmd_pipe
self.dbg_pipe = dbg_pipe
@@ -223,7 +227,10 @@ class Interpreter(object):
if not self.connected:
self.logger.debug('UART reconnect request.')
# Reopen the PTY.
- fileobj = open(self.ec_uart_pty_name, 'ab+')
+ # TODO(https://bugs.python.org/issue27805, python3.7+): revert to ab+
+ # TODO(https://bugs.python.org/issue20074): removing buffering=0 if/when
+ # that gets fixed, or keep two pty: one for reading and one for writing
+ fileobj = open(self.ec_uart_pty_name, 'r+b', buffering=0)
self.logger.debug('fileobj: %r', fileobj)
self.ec_uart_pty = fileobj
# Add the descriptor to the inputs.