Skip to content

Commit

Permalink
Add instructions to get trace from linux lighting app. (#17150)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyzhong-g authored Apr 7, 2022
1 parent 8659ded commit 16606a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/lighting-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini**
- [Commandline Arguments](#command-line-args)
- [Running the Complete Example on Raspberry Pi 4](#running-complete-example)
- [Running RPC console](#running-rpc-console)
- [Device Tracing](#device-tracing)

<hr>

Expand Down Expand Up @@ -136,3 +137,15 @@ To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini**
`rpcs.chip.rpc.Lighting.Get()`

`rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5))`

## Device Tracing

Device tracing is available to analyze the device performance. To turn on
tracing, build with RPC enabled. See [Building with RPC enabled](#building).

Obtain tracing json file.

```
$ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -s localhost:33000 \
-o {OUTPUT_FILE} -t {ELF_FILE} {PIGWEED_REPO}/pw_trace_tokenized/pw_trace_protos/trace_rpc.proto
```
2 changes: 2 additions & 0 deletions examples/platform/linux/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE

#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
#define PW_TRACE_BUFFER_SIZE_BYTES 1024
#include "pw_trace/trace.h"
#include "pw_trace_tokenized/trace_rpc_service_nanopb.h"

Expand Down Expand Up @@ -102,6 +103,7 @@ void RegisterServices(pw::rpc::Server & server)

#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
server.RegisterService(trace_service);
PW_TRACE_SET_ENABLED(true);
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
}

Expand Down

0 comments on commit 16606a4

Please sign in to comment.