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

Create CHIP-specific backends for pigweed assert and logs #36297

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ default_args = {

# Required for pw_unit_test
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "//src/backends/assert"
pw_log_BACKEND = "//src/backends/log"

# TODO: Make sure only unit tests link against this
pw_build_LINK_DEPS = [
Expand Down
4 changes: 2 additions & 2 deletions config/bouffalolab/common/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/bouffalolab/common/rpc/pw_sys_io:pw_sys_io"

Expand Down
4 changes: 2 additions & 2 deletions config/efr32/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/silabs/pw_sys_io:pw_sys_io_silabs"
Expand Down
4 changes: 2 additions & 2 deletions config/mbed/chip-gn/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/mbed/pw_sys_io:pw_sys_io_mbed"
pw_rpc_system_server_BACKEND =
Expand Down
4 changes: 2 additions & 2 deletions config/nxp/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"
pw_sys_io_BACKEND = "${chip_root}/examples/platform/nxp/pw_sys_io:pw_sys_io_nxp"

Expand Down
4 changes: 2 additions & 2 deletions config/qpg/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "${chip_root}/examples/platform/qpg/pw_sys_io:pw_sys_io_qpg"

pw_build_LINK_DEPS = [
Expand Down
4 changes: 2 additions & 2 deletions examples/all-clusters-app/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
4 changes: 2 additions & 2 deletions examples/android/CHIPTest/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ chip_monolithic_tests = false

pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"

pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_log_BACKEND = "${chip_root}/src/backends/log"

pw_unit_test_BACKEND = "$dir_pw_unit_test:light"

Expand Down
4 changes: 2 additions & 2 deletions examples/chef/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
14 changes: 0 additions & 14 deletions examples/common/pigweed/RpcService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ void Start(void (*RegisterServices)(pw::rpc::Server &), ::chip::rpc::Mutex * uar
PW_DASSERT(RegisterServices != nullptr);
uart_mutex = uart_mutex_;

// Send log messages to HDLC address 1. This prevents logs from interfering
// with pw_rpc communications.
pw::log_basic::SetOutput([](std::string_view log) {
if (uart_mutex)
{
uart_mutex->Lock();
}
pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), sysIoWriter);
if (uart_mutex)
{
uart_mutex->Unlock();
}
});

// Set up the server and start processing data.
RegisterServices(server);

Expand Down
18 changes: 2 additions & 16 deletions examples/common/pigweed/rpc_console/py/chip_rpc/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import argparse
import sys
from pathlib import Path
from typing import Any, Collection
from typing import Collection

import pw_system.console
from pw_hdlc import rpc
Expand All @@ -52,7 +52,6 @@
from button_service import button_service_pb2
from descriptor_service import descriptor_service_pb2
from device_service import device_service_pb2
from echo_service import echo_pb2
from fabric_admin_service import fabric_admin_service_pb2
from fabric_bridge_service import fabric_bridge_service_pb2
from lighting_service import lighting_service_pb2
Expand All @@ -72,13 +71,6 @@ def _parse_args():
type=int,
default=115200,
help='the baud rate to use')
parser.add_argument(
'-o',
'--output',
type=argparse.FileType('wb'),
default=sys.stdout.buffer,
help=('The file to which to write device output (HDLC channel 1); '
'provide - or omit for stdout.'))
parser.add_argument(
'-r',
'--raw_serial',
Expand All @@ -99,7 +91,7 @@ def _parse_args():

def show_console(device: str, baudrate: int,
token_databases: Collection[Path],
socket_addr: str, output: Any, raw_serial: bool) -> int:
socket_addr: str, raw_serial: bool) -> int:

# TODO: this shows a default console with little customization
# Ideally we should at least customize the default messages
Expand All @@ -114,30 +106,24 @@ def show_console(device: str, baudrate: int,
device=device,
baudrate=baudrate,
socket_addr=socket_addr,
output=output,
hdlc_encoding=not raw_serial,
token_databases=token_databases,
logfile="",
device_logfile="",
channel_id=rpc.DEFAULT_CHANNEL_ID,

# Defaults beyond the original console
proto_globs=[],
ticks_per_second=None,
host_logfile="",
json_logfile="",
rpc_logging=False,
# the pt-python based console seems to break on python 3.1 with
# "set_wakeup_fd only works in main thread of the main interpreter"
use_ipython=True,
compiled_protos=[
actions_service_pb2,
attributes_service_pb2,
boolean_state_service_pb2,
button_service_pb2,
descriptor_service_pb2,
device_service_pb2,
echo_pb2,
fabric_admin_service_pb2,
fabric_bridge_service_pb2,
lighting_service_pb2,
Expand Down
7 changes: 1 addition & 6 deletions examples/common/pigweed/system_rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ rpc::Server server(channels);

} // namespace

void Init()
{
// Send log messages to HDLC address 1. This prevents logs from interfering
// with pw_rpc communications.
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), writer); });
}
void Init() {}

