summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2019-04-26 17:00:27 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-30 14:12:45 -0700
commit0ef5ba062fb1aca3236b6a12cb58248cba16b729 (patch)
tree9392bc529e379964f3544e448d0ae4f636d7275b /util
parent3c49473cd607bc5debbbbd22118bad18d11b8611 (diff)
downloadchrome-ec-0ef5ba062fb1aca3236b6a12cb58248cba16b729.tar.gz
console: add support for disabling timestamps
People may want to disable timestamps. Add a command to do that. BUG=none BRANCH=none TEST=none Change-Id: I702c41a214367b6c58f3d9b932310e1bb7e08b95 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1586588 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/ec3po/console.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 8206df437a..913aee4498 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -177,6 +177,7 @@ class Console(object):
self.receiving_oobm_cmd = False
self.pending_oobm_cmd = ''
self.interrogation_mode = 'auto'
+ self.timestamp_enabled = True
self.look_buffer = ''
def __str__(self):
@@ -756,6 +757,12 @@ class Console(object):
# Ignoring the request if an integer was not provided.
self.PrintOOBMHelp()
+ elif cmd[0] == 'timestamp':
+ mode = cmd[1].lower()
+ self.timestamp_enabled = mode == 'on'
+ self.logger.info('%sabling uart timestamps.',
+ 'En' if self.timestamp_enabled else 'Dis')
+
elif cmd[0] == 'interrogate' and len(cmd) >= 2:
enhanced = False
mode = cmd[1]
@@ -956,21 +963,23 @@ def StartLoop(console, command_active, shutdown_pipe=None):
('u' if master_connected else '') +
('i' if command_active.value else ''), data.strip())
if master_connected:
-
- # A timestamp is required at the beginning of this line
- if tm_req is True:
- now = datetime.now()
- tm = now.strftime(HOST_STRFTIME)
- os.write(console.master_pty, tm)
- tm_req = False
-
- # Insert timestamps into the middle where appropriate
- # except if the last character is a newline
end = len(data) - 1
- nls_found = data.count('\n', 0, end)
- now = datetime.now()
- tm = now.strftime('\n' + HOST_STRFTIME)
- data_tm = data.replace('\n', tm, nls_found)
+ if console.timestamp_enabled:
+ # A timestamp is required at the beginning of this line
+ if tm_req is True:
+ now = datetime.now()
+ tm = now.strftime(HOST_STRFTIME)
+ os.write(console.master_pty, tm)
+ tm_req = False
+
+ # Insert timestamps into the middle where appropriate
+ # except if the last character is a newline
+ nls_found = data.count('\n', 0, end)
+ now = datetime.now()
+ tm = now.strftime('\n' + HOST_STRFTIME)
+ data_tm = data.replace('\n', tm, nls_found)
+ else:
+ data_tm = data
# timestamp required on next input
if data[end] == '\n':