add free cmd in shell

This commit is contained in:
mculover666
2021-09-26 20:39:57 +08:00
parent d285144a8f
commit 9e45c54da0

View File

@@ -89,10 +89,32 @@ __STATIC__ int cmd_ps(int argc, char *argv[])
return 0; return 0;
} }
__STATIC__ int cmd_free(int argc, char *argv[])
{
#if TOS_CFG_MMHEAP_EN > 0u
k_mmheap_info_t pool_info;
uint32_t total;
if (tos_mmheap_check(&pool_info) != K_ERR_NONE) {
tos_shell_printfln("mmheap check fail!");
return -1;
}
total = pool_info.used + pool_info.free;
tos_shell_printfln(" %10s %10s %10s", "total", "used", "free");
tos_shell_printfln("Pool: %10d %10d %10d", total, pool_info.used, pool_info.free);
return 0;
#else
tos_shell_printfln("TOS_CFG_MMHEAP_EN is disenable!");
return -1;
#endif /* TOS_CFG_MMHEAP_EN */
}
__STATIC__ const shell_cmd_t builtin_shell_cmds[] = { __STATIC__ const shell_cmd_t builtin_shell_cmds[] = {
{ "help", cmd_help, "show help" }, { "help", cmd_help, "show help" },
{ "ps", cmd_ps, "show tasks" }, { "ps", cmd_ps, "show task info" },
{ "free", cmd_free, "show mmheap info" },
{ K_NULL, K_NULL, K_NULL }, { K_NULL, K_NULL, K_NULL },
}; };