Minor changes to shell-commands

This commit is contained in:
Simon Duquennoy 2017-10-11 17:26:39 +02:00
parent 48997bb3ad
commit 4c7d2a4bfc
1 changed files with 18 additions and 4 deletions

View File

@ -51,11 +51,13 @@
#include "net/ipv6/uiplib.h" #include "net/ipv6/uiplib.h"
#include "net/ipv6/uip-icmp6.h" #include "net/ipv6/uip-icmp6.h"
#include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6.h"
#if MAC_CONF_WITH_TSCH
#include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch.h"
#include "net/mac/tsch/tsch-adaptive-timesync.h" #include "net/mac/tsch/tsch-adaptive-timesync.h"
#include "net/mac/tsch/tsch-queue.h" #include "net/mac/tsch/tsch-queue.h"
#include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-log.h"
#include "net/mac/tsch/tsch-private.h" #include "net/mac/tsch/tsch-private.h"
#endif /* MAC_CONF_WITH_TSCH */
#if UIP_CONF_IPV6_RPL_LITE == 1 #if UIP_CONF_IPV6_RPL_LITE == 1
#include "net/rpl-lite/rpl.h" #include "net/rpl-lite/rpl.h"
#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ #else /* UIP_CONF_IPV6_RPL_LITE == 1 */
@ -234,7 +236,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
if(!rpl_dag_root_is_root()) { if(!rpl_dag_root_is_root()) {
SHELL_OUTPUT(output, "Setting as DAG root with prefix "); SHELL_OUTPUT(output, "Setting as DAG root with prefix ");
shell_output_6addr(output, &prefix); shell_output_6addr(output, &prefix);
SHELL_OUTPUT(output, "\n"); SHELL_OUTPUT(output, "/64\n");
rpl_dag_root_init(&prefix, NULL); rpl_dag_root_init(&prefix, NULL);
rpl_dag_root_init_dag_immediately(); rpl_dag_root_init_dag_immediately();
} else { } else {
@ -258,8 +260,9 @@ shell_output_log_levels(shell_output_func output)
int i = 0; int i = 0;
SHELL_OUTPUT(output, "Log levels:\n"); SHELL_OUTPUT(output, "Log levels:\n");
while(all_modules[i].name != NULL) { while(all_modules[i].name != NULL) {
SHELL_OUTPUT(output, "-- %-10s: %s\n", SHELL_OUTPUT(output, "-- %-10s: %u (%s)\n",
all_modules[i].name, all_modules[i].name,
*all_modules[i].curr_log_level,
log_level_to_str(*all_modules[i].curr_log_level)); log_level_to_str(*all_modules[i].curr_log_level));
i++; i++;
} }
@ -304,6 +307,7 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
/* Set log level */ /* Set log level */
if(level != prev_level) { if(level != prev_level) {
log_set_level(module, level); log_set_level(module, level);
#if MAC_CONF_WITH_TSCH
if(!strcmp(module, "mac") || !strcmp(module, "all")) { if(!strcmp(module, "mac") || !strcmp(module, "all")) {
if(level >= LOG_LEVEL_DBG) { if(level >= LOG_LEVEL_DBG) {
tsch_log_init(); tsch_log_init();
@ -313,6 +317,7 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
SHELL_OUTPUT(output, "TSCH logging stopped\n"); SHELL_OUTPUT(output, "TSCH logging stopped\n");
} }
} }
#endif /* MAC_CONF_WITH_TSCH */
} }
shell_output_log_levels(output); shell_output_log_levels(output);
@ -410,6 +415,7 @@ PT_THREAD(cmd_ip_neighbors(struct pt *pt, shell_output_func output, char *args))
PT_END(pt); PT_END(pt);
} }
#if MAC_CONF_WITH_TSCH
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static
PT_THREAD(cmd_tsch_status(struct pt *pt, shell_output_func output, char *args)) PT_THREAD(cmd_tsch_status(struct pt *pt, shell_output_func output, char *args))
@ -438,6 +444,7 @@ PT_THREAD(cmd_tsch_status(struct pt *pt, shell_output_func output, char *args))
PT_END(pt); PT_END(pt);
} }
#endif /* MAC_CONF_WITH_TSCH */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static
PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args)) PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args))
@ -575,6 +582,8 @@ PT_THREAD(cmd_reboot(struct pt *pt, shell_output_func output, char *args))
watchdog_reboot(); watchdog_reboot();
PT_END(pt); PT_END(pt);
} }
#if MAC_CONF_WITH_TSCH
/*---------------------------------------------------------------------------*/
static static
PT_THREAD(cmd_tsch_schedule(struct pt *pt, shell_output_func output, char *args)) PT_THREAD(cmd_tsch_schedule(struct pt *pt, shell_output_func output, char *args))
{ {
@ -610,6 +619,7 @@ PT_THREAD(cmd_tsch_schedule(struct pt *pt, shell_output_func output, char *args)
} }
PT_END(pt); PT_END(pt);
} }
#endif /* MAC_CONF_WITH_TSCH */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if TSCH_WITH_SIXTOP #if TSCH_WITH_SIXTOP
void void
@ -645,22 +655,26 @@ shell_commands_init(void)
/* Set up Ping Reply callback */ /* Set up Ping Reply callback */
uip_icmp6_echo_reply_callback_add(&echo_reply_notification, uip_icmp6_echo_reply_callback_add(&echo_reply_notification,
echo_reply_handler); echo_reply_handler);
/* Start with soft log level 0 so as to minimize interference with shell */
log_set_level("all", LOG_LEVEL_NONE);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
struct shell_command_t shell_commands[] = { struct shell_command_t shell_commands[] = {
{ "help", cmd_help, "'> help': Shows this help" }, { "help", cmd_help, "'> help': Shows this help" },
{ "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" },
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" }, { "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
{ "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" }, { "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" },
{ "log", cmd_log, "'> log module level': Sets log level (0--4) for a given module (or \"all\"). For module \"mac\", level 4 also enables per-slot logging." }, { "log", cmd_log, "'> log module level': Sets log level (0--4) for a given module (or \"all\"). For module \"mac\", level 4 also enables per-slot logging." },
{ "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" }, { "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" },
{ "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (on) or not (off). A /64 prefix can be optionally specified." }, { "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (on) or not (off). A /64 prefix can be optionally specified." },
{ "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" }, { "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" },
{ "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" },
{ "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" }, { "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" },
{ "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" },
{ "routes", cmd_routes, "'> routes': Shows the route entries" }, { "routes", cmd_routes, "'> routes': Shows the route entries" },
#if MAC_CONF_WITH_TSCH
{ "tsch-schedule", cmd_tsch_schedule, "'> tsch-schedule': Shows the current TSCH schedule" }, { "tsch-schedule", cmd_tsch_schedule, "'> tsch-schedule': Shows the current TSCH schedule" },
{ "tsch-status", cmd_tsch_status, "'> tsch-status': Shows a summary of the current TSCH state" }, { "tsch-status", cmd_tsch_status, "'> tsch-status': Shows a summary of the current TSCH state" },
{ "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" }, #endif /* MAC_CONF_WITH_TSCH */
#if TSCH_WITH_SIXTOP #if TSCH_WITH_SIXTOP
{ "6top", cmd_6top, "'> 6top help': Shows 6top command usage" }, { "6top", cmd_6top, "'> 6top help': Shows 6top command usage" },
#endif /* TSCH_WITH_SIXTOP */ #endif /* TSCH_WITH_SIXTOP */