feat: Add RPC thread analysis support.

This commit is contained in:
Peter Johanson 2024-09-25 11:06:52 -06:00 committed by Pete Johanson
parent 17f0a4d307
commit 21e1b2acad
1 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/debug/thread_analyzer.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(zmk_studio, CONFIG_ZMK_STUDIO_LOG_LEVEL);
@ -215,6 +216,9 @@ static void rpc_main(void) {
for (;;) {
pb_istream_t stream = pb_istream_for_rx_ring_buf();
zmk_studio_Request req = zmk_studio_Request_init_zero;
#if IS_ENABLED(CONFIG_THREAD_ANALYZER)
thread_analyzer_print();
#endif // IS_ENABLED(CONFIG_THREAD_ANALYZER)
bool status = pb_decode(&stream, &zmk_studio_Request_msg, &req);
rpc_framing_state = FRAMING_STATE_IDLE;
@ -223,6 +227,9 @@ static void rpc_main(void) {
zmk_studio_Response resp = handle_request(&req);
int err = send_response(&resp);
#if IS_ENABLED(CONFIG_THREAD_ANALYZER)
thread_analyzer_print();
#endif // IS_ENABLED(CONFIG_THREAD_ANALYZER)
if (err < 0) {
LOG_ERR("Failed to send the RPC response %d", err);
}