You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
C
64 lines
1.6 KiB
C
/*
|
|
* user_finsh_cmd.c
|
|
*
|
|
* Created on: 2013Äê12ÔÂ7ÈÕ
|
|
* Author: Armink
|
|
*/
|
|
#include <rthw.h>
|
|
#include <rtthread.h>
|
|
#include <stm32f4xx_conf.h>
|
|
#include "easyflash.h"
|
|
#include "finsh.h"
|
|
|
|
void reboot(uint8_t argc, char **argv) {
|
|
NVIC_SystemReset();
|
|
}
|
|
MSH_CMD_EXPORT(reboot, Reboot System);
|
|
|
|
void get_cpuusage(void) {
|
|
extern uint8_t cpu_usage_major, cpu_usage_minor;
|
|
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.);
|