mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 10:00:51 +00:00
util: ec3po: Add OOBM queue and dynamic loglevels.
This commit adds an Out Of Band Managament queue which will allow the console to receive commands outside of the PTY which it can take action on. The first use of this is to dynamically change the logging level. Prior to this change, changing the log level using dut-control would not affect the log level of the console or interpreter. BUG=None BRANCH=None TEST=Launch modified servod; issue dut-control loglevel:debug, verify that debug messages from both servod and ec3po are emitted. Then issue dut-control loglevel:info and verify that no debug messages from either are emitted. Change-Id: I692824742b018da9540a81305985f6f355f716e6 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/325134 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
f6f06c95d6
commit
086e501be3
@@ -86,6 +86,8 @@ class Console(object):
|
||||
dbg_pipe: A multiprocessing.Connection object which represents the console's
|
||||
read-only side of the debug pipe. This must be a unidirectional pipe
|
||||
attached to the intepreter. EC debug messages use this pipe.
|
||||
oobm_queue: A multiprocessing.Queue which is used for out of band management
|
||||
for the interactive console.
|
||||
input_buffer: A string representing the current input command.
|
||||
input_buffer_pos: An integer representing the current position in the buffer
|
||||
to insert a char.
|
||||
@@ -127,6 +129,7 @@ class Console(object):
|
||||
self.user_pty = user_pty
|
||||
self.cmd_pipe = cmd_pipe
|
||||
self.dbg_pipe = dbg_pipe
|
||||
self.oobm_queue = multiprocessing.Queue()
|
||||
self.input_buffer = ''
|
||||
self.input_buffer_pos = 0
|
||||
self.partial_cmd = ''
|
||||
@@ -145,6 +148,7 @@ class Console(object):
|
||||
string.append('user_pty: %s' % self.user_pty)
|
||||
string.append('cmd_pipe: %s' % self.cmd_pipe)
|
||||
string.append('dbg_pipe: %s' % self.dbg_pipe)
|
||||
string.append('oobm_queue: %s' % self.oobm_queue)
|
||||
string.append('input_buffer: %s' % self.input_buffer)
|
||||
string.append('input_buffer_pos: %d' % self.input_buffer_pos)
|
||||
string.append('esc_state: %d' % self.esc_state)
|
||||
@@ -695,6 +699,19 @@ def StartLoop(console):
|
||||
console.logger.debug('|DBG|->\'%s\'', data)
|
||||
os.write(console.master_pty, data)
|
||||
|
||||
while not console.oobm_queue.empty():
|
||||
console.logger.debug('OOBM queue ready for reading.')
|
||||
cmd = console.oobm_queue.get()
|
||||
console.logger.debug('cmd: %s', cmd)
|
||||
if cmd.startswith('loglevel'):
|
||||
console.logger.debug('Log level change request.')
|
||||
new_log_level = int(cmd.split(' ')[1])
|
||||
console.logger.logger.setLevel(new_log_level)
|
||||
console.logger.info('Log level changed to %d.', new_log_level)
|
||||
|
||||
# Forward the request to the interpreter as well.
|
||||
console.cmd_pipe.send(cmd)
|
||||
|
||||
finally:
|
||||
# Close pipes.
|
||||
console.dbg_pipe.close()
|
||||
|
||||
@@ -240,6 +240,14 @@ class Interpreter(object):
|
||||
if len(command) == 0:
|
||||
return
|
||||
|
||||
# Handle log level change requests.
|
||||
if command.startswith('loglevel'):
|
||||
self.logger.debug('Log level change request.')
|
||||
new_log_level = int(command.split(' ')[1])
|
||||
self.logger.logger.setLevel(new_log_level)
|
||||
self.logger.info('Log level changed to %d.', new_log_level)
|
||||
return
|
||||
|
||||
# Check for interrogation command.
|
||||
if command == EC_SYN:
|
||||
# User is requesting interrogation. Send SYN as is.
|
||||
|
||||
Reference in New Issue
Block a user