Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pigweed Console default timeout #11402

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions examples/common/pigweed/rpc_console/py/chip_rpc/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
import serial # type: ignore
import re
import pw_cli.log
from pw_console.console_app import embed
from pw_console import PwConsoleEmbed
from pw_console.__main__ import create_temp_log_file
from pw_hdlc.rpc import HdlcRpcClient, default_channels
from pw_rpc import callback_client
from pw_rpc.console_tools.console import ClientInfo, flattened_rpc_completions


# Protos
from attributes_service import attributes_service_pb2
Expand Down Expand Up @@ -111,6 +114,10 @@ def _start_ipython_terminal(client: HdlcRpcClient) -> None:
LOG=_DEVICE_LOG,
)

client_info = ClientInfo('channel_client',
client.client.channel(1).rpcs, client.client)
completions = flattened_rpc_completions([client_info])

welcome_message = cleandoc("""
Welcome to the CHIP RPC Console!

Expand All @@ -122,12 +129,25 @@ def _start_ipython_terminal(client: HdlcRpcClient) -> None:
LOG.warning('Message appears console log window.')
""")

embed(global_vars=local_variables,
local_vars=None,
loggers=[_DEVICE_LOG],
repl_startup_message=welcome_message,
help_text=__doc__,
app_title="CHIP Console")
interactive_console = PwConsoleEmbed(
global_vars=local_variables,
local_vars=None,
loggers={
'Device Logs': [_DEVICE_LOG],
'Host Logs': [logging.getLogger()],
},
repl_startup_message=welcome_message,
help_text=__doc__,
app_title="CHIP Console",
)
interactive_console.hide_windows('Host Logs')
interactive_console.add_sentence_completer(completions)

# Setup Python logger propagation
interactive_console.setup_python_logging()
# Don't send device logs to the root logger.
_DEVICE_LOG.propagate = False
interactive_console.embed()


class SocketClientImpl:
Expand Down Expand Up @@ -200,9 +220,16 @@ def read(): return serial_device.read(8192)
_LOG.exception('Failed to initialize socket at %s', socket_addr)
return 1

callback_client_impl = callback_client.Impl(
default_unary_timeout_s=5.0,
default_stream_timeout_s=None,
)

_start_ipython_terminal(
HdlcRpcClient(read, PROTOS, default_channels(write),
lambda data: write_to_output(data, output)))
lambda data: write_to_output(data, output),
client_impl=callback_client_impl)
)
return 0


Expand Down