shell: printing command's help by shell engine
Removed printing command help from help handler. It is now realized by the shell engine. This change saves a lot of flash but still allows to print help in command handler with function shell_help_print. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
parent
5451ff2848
commit
e0be6a10b3
15 changed files with 41 additions and 346 deletions
|
@ -44,11 +44,6 @@ static int cmd_lspci(const struct shell *shell, size_t argc, char **argv)
|
||||||
.bar = PCI_BAR_ANY,
|
.bar = PCI_BAR_ANY,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_bus_scan_init();
|
pci_bus_scan_init();
|
||||||
|
|
||||||
while (pci_bus_scan(&info)) {
|
while (pci_bus_scan(&info)) {
|
||||||
|
|
|
@ -342,7 +342,6 @@ struct shell_stats {
|
||||||
*/
|
*/
|
||||||
struct shell_flags {
|
struct shell_flags {
|
||||||
u32_t insert_mode :1; /*!< Controls insert mode for text introduction.*/
|
u32_t insert_mode :1; /*!< Controls insert mode for text introduction.*/
|
||||||
u32_t show_help :1; /*!< Shows help if -h or --help option present.*/
|
|
||||||
u32_t use_colors :1; /*!< Controls colored syntax.*/
|
u32_t use_colors :1; /*!< Controls colored syntax.*/
|
||||||
u32_t echo :1; /*!< Controls shell echo.*/
|
u32_t echo :1; /*!< Controls shell echo.*/
|
||||||
u32_t processing :1; /*!< Shell is executing process function.*/
|
u32_t processing :1; /*!< Shell is executing process function.*/
|
||||||
|
@ -615,18 +614,6 @@ void shell_fprintf(const struct shell *shell, enum shell_vt100_color color,
|
||||||
*/
|
*/
|
||||||
void shell_process(const struct shell *shell);
|
void shell_process(const struct shell *shell);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Informs that a command has been called with -h or --help option.
|
|
||||||
*
|
|
||||||
* @param[in] shell Pointer to the shell instance.
|
|
||||||
*
|
|
||||||
* @return True if help has been requested.
|
|
||||||
*/
|
|
||||||
static inline bool shell_help_requested(const struct shell *shell)
|
|
||||||
{
|
|
||||||
return shell->ctx->internal.flags.show_help;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the current command help.
|
* @brief Prints the current command help.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,11 +34,6 @@ static int cmd_read(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
u32_t *p_mem = (u32_t *) RESERVED_MEM_MAP;
|
u32_t *p_mem = (u32_t *) RESERVED_MEM_MAP;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reads from an address that is reserved in the memory map */
|
/* Reads from an address that is reserved in the memory map */
|
||||||
PR_SHELL(shell, "The value is: %d\n", *p_mem);
|
PR_SHELL(shell, "The value is: %d\n", *p_mem);
|
||||||
|
|
||||||
|
@ -55,11 +50,6 @@ static int cmd_write_mcux(const struct shell *shell, size_t argc, char *argv[])
|
||||||
u32_t value[2];
|
u32_t value[2];
|
||||||
u32_t offset;
|
u32_t offset;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
flash_dev = device_get_binding(DT_FLASH_DEV_NAME);
|
flash_dev = device_get_binding(DT_FLASH_DEV_NAME);
|
||||||
|
|
||||||
/* 128K reserved to the application */
|
/* 128K reserved to the application */
|
||||||
|
@ -90,11 +80,6 @@ static int cmd_write_stm32(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
struct device *flash_dev;
|
struct device *flash_dev;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
flash_dev = device_get_binding(DT_FLASH_DEV_NAME);
|
flash_dev = device_get_binding(DT_FLASH_DEV_NAME);
|
||||||
|
|
||||||
/* 16K reserved to the application */
|
/* 16K reserved to the application */
|
||||||
|
@ -123,11 +108,6 @@ static int cmd_write(const struct shell *shell, size_t argc, char *argv[])
|
||||||
/* 16K reserved to the application */
|
/* 16K reserved to the application */
|
||||||
u32_t *p_mem = (u32_t *) (FLASH_MEM + 0x4000);
|
u32_t *p_mem = (u32_t *) (FLASH_MEM + 0x4000);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_SHELL(shell, "write address: 0x%x\n", FLASH_MEM + 0x4000);
|
PR_SHELL(shell, "write address: 0x%x\n", FLASH_MEM + 0x4000);
|
||||||
|
|
||||||
/* Write in to boot FLASH/ROM */
|
/* Write in to boot FLASH/ROM */
|
||||||
|
@ -144,11 +124,6 @@ static int cmd_run(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
void (*func_ptr)(void) = (void (*)(void)) RAM_MEM;
|
void (*func_ptr)(void) = (void (*)(void)) RAM_MEM;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run code located in RAM */
|
/* Run code located in RAM */
|
||||||
func_ptr();
|
func_ptr();
|
||||||
|
|
||||||
|
|
|
@ -146,11 +146,6 @@ static int set_promisc_mode(const struct shell *shell,
|
||||||
char *endptr;
|
char *endptr;
|
||||||
int idx, ret;
|
int idx, ret;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
shell_fprintf(shell, SHELL_ERROR, "Invalid arguments.\n");
|
shell_fprintf(shell, SHELL_ERROR, "Invalid arguments.\n");
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
|
@ -24,11 +24,6 @@ static int cmd_br_repair(const struct shell *shell,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_INFO, "Starting global repair...\n");
|
shell_fprintf(shell, SHELL_INFO, "Starting global repair...\n");
|
||||||
|
|
||||||
net_rpl_repair_root(CONFIG_NET_RPL_DEFAULT_INSTANCE);
|
net_rpl_repair_root(CONFIG_NET_RPL_DEFAULT_INSTANCE);
|
||||||
|
@ -43,11 +38,6 @@ static int cmd_coap_send(const struct shell *shell,
|
||||||
enum coap_request_type type;
|
enum coap_request_type type;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 3 || !argv[1] || !argv[2]) {
|
if (argc != 3 || !argv[1] || !argv[2]) {
|
||||||
shell_fprintf(shell, SHELL_ERROR, "Invalid arguments.\n");
|
shell_fprintf(shell, SHELL_ERROR, "Invalid arguments.\n");
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
|
@ -225,7 +225,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[])
|
||||||
do_init(shell);
|
do_init(shell);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && !IS_ENABLED(CONFIG_NET_IPV4)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && !IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||||
if (argc != 3 || shell_help_requested(shell)) {
|
if (argc != 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV4) && !IS_ENABLED(CONFIG_NET_IPV6)) {
|
if (IS_ENABLED(CONFIG_NET_IPV4) && !IS_ENABLED(CONFIG_NET_IPV6)) {
|
||||||
if (argc != 2 || shell_help_requested(shell)) {
|
if (argc != 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && IS_ENABLED(CONFIG_NET_IPV4)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||||
if (net_addr_pton(AF_INET6, argv[start + 1], &ipv6) < 0) {
|
if (net_addr_pton(AF_INET6, argv[start + 1], &ipv6) < 0) {
|
||||||
if (argc != 2 || shell_help_requested(shell)) {
|
if (argc != 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[])
|
||||||
"Setting IP address %s\n",
|
"Setting IP address %s\n",
|
||||||
net_sprint_ipv4_addr(&ipv4));
|
net_sprint_ipv4_addr(&ipv4));
|
||||||
} else {
|
} else {
|
||||||
if (argc != 3 || shell_help_requested(shell)) {
|
if (argc != 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -307,11 +307,6 @@ static int cmd_udp_download(const struct shell *shell, size_t argc,
|
||||||
|
|
||||||
do_init(shell);
|
do_init(shell);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
port = strtoul(argv[start + 1], NULL, 10);
|
port = strtoul(argv[start + 1], NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
|
@ -983,11 +978,6 @@ static int cmd_tcp_download(const struct shell *shell, size_t argc,
|
||||||
|
|
||||||
do_init(shell);
|
do_init(shell);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
port = strtoul(argv[1], NULL, 10);
|
port = strtoul(argv[1], NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern void qsort(void *a, size_t n, size_t es, cmp_t *cmp);
|
||||||
|
|
||||||
static int cmd_dynamic(const struct shell *shell, size_t argc, char **argv)
|
static int cmd_dynamic(const struct shell *shell, size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
if ((argc == 1) || shell_help_requested(shell)) {
|
if ((argc == 1)) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,6 @@ static int cmd_dynamic_add(const struct shell *shell,
|
||||||
u8_t idx;
|
u8_t idx;
|
||||||
u16_t cmd_len;
|
u16_t cmd_len;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
shell_fprintf(shell, SHELL_ERROR,
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
"%s: bad parameter count\r\n", argv[0]);
|
"%s: bad parameter count\r\n", argv[0]);
|
||||||
|
@ -102,11 +97,6 @@ static int cmd_dynamic_add(const struct shell *shell,
|
||||||
static int cmd_dynamic_show(const struct shell *shell,
|
static int cmd_dynamic_show(const struct shell *shell,
|
||||||
size_t argc, char **argv)
|
size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
shell_fprintf(shell, SHELL_ERROR,
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
"%s: bad parameter count\r\n", argv[0]);
|
"%s: bad parameter count\r\n", argv[0]);
|
||||||
|
@ -132,11 +122,6 @@ static int cmd_dynamic_show(const struct shell *shell,
|
||||||
static int cmd_dynamic_execute(const struct shell *shell,
|
static int cmd_dynamic_execute(const struct shell *shell,
|
||||||
size_t argc, char **argv)
|
size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
shell_fprintf(shell, SHELL_ERROR,
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
"%s: bad parameter count\r\n", argv[0]);
|
"%s: bad parameter count\r\n", argv[0]);
|
||||||
|
@ -160,7 +145,7 @@ static int cmd_dynamic_execute(const struct shell *shell,
|
||||||
static int cmd_dynamic_remove(const struct shell *shell, size_t argc,
|
static int cmd_dynamic_remove(const struct shell *shell, size_t argc,
|
||||||
char **argv)
|
char **argv)
|
||||||
{
|
{
|
||||||
if ((argc == 1) || shell_help_requested(shell)) {
|
if (argc == 1) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,7 +441,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(sub_log_stat)
|
||||||
|
|
||||||
static int cmd_log(const struct shell *shell, size_t argc, char **argv)
|
static int cmd_log(const struct shell *shell, size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
if ((argc == 1) || shell_help_requested(shell)) {
|
if (argc == 1) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1152,11 +1152,6 @@ static int cmd_net_allocs(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
|
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
|
|
||||||
|
@ -1380,11 +1375,6 @@ static int cmd_net_app(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CONFIG_NET_APP_LOG_LEVEL >= LOG_LEVEL_DBG
|
#if CONFIG_NET_APP_LOG_LEVEL >= LOG_LEVEL_DBG
|
||||||
if (IS_ENABLED(CONFIG_NET_APP_SERVER)) {
|
if (IS_ENABLED(CONFIG_NET_APP_SERVER)) {
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
|
@ -1458,11 +1448,6 @@ static int cmd_net_arp(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_ARP)
|
#if defined(CONFIG_NET_ARP)
|
||||||
if (!argv[arg]) {
|
if (!argv[arg]) {
|
||||||
/* ARP cache content */
|
/* ARP cache content */
|
||||||
|
@ -1488,11 +1473,6 @@ static int cmd_net_arp_flush(const struct shell *shell, size_t argc,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_ARP)
|
#if defined(CONFIG_NET_ARP)
|
||||||
PR("Flushing ARP cache.\n");
|
PR("Flushing ARP cache.\n");
|
||||||
net_arp_clear_cache(NULL);
|
net_arp_clear_cache(NULL);
|
||||||
|
@ -1511,11 +1491,6 @@ static int cmd_net_conn(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR(" Context \tIface Flags Local \tRemote\n");
|
PR(" Context \tIface Flags Local \tRemote\n");
|
||||||
|
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
|
@ -1693,11 +1668,6 @@ static int cmd_net_dns_cancel(const struct shell *shell, size_t argc,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_DNS_RESOLVER)
|
#if defined(CONFIG_DNS_RESOLVER)
|
||||||
ctx = dns_resolve_get_default();
|
ctx = dns_resolve_get_default();
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
|
@ -1731,10 +1701,6 @@ static int cmd_net_dns_cancel(const struct shell *shell, size_t argc,
|
||||||
static int cmd_net_dns_query(const struct shell *shell, size_t argc,
|
static int cmd_net_dns_query(const struct shell *shell, size_t argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_DNS_RESOLVER)
|
#if defined(CONFIG_DNS_RESOLVER)
|
||||||
#define DNS_TIMEOUT K_MSEC(2000) /* ms */
|
#define DNS_TIMEOUT K_MSEC(2000) /* ms */
|
||||||
|
@ -1792,11 +1758,6 @@ static int cmd_net_dns(const struct shell *shell, size_t argc, char *argv[])
|
||||||
struct dns_resolve_context *ctx;
|
struct dns_resolve_context *ctx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_DNS_RESOLVER)
|
#if defined(CONFIG_DNS_RESOLVER)
|
||||||
if (argv[1]) {
|
if (argv[1]) {
|
||||||
/* So this is a query then */
|
/* So this is a query then */
|
||||||
|
@ -2338,11 +2299,6 @@ static int cmd_net_gptp_port(const struct shell *shell, size_t argc,
|
||||||
int port;
|
int port;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_GPTP)
|
#if defined(CONFIG_NET_GPTP)
|
||||||
if (!argv[arg]) {
|
if (!argv[arg]) {
|
||||||
PR_WARNING("Port number must be given.\n");
|
PR_WARNING("Port number must be given.\n");
|
||||||
|
@ -2375,11 +2331,6 @@ static int cmd_net_gptp(const struct shell *shell, size_t argc, char *argv[])
|
||||||
int arg = 1;
|
int arg = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_GPTP)
|
#if defined(CONFIG_NET_GPTP)
|
||||||
if (argv[arg]) {
|
if (argv[arg]) {
|
||||||
cmd_net_gptp_port(shell, argc, argv);
|
cmd_net_gptp_port(shell, argc, argv);
|
||||||
|
@ -2497,11 +2448,6 @@ static int http_monitor_count;
|
||||||
static int cmd_net_http_monitor(const struct shell *shell, size_t argc,
|
static int cmd_net_http_monitor(const struct shell *shell, size_t argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_DEBUG_HTTP_CONN) && defined(CONFIG_HTTP_SERVER)
|
#if defined(CONFIG_NET_DEBUG_HTTP_CONN) && defined(CONFIG_HTTP_SERVER)
|
||||||
PR_INFO("Activating HTTP monitor. Type \"net http\" "
|
PR_INFO("Activating HTTP monitor. Type \"net http\" "
|
||||||
"to disable HTTP connection monitoring.\n");
|
"to disable HTTP connection monitoring.\n");
|
||||||
|
@ -2524,11 +2470,6 @@ static int cmd_net_http(const struct shell *shell, size_t argc, char *argv[])
|
||||||
int arg = 2;
|
int arg = 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_DEBUG_HTTP_CONN) && defined(CONFIG_HTTP_SERVER)
|
#if defined(CONFIG_NET_DEBUG_HTTP_CONN) && defined(CONFIG_HTTP_SERVER)
|
||||||
http_monitor_count = 0;
|
http_monitor_count = 0;
|
||||||
|
|
||||||
|
@ -2580,11 +2521,6 @@ static int cmd_net_iface_up(const struct shell *shell, size_t argc,
|
||||||
struct net_if *iface;
|
struct net_if *iface;
|
||||||
int idx, ret;
|
int idx, ret;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
idx = get_iface_idx(shell, argv[1]);
|
idx = get_iface_idx(shell, argv[1]);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
@ -2618,11 +2554,6 @@ static int cmd_net_iface_down(const struct shell *shell, size_t argc,
|
||||||
struct net_if *iface;
|
struct net_if *iface;
|
||||||
int idx, ret;
|
int idx, ret;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
idx = get_iface_idx(shell, argv[1]);
|
idx = get_iface_idx(shell, argv[1]);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
@ -2721,10 +2652,6 @@ static int cmd_net_ipv6(const struct shell *shell, size_t argc, char *argv[])
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
struct net_shell_user_data user_data;
|
struct net_shell_user_data user_data;
|
||||||
#endif
|
#endif
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR("IPv6 support : %s\n",
|
PR("IPv6 support : %s\n",
|
||||||
IS_ENABLED(CONFIG_NET_IPV6) ?
|
IS_ENABLED(CONFIG_NET_IPV6) ?
|
||||||
|
@ -2792,11 +2719,6 @@ static int cmd_net_iface(const struct shell *shell, size_t argc, char *argv[])
|
||||||
struct net_shell_user_data user_data;
|
struct net_shell_user_data user_data;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv[1]) {
|
if (argv[1]) {
|
||||||
idx = get_iface_idx(shell, argv[1]);
|
idx = get_iface_idx(shell, argv[1]);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -2912,11 +2834,6 @@ static int cmd_net_mem(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
net_pkt_get_info(&rx, &tx, &rx_data, &tx_data);
|
net_pkt_get_info(&rx, &tx, &rx_data, &tx_data);
|
||||||
|
|
||||||
PR("Fragment length %d bytes\n", CONFIG_NET_BUF_DATA_SIZE);
|
PR("Fragment length %d bytes\n", CONFIG_NET_BUF_DATA_SIZE);
|
||||||
|
@ -2976,11 +2893,6 @@ static int cmd_net_nbr_rm(const struct shell *shell, size_t argc,
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
if (!argv[1]) {
|
if (!argv[1]) {
|
||||||
PR_WARNING("Neighbor IPv6 address missing.\n");
|
PR_WARNING("Neighbor IPv6 address missing.\n");
|
||||||
|
@ -3082,11 +2994,6 @@ static int cmd_net_nbr(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
user_data.user_data = &count;
|
user_data.user_data = &count;
|
||||||
|
@ -3247,11 +3154,6 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[])
|
||||||
|
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
host = argv[1];
|
host = argv[1];
|
||||||
|
|
||||||
if (!host) {
|
if (!host) {
|
||||||
|
@ -3306,11 +3208,6 @@ static int cmd_net_route(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_ROUTE) || defined(CONFIG_NET_ROUTE_MCAST)
|
#if defined(CONFIG_NET_ROUTE) || defined(CONFIG_NET_ROUTE_MCAST)
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3390,11 +3287,6 @@ static int cmd_net_rpl(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_RPL)
|
#if defined(CONFIG_NET_RPL)
|
||||||
mode = net_rpl_get_mode();
|
mode = net_rpl_get_mode();
|
||||||
PR("RPL Configuration\n");
|
PR("RPL Configuration\n");
|
||||||
|
@ -3551,11 +3443,6 @@ static int cmd_net_stacks(const struct shell *shell, size_t argc,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (info = __net_stack_start; info != __net_stack_end; info++) {
|
for (info = __net_stack_start; info != __net_stack_end; info++) {
|
||||||
net_analyze_stack_get_values(K_THREAD_STACK_BUFFER(info->stack),
|
net_analyze_stack_get_values(K_THREAD_STACK_BUFFER(info->stack),
|
||||||
info->size, &pcnt, &unused);
|
info->size, &pcnt, &unused);
|
||||||
|
@ -3631,11 +3518,6 @@ static int cmd_net_stats_all(const struct shell *shell, size_t argc,
|
||||||
struct net_shell_user_data user_data;
|
struct net_shell_user_data user_data;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_STATISTICS)
|
#if defined(CONFIG_NET_STATISTICS)
|
||||||
user_data.shell = shell;
|
user_data.shell = shell;
|
||||||
|
|
||||||
|
@ -3664,11 +3546,6 @@ static int cmd_net_stats_iface(const struct shell *shell, size_t argc,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_STATISTICS)
|
#if defined(CONFIG_NET_STATISTICS)
|
||||||
#if defined(CONFIG_NET_STATISTICS_PER_INTERFACE)
|
#if defined(CONFIG_NET_STATISTICS_PER_INTERFACE)
|
||||||
idx = strtol(argv[1], &endptr, 10);
|
idx = strtol(argv[1], &endptr, 10);
|
||||||
|
@ -3703,11 +3580,6 @@ static int cmd_net_stats_iface(const struct shell *shell, size_t argc,
|
||||||
|
|
||||||
static int cmd_net_stats(const struct shell *shell, size_t argc, char *argv[])
|
static int cmd_net_stats(const struct shell *shell, size_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_STATISTICS)
|
#if defined(CONFIG_NET_STATISTICS)
|
||||||
if (!argv[1]) {
|
if (!argv[1]) {
|
||||||
cmd_net_stats_all(shell, argc, argv);
|
cmd_net_stats_all(shell, argc, argv);
|
||||||
|
@ -3940,11 +3812,6 @@ static int cmd_net_tcp_connect(const struct shell *shell, size_t argc,
|
||||||
u16_t port;
|
u16_t port;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP)
|
#if defined(CONFIG_NET_TCP)
|
||||||
/* tcp connect <ip> port */
|
/* tcp connect <ip> port */
|
||||||
if (tcp_ctx && net_context_is_used(tcp_ctx)) {
|
if (tcp_ctx && net_context_is_used(tcp_ctx)) {
|
||||||
|
@ -3988,11 +3855,6 @@ static int cmd_net_tcp_send(const struct shell *shell, size_t argc,
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP)
|
#if defined(CONFIG_NET_TCP)
|
||||||
/* tcp send <data> */
|
/* tcp send <data> */
|
||||||
if (!tcp_ctx || !net_context_is_used(tcp_ctx)) {
|
if (!tcp_ctx || !net_context_is_used(tcp_ctx)) {
|
||||||
|
@ -4043,11 +3905,6 @@ static int cmd_net_tcp_close(const struct shell *shell, size_t argc,
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP)
|
#if defined(CONFIG_NET_TCP)
|
||||||
/* tcp close */
|
/* tcp close */
|
||||||
if (!tcp_ctx || !net_context_is_used(tcp_ctx)) {
|
if (!tcp_ctx || !net_context_is_used(tcp_ctx)) {
|
||||||
|
@ -4075,11 +3932,6 @@ static int cmd_net_tcp(const struct shell *shell, size_t argc, char *argv[])
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4152,11 +4004,6 @@ static int cmd_net_vlan(const struct shell *shell, size_t argc, char *argv[])
|
||||||
int count;
|
int count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_VLAN)
|
#if defined(CONFIG_NET_VLAN)
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
|
@ -4183,11 +4030,6 @@ static int cmd_net_vlan_add(const struct shell *shell, size_t argc,
|
||||||
u32_t iface_idx;
|
u32_t iface_idx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_VLAN)
|
#if defined(CONFIG_NET_VLAN)
|
||||||
/* vlan add <tag> <interface index> */
|
/* vlan add <tag> <interface index> */
|
||||||
if (!argv[++arg]) {
|
if (!argv[++arg]) {
|
||||||
|
@ -4260,11 +4102,6 @@ static int cmd_net_vlan_del(const struct shell *shell, size_t argc,
|
||||||
u16_t tag;
|
u16_t tag;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_VLAN)
|
#if defined(CONFIG_NET_VLAN)
|
||||||
/* vlan del <tag> */
|
/* vlan del <tag> */
|
||||||
if (!argv[++arg]) {
|
if (!argv[++arg]) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ static int shell_cmd_connect(const struct shell *shell,
|
||||||
bt_addr_le_t addr;
|
bt_addr_le_t addr;
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
|
|
||||||
if (argc < 3 || shell_help_requested(shell)) {
|
if (argc < 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ static int shell_cmd_scan(const struct shell *shell,
|
||||||
{
|
{
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,6 @@ static int shell_cmd_disconnect(const struct shell *shell,
|
||||||
{
|
{
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (net_mgmt(NET_REQUEST_BT_DISCONNECT, iface, NULL, 0)) {
|
if (net_mgmt(NET_REQUEST_BT_DISCONNECT, iface, NULL, 0)) {
|
||||||
shell_fprintf(shell, SHELL_WARNING,
|
shell_fprintf(shell, SHELL_WARNING,
|
||||||
"Disconnect failed\n");
|
"Disconnect failed\n");
|
||||||
|
@ -154,7 +149,7 @@ static int shell_cmd_advertise(const struct shell *shell,
|
||||||
{
|
{
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,6 @@ static int cmd_ieee802154_ack(const struct shell *shell,
|
||||||
|
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -77,7 +72,7 @@ static int cmd_ieee802154_associate(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
char ext_addr[MAX_EXT_ADDR_STR_LEN];
|
char ext_addr[MAX_EXT_ADDR_STR_LEN];
|
||||||
|
|
||||||
if (argc < 3 || shell_help_requested(shell)) {
|
if (argc < 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -123,11 +118,6 @@ static int cmd_ieee802154_disassociate(const struct shell *shell,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -217,7 +207,7 @@ static int cmd_ieee802154_scan(const struct shell *shell,
|
||||||
u32_t scan_type;
|
u32_t scan_type;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (argc < 3 || shell_help_requested(shell)) {
|
if (argc < 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +278,7 @@ static int cmd_ieee802154_set_chan(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
u16_t channel;
|
u16_t channel;
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -324,11 +314,6 @@ static int cmd_ieee802154_get_chan(const struct shell *shell,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -357,7 +342,7 @@ static int cmd_ieee802154_set_pan_id(const struct shell *shell,
|
||||||
|
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -393,11 +378,6 @@ static int cmd_ieee802154_get_pan_id(const struct shell *shell,
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -424,7 +404,7 @@ static int cmd_ieee802154_set_ext_addr(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
u8_t addr[IEEE802154_EXT_ADDR_LENGTH];
|
u8_t addr[IEEE802154_EXT_ADDR_LENGTH];
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -463,11 +443,6 @@ static int cmd_ieee802154_get_ext_addr(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
u8_t addr[IEEE802154_EXT_ADDR_LENGTH];
|
u8_t addr[IEEE802154_EXT_ADDR_LENGTH];
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -504,7 +479,7 @@ static int cmd_ieee802154_set_short_addr(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
u16_t short_addr;
|
u16_t short_addr;
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -537,11 +512,6 @@ static int cmd_ieee802154_get_short_addr(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
u16_t short_addr;
|
u16_t short_addr;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
@ -568,7 +538,7 @@ static int cmd_ieee802154_set_tx_power(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
s16_t tx_power;
|
s16_t tx_power;
|
||||||
|
|
||||||
if (argc < 2 || shell_help_requested(shell)) {
|
if (argc < 2) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -601,11 +571,6 @@ static int cmd_ieee802154_get_tx_power(const struct shell *shell,
|
||||||
struct net_if *iface = net_if_get_ieee802154();
|
struct net_if *iface = net_if_get_ieee802154();
|
||||||
s16_t tx_power;
|
s16_t tx_power;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
shell_fprintf(shell, SHELL_INFO,
|
shell_fprintf(shell, SHELL_INFO,
|
||||||
"No IEEE 802.15.4 interface found.\n");
|
"No IEEE 802.15.4 interface found.\n");
|
||||||
|
|
|
@ -151,7 +151,7 @@ static int cmd_wifi_connect(const struct shell *shell, size_t argc,
|
||||||
char *endptr;
|
char *endptr;
|
||||||
int idx = 3;
|
int idx = 3;
|
||||||
|
|
||||||
if (shell_help_requested(shell) || argc < 3) {
|
if (argc < 3) {
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -212,11 +212,6 @@ static int cmd_wifi_disconnect(const struct shell *shell, size_t argc,
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.disconnecting = true;
|
context.disconnecting = true;
|
||||||
context.shell = shell;
|
context.shell = shell;
|
||||||
|
|
||||||
|
@ -245,11 +240,6 @@ static int cmd_wifi_scan(const struct shell *shell, size_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (net_mgmt(NET_REQUEST_WIFI_SCAN, iface, NULL, 0)) {
|
if (net_mgmt(NET_REQUEST_WIFI_SCAN, iface, NULL, 0)) {
|
||||||
shell_fprintf(shell, SHELL_WARNING, "Scan request failed\n");
|
shell_fprintf(shell, SHELL_WARNING, "Scan request failed\n");
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,6 @@ static int ot_cmd(const struct shell *shell, size_t argc, char *argv[])
|
||||||
size_t arg_len = 0;
|
size_t arg_len = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return -ENOEXEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,15 +62,6 @@ static inline void transport_buffer_flush(const struct shell *shell)
|
||||||
shell_fprintf_buffer_flush(shell->fprintf_ctx);
|
shell_fprintf_buffer_flush(shell->fprintf_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void help_flag_set(const struct shell *shell)
|
|
||||||
{
|
|
||||||
shell->ctx->internal.flags.show_help = 1;
|
|
||||||
}
|
|
||||||
static inline void help_flag_clear(const struct shell *shell)
|
|
||||||
{
|
|
||||||
shell->ctx->internal.flags.show_help = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Function returns true if delete escape code shall be interpreted as
|
/* Function returns true if delete escape code shall be interpreted as
|
||||||
* backspace.
|
* backspace.
|
||||||
*/
|
*/
|
||||||
|
@ -974,12 +965,16 @@ static const struct shell_cmd_entry *root_cmd_find(const char *syntax)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int exec_cmd(const struct shell *shell, size_t argc, char **argv)
|
static int exec_cmd(const struct shell *shell, size_t argc, char **argv,
|
||||||
|
struct shell_static_entry help_entry)
|
||||||
{
|
{
|
||||||
int ret_val = 0;
|
int ret_val = 0;
|
||||||
|
|
||||||
if (shell->ctx->active_cmd.handler == NULL) {
|
if (shell->ctx->active_cmd.handler == NULL) {
|
||||||
if (shell->ctx->active_cmd.help) {
|
if (help_entry.help) {
|
||||||
|
if (help_entry.help != shell->ctx->active_cmd.help) {
|
||||||
|
shell->ctx->active_cmd = help_entry;
|
||||||
|
}
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
} else {
|
} else {
|
||||||
shell_fprintf(shell, SHELL_ERROR,
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
|
@ -1014,12 +1009,9 @@ static int exec_cmd(const struct shell *shell, size_t argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
clear:
|
clear:
|
||||||
help_flag_clear(shell);
|
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function is analyzing the command buffer to find matching commands. Next, it
|
/* Function is analyzing the command buffer to find matching commands. Next, it
|
||||||
* invokes the last recognized command which has a handler and passes the rest
|
* invokes the last recognized command which has a handler and passes the rest
|
||||||
* of command buffer as arguments.
|
* of command buffer as arguments.
|
||||||
|
@ -1030,6 +1022,7 @@ static int shell_execute(const struct shell *shell)
|
||||||
char *argv[CONFIG_SHELL_ARGC_MAX + 1]; /* +1 reserved for NULL */
|
char *argv[CONFIG_SHELL_ARGC_MAX + 1]; /* +1 reserved for NULL */
|
||||||
const struct shell_static_entry *p_static_entry = NULL;
|
const struct shell_static_entry *p_static_entry = NULL;
|
||||||
const struct shell_cmd_entry *p_cmd = NULL;
|
const struct shell_cmd_entry *p_cmd = NULL;
|
||||||
|
struct shell_static_entry help_entry;
|
||||||
size_t cmd_lvl = SHELL_CMD_ROOT_LVL;
|
size_t cmd_lvl = SHELL_CMD_ROOT_LVL;
|
||||||
size_t cmd_with_handler_lvl = 0;
|
size_t cmd_with_handler_lvl = 0;
|
||||||
bool wildcard_found = false;
|
bool wildcard_found = false;
|
||||||
|
@ -1080,6 +1073,7 @@ static int shell_execute(const struct shell *shell)
|
||||||
|
|
||||||
/* checking if root command has a handler */
|
/* checking if root command has a handler */
|
||||||
shell->ctx->active_cmd = *p_cmd->u.entry;
|
shell->ctx->active_cmd = *p_cmd->u.entry;
|
||||||
|
help_entry = *p_cmd->u.entry;
|
||||||
|
|
||||||
p_cmd = p_cmd->u.entry->subcmd;
|
p_cmd = p_cmd->u.entry->subcmd;
|
||||||
cmd_lvl++;
|
cmd_lvl++;
|
||||||
|
@ -1096,8 +1090,15 @@ static int shell_execute(const struct shell *shell)
|
||||||
/* Command called with help option so it makes no sense
|
/* Command called with help option so it makes no sense
|
||||||
* to search deeper commands.
|
* to search deeper commands.
|
||||||
*/
|
*/
|
||||||
help_flag_set(shell);
|
if (help_entry.help) {
|
||||||
break;
|
shell->ctx->active_cmd = help_entry;
|
||||||
|
shell_help_print(shell);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
|
SHELL_MSG_SPECIFY_SUBCOMMAND);
|
||||||
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_SHELL_WILDCARD)) {
|
if (IS_ENABLED(CONFIG_SHELL_WILDCARD)) {
|
||||||
|
@ -1147,7 +1148,6 @@ static int shell_execute(const struct shell *shell)
|
||||||
"Error: requested"
|
"Error: requested"
|
||||||
" multiple function"
|
" multiple function"
|
||||||
" executions\r\n");
|
" executions\r\n");
|
||||||
help_flag_clear(shell);
|
|
||||||
|
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
@ -1156,6 +1156,10 @@ static int shell_execute(const struct shell *shell)
|
||||||
shell->ctx->active_cmd = *p_static_entry;
|
shell->ctx->active_cmd = *p_static_entry;
|
||||||
cmd_with_handler_lvl = cmd_lvl;
|
cmd_with_handler_lvl = cmd_lvl;
|
||||||
}
|
}
|
||||||
|
/* checking if function has a help handler */
|
||||||
|
if (p_static_entry->help != NULL) {
|
||||||
|
help_entry = *p_static_entry;
|
||||||
|
}
|
||||||
|
|
||||||
cmd_lvl++;
|
cmd_lvl++;
|
||||||
cmd_idx = 0;
|
cmd_idx = 0;
|
||||||
|
@ -1176,7 +1180,7 @@ static int shell_execute(const struct shell *shell)
|
||||||
|
|
||||||
/* Executing the deepest found handler. */
|
/* Executing the deepest found handler. */
|
||||||
return exec_cmd(shell, argc - cmd_with_handler_lvl,
|
return exec_cmd(shell, argc - cmd_with_handler_lvl,
|
||||||
&argv[cmd_with_handler_lvl]);
|
&argv[cmd_with_handler_lvl], help_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shell_transport_evt_handler(enum shell_transport_evt evt_type,
|
static void shell_transport_evt_handler(enum shell_transport_evt evt_type,
|
||||||
|
@ -1740,11 +1744,6 @@ int shell_prompt_change(const struct shell *shell, char *prompt)
|
||||||
int shell_cmd_precheck(const struct shell *shell,
|
int shell_cmd_precheck(const struct shell *shell,
|
||||||
bool arg_cnt_ok)
|
bool arg_cnt_ok)
|
||||||
{
|
{
|
||||||
if (shell_help_requested(shell)) {
|
|
||||||
shell_help_print(shell);
|
|
||||||
return 1; /* help printed */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arg_cnt_ok) {
|
if (!arg_cnt_ok) {
|
||||||
shell_fprintf(shell, SHELL_ERROR,
|
shell_fprintf(shell, SHELL_ERROR,
|
||||||
"%s: wrong parameter count\n",
|
"%s: wrong parameter count\n",
|
||||||
|
|
|
@ -434,10 +434,7 @@ static int cmd_shell_stats(const struct shell *shell, size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
|
|
||||||
if (shell_help_requested(shell)) {
|
if (argc == 1) {
|
||||||
shell_help_print(shell);
|
|
||||||
return 1;
|
|
||||||
} else if (argc == 1) {
|
|
||||||
shell_help_print(shell);
|
shell_help_print(shell);
|
||||||
} else {
|
} else {
|
||||||
shell_fprintf(shell, SHELL_ERROR, "%s:%s%s\n", argv[0],
|
shell_fprintf(shell, SHELL_ERROR, "%s:%s%s\n", argv[0],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue