From 2789bc1f3435c3187675e2499f8ab9906496e7e2 Mon Sep 17 00:00:00 2001 From: "Yuanyao (YY) Zhong" Date: Tue, 30 Nov 2021 18:38:39 -0500 Subject: [PATCH 1/2] Add tracing service to example/platform/esp rpc --- .../esp32/main/CMakeLists.txt | 3 ++- examples/platform/esp32/Rpc.cpp | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 38b3240b3a0d14..ca82aff0adb03e 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -228,6 +228,7 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-DPW_RPC_BUTTON_SERVICE=1" "-DPW_RPC_DEVICE_SERVICE=1" "-DPW_RPC_LIGHTING_SERVICE=1" - "-DPW_RPC_LOCKING_SERVICE=1") + "-DPW_RPC_LOCKING_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1") endif (CONFIG_ENABLE_PW_RPC) diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index 3cfe0070e815b6..a385d7d9287ad8 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -52,6 +52,23 @@ #include "pigweed/rpc_services/Locking.h" #endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" +#include "pw_trace/trace.h" + +// Define trace time for pw_trace +PW_TRACE_TIME_TYPE pw_trace_GetTraceTime() +{ + return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count(); +} +// Microsecond time source +size_t pw_trace_GetTraceTimeTicksPerSecond() +{ + return 1000000; +} + +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + namespace chip { namespace rpc { @@ -122,6 +139,10 @@ Lighting lighting_service; Locking locking; #endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +pw::trace::TraceService trace_service; +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + void RegisterServices(pw::rpc::Server & server) { #if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE @@ -143,6 +164,10 @@ void RegisterServices(pw::rpc::Server & server) #if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE server.RegisterService(locking); #endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + server.RegisterService(trace_service); +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE } } // namespace From 5c9a6c62dbe252d258b40412298627e863738d39 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 30 Nov 2021 23:42:38 +0000 Subject: [PATCH 2/2] Restyled by clang-format --- examples/platform/esp32/Rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index a385d7d9287ad8..9286191dc4eeca 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -53,8 +53,8 @@ #endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE #if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE -#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" #include "pw_trace/trace.h" +#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" // Define trace time for pw_trace PW_TRACE_TIME_TYPE pw_trace_GetTraceTime()