rpc::Server & Server()
{
Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-admin/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-bridge-app/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/genio/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("${chip_root}/src/platform/mt793x/args.gni")

mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"

chip_enable_ble = true

Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/genio/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/MT793X/wifi_args.gni")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
4 changes: 2 additions & 2 deletions examples/light-switch-app/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ chip_stack_lock_tracking = "none"
matter_device_vid = "0xFFF1"
matter_device_pid = "0x8004"

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import("${chip_root}/src/platform/bouffalolab/BL602/args.gni")

bl_iot_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"

chip_detail_logging = false
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl702/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import("${chip_root}/src/platform/bouffalolab/BL702/args.gni")

bl_iot_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"

chip_detail_logging = false
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl702l/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import("${chip_root}/src/platform/bouffalolab/BL702L/args.gni")

bl_iot_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex"

chip_detail_logging = false
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/genio/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import("${chip_root}/src/platform/mt793x/args.gni")

mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"

chip_enable_ble = true

Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/genio/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/MT793X/wifi_args.gni")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
4 changes: 2 additions & 2 deletions examples/lighting-app/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ chip_stack_lock_tracking = "none"
matter_device_vid = "0xFFF1"
matter_device_pid = "0x8005"

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
4 changes: 2 additions & 2 deletions examples/lock-app/genio/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("${chip_root}/src/platform/mt793x/args.gni")

mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"

chip_enable_ble = true

Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/genio/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/MT793X/wifi_args.gni")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
4 changes: 2 additions & 2 deletions examples/lock-app/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ chip_stack_lock_tracking = "none"
matter_device_vid = "0xFFF1"
matter_device_pid = "0x8006"

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
4 changes: 2 additions & 2 deletions examples/ota-requestor-app/genio/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import("${chip_root}/src/platform/mt793x/args.gni")

mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"

chip_enable_ble = true

Expand Down
4 changes: 2 additions & 2 deletions examples/ota-requestor-app/genio/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/MT793X/wifi_args.gni")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_log_BACKEND = "${chip_root}/src/backends/log"
pw_assert_BACKEND = "${chip_root}/src/backends/assert"
5 changes: 0 additions & 5 deletions examples/platform/linux/system_rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ void set_socket_port(uint16_t new_socket_port)

void Init()
{
log_basic::SetOutput([](std::string_view log) {
std::fprintf(stderr, "%.*s\n", static_cast<int>(log.size()), log.data());
hdlc::WriteUIFrame(1, as_bytes(span(log)), socket_stream).IgnoreError(); // TODO(pwbug/387): Handle Status properly
});

PW_LOG_INFO("Starting pw_rpc server on port %d", socket_port);
PW_CHECK_OK(server_socket.Listen(socket_port));
auto accept_result = server_socket.Accept();
Expand Down
Loading
Loading