mirror of
https://gitee.com/Armink/EasyFlash.git
synced 2024-11-29 18:57:41 +08:00
1、【完善】ENV 中 RT-Thread 平台相关 Demo 中的 Finsh 命令。
Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
parent
15e8c63bbe
commit
12e0b5fce5
41
demo/env/stm32f10x/rtt/app/src/user_finsh_cmd.c
vendored
41
demo/env/stm32f10x/rtt/app/src/user_finsh_cmd.c
vendored
@ -20,44 +20,3 @@ void get_cpuusage(void) {
|
||||
rt_kprintf("The CPU usage is %d.%d% now.\n", cpu_usage_major, cpu_usage_minor);
|
||||
}
|
||||
MSH_CMD_EXPORT(get_cpuusage, Get control board cpu usage);
|
||||
|
||||
void setenv(uint8_t argc, char **argv) {
|
||||
uint8_t i;
|
||||
char c_value = NULL;
|
||||
char *value = &c_value;
|
||||
if (argc > 3) {
|
||||
/* environment variable value string together */
|
||||
for (i = 0; i < argc - 2; i++) {
|
||||
argv[2 + i][rt_strlen(argv[2 + i])] = ' ';
|
||||
}
|
||||
}
|
||||
if (argc == 1) {
|
||||
ef_set_env(value, value);
|
||||
} else if (argc == 2) {
|
||||
ef_set_env(argv[1], value);
|
||||
} else {
|
||||
ef_set_env(argv[1], argv[2]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(setenv, Set an envrionment variable.);
|
||||
|
||||
void printenv(uint8_t argc, char **argv) {
|
||||
ef_print_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(printenv, Print all envrionment variables.);
|
||||
|
||||
void saveenv(uint8_t argc, char **argv) {
|
||||
ef_save_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(saveenv, Save all envrionment variables to flash.);
|
||||
|
||||
void getvalue(uint8_t argc, char **argv) {
|
||||
char *value = NULL;
|
||||
value = ef_get_env(argv[1]);
|
||||
if (value) {
|
||||
rt_kprintf("The %s value is %s.\n", argv[1], value);
|
||||
} else {
|
||||
rt_kprintf("Can't find %s.\n", argv[1]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(getvalue, Get an envrionment variable by name.);
|
||||
|
@ -233,3 +233,54 @@ void ef_print(const char *format, ...) {
|
||||
rt_kprintf("%s", log_buf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
#include <finsh.h>
|
||||
#if defined(EF_USING_ENV)
|
||||
void setenv(uint8_t argc, char **argv) {
|
||||
uint8_t i;
|
||||
char c_value = NULL;
|
||||
char *value = &c_value;
|
||||
if (argc > 3) {
|
||||
/* environment variable value string together */
|
||||
for (i = 0; i < argc - 2; i++) {
|
||||
argv[2 + i][rt_strlen(argv[2 + i])] = ' ';
|
||||
}
|
||||
}
|
||||
if (argc == 1) {
|
||||
ef_set_env(value, value);
|
||||
} else if (argc == 2) {
|
||||
ef_set_env(argv[1], value);
|
||||
} else {
|
||||
ef_set_env(argv[1], argv[2]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(setenv, Set an envrionment variable.);
|
||||
|
||||
void printenv(uint8_t argc, char **argv) {
|
||||
ef_print_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(printenv, Print all envrionment variables.);
|
||||
|
||||
void saveenv(uint8_t argc, char **argv) {
|
||||
ef_save_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(saveenv, Save all envrionment variables to flash.);
|
||||
|
||||
void getvalue(uint8_t argc, char **argv) {
|
||||
char *value = NULL;
|
||||
value = ef_get_env(argv[1]);
|
||||
if (value) {
|
||||
rt_kprintf("The %s value is %s.\n", argv[1], value);
|
||||
} else {
|
||||
rt_kprintf("Can't find %s.\n", argv[1]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(getvalue, Get an envrionment variable by name.);
|
||||
|
||||
void resetenv(uint8_t argc, char **argv) {
|
||||
ef_env_set_default();
|
||||
}
|
||||
MSH_CMD_EXPORT(resetenv, Reset all envrionment variable to default.);
|
||||
#endif /* defined(EF_USING_ENV) */
|
||||
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
|
||||
|
41
demo/env/stm32f4xx/app/src/user_finsh_cmd.c
vendored
41
demo/env/stm32f4xx/app/src/user_finsh_cmd.c
vendored
@ -20,44 +20,3 @@ void get_cpuusage(void) {
|
||||
rt_kprintf("The CPU usage is %d.%d% now.\n", cpu_usage_major, cpu_usage_minor);
|
||||
}
|
||||
MSH_CMD_EXPORT(get_cpuusage, Get control board cpu usage);
|
||||
|
||||
void setenv(uint8_t argc, char **argv) {
|
||||
uint8_t i;
|
||||
char c_value = NULL;
|
||||
char *value = &c_value;
|
||||
if (argc > 3) {
|
||||
/* environment variable value string together */
|
||||
for (i = 0; i < argc - 2; i++) {
|
||||
argv[2 + i][rt_strlen(argv[2 + i])] = ' ';
|
||||
}
|
||||
}
|
||||
if (argc == 1) {
|
||||
ef_set_env(value, value);
|
||||
} else if (argc == 2) {
|
||||
ef_set_env(argv[1], value);
|
||||
} else {
|
||||
ef_set_env(argv[1], argv[2]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(setenv, Set an envrionment variable.);
|
||||
|
||||
void printenv(uint8_t argc, char **argv) {
|
||||
ef_print_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(printenv, Print all envrionment variables.);
|
||||
|
||||
void saveenv(uint8_t argc, char **argv) {
|
||||
ef_save_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(saveenv, Save all envrionment variables to flash.);
|
||||
|
||||
void getvalue(uint8_t argc, char **argv) {
|
||||
char *value = NULL;
|
||||
value = ef_get_env(argv[1]);
|
||||
if (value) {
|
||||
rt_kprintf("The %s value is %s.\n", argv[1], value);
|
||||
} else {
|
||||
rt_kprintf("Can't find %s.\n", argv[1]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(getvalue, Get an envrionment variable by name.);
|
||||
|
@ -364,3 +364,54 @@ void ef_print(const char *format, ...) {
|
||||
rt_kprintf("%s", log_buf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
#include <finsh.h>
|
||||
#if defined(EF_USING_ENV)
|
||||
void setenv(uint8_t argc, char **argv) {
|
||||
uint8_t i;
|
||||
char c_value = NULL;
|
||||
char *value = &c_value;
|
||||
if (argc > 3) {
|
||||
/* environment variable value string together */
|
||||
for (i = 0; i < argc - 2; i++) {
|
||||
argv[2 + i][rt_strlen(argv[2 + i])] = ' ';
|
||||
}
|
||||
}
|
||||
if (argc == 1) {
|
||||
ef_set_env(value, value);
|
||||
} else if (argc == 2) {
|
||||
ef_set_env(argv[1], value);
|
||||
} else {
|
||||
ef_set_env(argv[1], argv[2]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(setenv, Set an envrionment variable.);
|
||||
|
||||
void printenv(uint8_t argc, char **argv) {
|
||||
ef_print_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(printenv, Print all envrionment variables.);
|
||||
|
||||
void saveenv(uint8_t argc, char **argv) {
|
||||
ef_save_env();
|
||||
}
|
||||
MSH_CMD_EXPORT(saveenv, Save all envrionment variables to flash.);
|
||||
|
||||
void getvalue(uint8_t argc, char **argv) {
|
||||
char *value = NULL;
|
||||
value = ef_get_env(argv[1]);
|
||||
if (value) {
|
||||
rt_kprintf("The %s value is %s.\n", argv[1], value);
|
||||
} else {
|
||||
rt_kprintf("Can't find %s.\n", argv[1]);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(getvalue, Get an envrionment variable by name.);
|
||||
|
||||
void resetenv(uint8_t argc, char **argv) {
|
||||
ef_env_set_default();
|
||||
}
|
||||
MSH_CMD_EXPORT(resetenv, Reset all envrionment variable to default.);
|
||||
#endif /* defined(EF_USING_ENV) */
|
||||
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
|
||||
|
Loading…
Reference in New Issue
Block a user