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 17 NOTE 18 To use this example you need to enable nanopb, one option is to set this in 19 either your out/args.gn or the root .gn: 20 default_args = { 21 dir_pw_third_party_nanopb = "<path to nanopb repo>" 22 } 23 24 BUILD 25 ninja -C out 26 pw_strict_host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 27 28 RUN 29 ./out/pw_strict_host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 30 31 DECODE 32 python pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py 33 -s localhost:33000 34 -o trace.json 35 -t 36 out/pw_strict_host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_rpc 37 pw_trace_tokenized/pw_trace_protos/trace_rpc.proto 38 39 VIEW 40 In chrome navigate to chrome://tracing, and load the trace.json file. 41 */ 42 #include <thread> 43 44 #include "pw_assert/check.h" 45 #include "pw_log/log.h" 46 #include "pw_rpc/server.h" 47 #include "pw_rpc_system_server/rpc_server.h" 48 #include "pw_trace/example/sample_app.h" 49 #include "pw_trace/trace.h" 50 #include "pw_trace_tokenized/trace_rpc_service_nanopb.h" 51 52 namespace { 53 54 pw::trace::TraceService trace_service; 55 RpcThread()56void RpcThread() { 57 pw::rpc::system_server::Init(); 58 59 // Set up the server and start processing data. 60 pw::rpc::system_server::Server().RegisterService(trace_service); 61 PW_CHECK_OK(pw::rpc::system_server::Start()); 62 } 63 64 } // namespace 65 main()66int main() { 67 std::thread rpc_thread(RpcThread); 68 69 // Enable tracing. 70 PW_TRACE_SET_ENABLED(true); 71 72 PW_LOG_INFO("Running basic trace example...\n"); 73 RunTraceSampleApp(); 74 return 0; 75 } 76