Skip to content

Commit 1ccd9f0

Browse files
de-nordiccarlescufi
authored andcommitted
mgmt/mcumgr/lib: Reduce taskstat to Zephyr supported statistics
The commit adds CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS Kconfig option that disables code filling in task statistics, for mcumgr command `taskstat`, that are not collected or supported by Zephyr. Setting this option to y will skip following statistics in response: "runtime", "cswcnt", "last_checkin" and "next_checkin". Signed-off-by: Dominik Ermel <[email protected]>
1 parent c4a6137 commit 1ccd9f0

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

subsys/mgmt/mcumgr/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,21 @@ config OS_MGMT_TASKSTAT
239239
bool "Support for taskstat command"
240240
default y
241241

242+
if OS_MGMT_TASKSTAT
243+
244+
config OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
245+
bool "Send only data gathered by Zephyr"
246+
default y
247+
help
248+
Response will not include fields the Zephyr does not collect statistic for.
249+
Enable this if your client software is able to process "taskstat" response
250+
that would be missing "runtime", "cswcnt", "last_checkin" and "next_checkin"
251+
map entries for each listed task.
252+
Enabling this option will slightly reduce code size.
253+
254+
endif
255+
256+
242257
config OS_MGMT_ECHO
243258
bool "Support for echo command"
244259
default y

subsys/mgmt/mcumgr/lib/cmd/os_mgmt/include/os_mgmt/os_mgmt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ struct os_mgmt_task_info {
2929
uint8_t oti_state;
3030
uint16_t oti_stkusage;
3131
uint16_t oti_stksize;
32+
#ifndef CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
3233
uint32_t oti_cswcnt;
3334
uint32_t oti_runtime;
3435
uint32_t oti_last_checkin;
3536
uint32_t oti_next_checkin;
37+
#endif
3638

3739
char oti_name[OS_MGMT_TASK_NAME_LEN];
3840
};

subsys/mgmt/mcumgr/lib/cmd/os_mgmt/src/os_mgmt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ os_mgmt_taskstat_encode_one(struct CborEncoder *encoder, const struct os_mgmt_ta
7979
err |= cbor_encode_uint(&task_map, task_info->oti_stkusage);
8080
err |= cbor_encode_text_stringz(&task_map, "stksiz");
8181
err |= cbor_encode_uint(&task_map, task_info->oti_stksize);
82+
#ifndef CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
8283
err |= cbor_encode_text_stringz(&task_map, "cswcnt");
8384
err |= cbor_encode_uint(&task_map, task_info->oti_cswcnt);
8485
err |= cbor_encode_text_stringz(&task_map, "runtime");
@@ -87,6 +88,7 @@ os_mgmt_taskstat_encode_one(struct CborEncoder *encoder, const struct os_mgmt_ta
8788
err |= cbor_encode_uint(&task_map, task_info->oti_last_checkin);
8889
err |= cbor_encode_text_stringz(&task_map, "next_checkin");
8990
err |= cbor_encode_uint(&task_map, task_info->oti_next_checkin);
91+
#endif
9092
err |= cbor_encoder_close_container(encoder, &task_map);
9193

9294
if (err != 0) {

0 commit comments

Comments
 (0)