2023-12-16 23:08:43 +08:00
|
|
|
|
#include "shell.h"
|
|
|
|
|
|
#include "cons_cli.h"
|
|
|
|
|
|
#include "u_sig.h"
|
2025-03-23 17:35:56 +08:00
|
|
|
|
#include "pm_cli.h"
|
2023-12-16 23:08:43 +08:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
#include <errno.h>
|
2023-12-23 16:17:15 +08:00
|
|
|
|
#ifdef CONFIG_USING_SIG
|
2025-03-02 23:31:22 +08:00
|
|
|
|
static int sig_cn;
|
2023-12-16 23:08:43 +08:00
|
|
|
|
static int shell_sig_call_back(pid_t pid, umword_t sig_val)
|
|
|
|
|
|
{
|
2025-03-02 23:31:22 +08:00
|
|
|
|
/*TODO:这个消息是init发送的,这里不能给init发送消息,否导致卡死除非init增加多进程支持*/
|
|
|
|
|
|
cons_write_str("test sig.\n");
|
|
|
|
|
|
sig_cn++;
|
2023-12-16 23:08:43 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
int shell_test_sig(int argc, char *argv[])
|
|
|
|
|
|
{
|
2025-03-02 23:31:22 +08:00
|
|
|
|
int ret;
|
|
|
|
|
|
|
2023-12-16 23:08:43 +08:00
|
|
|
|
if (argc < 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
pm_sig_func_set(shell_sig_call_back);
|
|
|
|
|
|
pid_t pid = atoi(argv[1]);
|
|
|
|
|
|
|
2025-03-02 23:31:22 +08:00
|
|
|
|
ret = pm_sig_watch(pid, 0 /*TODO:现在只有kill */);
|
|
|
|
|
|
|
|
|
|
|
|
printf("sig_cn:%d\n", sig_cn);
|
|
|
|
|
|
return ret;
|
2023-12-16 23:08:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), test_sig, shell_test_sig, shell_test_sig command);
|
2025-03-10 22:45:24 +08:00
|
|
|
|
|
|
|
|
|
|
int shell_float_test(int argc, char *argv[])
|
|
|
|
|
|
{
|
|
|
|
|
|
float a = 1.1, b = 1.2;
|
2025-03-23 17:35:56 +08:00
|
|
|
|
|
2025-03-10 22:45:24 +08:00
|
|
|
|
printf("%f\n", a + b);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), ftest, shell_float_test, ftest command);
|
2025-03-17 00:35:42 +08:00
|
|
|
|
int shell_div0(int argc, char *argv[])
|
|
|
|
|
|
{
|
2025-03-23 17:35:56 +08:00
|
|
|
|
int a = 1, b = 0;
|
|
|
|
|
|
|
2025-03-17 00:35:42 +08:00
|
|
|
|
*((char *)(0)) = 0;
|
2025-03-23 17:35:56 +08:00
|
|
|
|
printf("%d\n", a / b);
|
2025-03-17 00:35:42 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), div0, shell_div0, div0 command);
|
2025-03-23 17:35:56 +08:00
|
|
|
|
|
|
|
|
|
|
int shell_fapp(int argc, char *argv[])
|
|
|
|
|
|
{
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf("example: fapp 2048\n");
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
ret = pm_run_app(NULL, 0, 0x1 /*FIXME:*/, -1,
|
|
|
|
|
|
NULL, atol(argv[1]), NULL, 0); //!< 创建一个dummy task
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), fapp, shell_fapp, fapp command);
|
2023-12-23 16:17:15 +08:00
|
|
|
|
#endif
|