1 // Copyright 2021 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 //============================================================================== 15 /* 16 BUILD 17 ninja -C out 18 host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 19 20 RUN 21 .out/host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 22 23 DECODE 24 python pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py 25 -s localhost:33000 26 -o trace.json 27 -t 28 out/host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 29 pw_trace_tokenized/pw_trace_protos/trace_rpc.proto 30 31 VIEW 32 In chrome navigate to chrome://tracing, and load the trace.json file. 33 */ 34 #include <thread> 35 36 #include "pw_log/log.h" 37 #include "pw_rpc/server.h" 38 #include "pw_rpc_system_server/rpc_server.h" 39 #include "pw_trace/example/sample_app.h" 40 #include "pw_trace/trace.h" 41 #include "pw_trace_tokenized/trace_rpc_service_nanopb.h" 42 43 namespace { 44 45 pw::trace::TraceService trace_service; 46 RpcThread()47void RpcThread() { 48 pw::rpc::system_server::Init(); 49 50 // Set up the server and start processing data. 51 pw::rpc::system_server::Server().RegisterService(trace_service); 52 pw::rpc::system_server::Start(); 53 } 54 55 } // namespace 56 main()57int main() { 58 std::thread rpc_thread(RpcThread); 59 60 // Enable tracing. 61 PW_TRACE_SET_ENABLED(true); 62 63 PW_LOG_INFO("Running basic trace example...\n"); 64 RunTraceSampleApp(); 65 return 0; 66 }