Skip to content

Commit

Permalink
sys/shell_commands: convert to SHELL_COMMAND()
Browse files Browse the repository at this point in the history
Make use of XFA for shell commands
  • Loading branch information
maribu committed Jun 2, 2022
1 parent d584823 commit fb32419
Show file tree
Hide file tree
Showing 85 changed files with 269 additions and 549 deletions.
1 change: 0 additions & 1 deletion examples/default/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include "thread.h"
#include "shell.h"
#include "shell_commands.h"

#ifdef MODULE_NETIF
#include "net/gnrc/pktdump.h"
Expand Down
1 change: 0 additions & 1 deletion examples/gnrc_lorawan/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "thread.h"
#include "shell.h"
#include "shell_commands.h"

#include "board.h"

Expand Down
1 change: 0 additions & 1 deletion examples/nimble_scanner/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "timex.h"
#include "ztimer.h"
#include "shell.h"
#include "shell_commands.h"

#include "nimble_scanner.h"
#include "nimble_scanlist.h"
Expand Down
1 change: 0 additions & 1 deletion examples/twr_aloha/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <stdio.h>
#include "shell.h"
#include "shell_commands.h"

#include "control.h"

Expand Down
1 change: 0 additions & 1 deletion examples/twr_aloha/twr_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "net/ieee802154.h"
#include "net/l2util.h"
#include "shell_commands.h"
#include "shell.h"
#include "ztimer.h"

Expand Down
1 change: 0 additions & 1 deletion pkg/nimble/autoadv/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <stdio.h>

#include "shell.h"
#include "shell_commands.h"
#include "xfa.h"

#include "nimble_riot.h"
Expand Down
32 changes: 30 additions & 2 deletions sys/congure/test/congure_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <stdlib.h>

#include "clist.h"
#include "fmt.h"

#include "congure/test.h"
#include "fmt.h"
#include "shell.h"

static congure_snd_msg_t _msgs_pool[CONFIG_CONGURE_TEST_LOST_MSG_POOL_SIZE];
static unsigned _msgs_pool_idx;
Expand All @@ -45,6 +45,9 @@ int congure_test_clear_state(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_clear, "Clears CongURE state object",
congure_test_clear_state);

int congure_test_call_setup(int argc, char **argv)
{
congure_test_snd_t *c = congure_test_get_state();
Expand All @@ -70,6 +73,10 @@ int congure_test_call_setup(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_setup,
"Calls the setup function for the CongURE state object",
congure_test_call_setup);

static inline bool _check_driver(congure_test_snd_t *c)
{
if (c->super.driver == NULL) {
Expand Down Expand Up @@ -103,6 +110,9 @@ int congure_test_call_init(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_init, "Calls init method of the CongURE state object",
congure_test_call_init);

int congure_test_call_inter_msg_interval(int argc, char **argv)
{
congure_test_snd_t *c = congure_test_get_state();
Expand All @@ -129,6 +139,10 @@ int congure_test_call_inter_msg_interval(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_imi,
"Calls inter_message_interval method of the CongURE state object",
congure_test_call_inter_msg_interval);

int congure_test_add_msg(int argc, char **argv)
{
uint32_t tmp;
Expand Down Expand Up @@ -169,6 +183,11 @@ int congure_test_add_msg(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_add_msg,
"Adds a message to the list of messages to be reported with "
"report_msgs_lost or report_msgs_timeout",
congure_test_add_msg);

int congure_test_msgs_reset(int argc, char **argv)
{
(void)argc;
Expand All @@ -179,6 +198,11 @@ int congure_test_msgs_reset(int argc, char **argv)
return 0;
}

SHELL_COMMAND(cong_msgs_reset,
"Resets the list of messages to be reported with report_msgs_lost or "
"report_msgs_timeout",
congure_test_msgs_reset);

static int _call_report_msg_sent(int argc, char **argv)
{
congure_test_snd_t *c = congure_test_get_state();
Expand Down Expand Up @@ -364,4 +388,8 @@ int congure_test_call_report(int argc, char **argv)
return 1;
}

SHELL_COMMAND(cong_report,
"Calls a report_* method of the CongURE state object",
congure_test_call_report);

/** @} */
51 changes: 0 additions & 51 deletions sys/include/shell_commands.h

This file was deleted.

2 changes: 1 addition & 1 deletion sys/shell/commands/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MODULE = shell_commands

SRC = shell_commands.c sc_sys.c
SRC = sc_sys.c

ifneq (,$(filter app_metadata,$(USEMODULE)))
SRC += sc_app_metadata.c
Expand Down
3 changes: 3 additions & 0 deletions sys/shell/commands/sc_app_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "app_metadata.h"
#include "shell.h"

int _app_metadata_handler(int argc, char **argv)
{
Expand All @@ -27,3 +28,5 @@ int _app_metadata_handler(int argc, char **argv)
app_metadata_print_json();
return 0;
}

SHELL_COMMAND(app_metadata, "Returns application metadata", _app_metadata_handler);
4 changes: 4 additions & 0 deletions sys/shell/commands/sc_at30tse75x.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

#include "at30tse75x.h"
#include "shell.h"

#ifdef MODULE_AT30TSE75X

Expand Down Expand Up @@ -157,4 +159,6 @@ int _at30tse75x_handler(int argc, char **argv)
return 0;
}

SHELL_COMMAND(at30tse75x, "Test AT30TSE75X temperature sensor", _at30tse75x_handler);

#endif /* MODULE_AT30TSE75X */
2 changes: 2 additions & 0 deletions sys/shell/commands/sc_benchmark_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ int _benchmark_udp_handler(int argc, char **argv)
printf("usage: %s [start|stop|config] <server> <port>\n", argv[0]);
return -1;
}

SHELL_COMMAND(bench_udp, "UDP benchmark", _benchmark_udp_handler);
/** @} */
5 changes: 5 additions & 0 deletions sys/shell/commands/sc_blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string.h>

#include "net/gnrc/ipv6/blacklist.h"
#include "shell.h"

static void _usage(char *cmd)
{
Expand Down Expand Up @@ -60,4 +61,8 @@ int _blacklist(int argc, char **argv)
return 0;
}

SHELL_COMMAND(blacklist,
"blacklists an address for receival ('blacklist [add|del|help]')",
_blacklist);

/** @} */
4 changes: 3 additions & 1 deletion sys/shell/commands/sc_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "can/conn/raw.h"
#include "can/raw.h"

#include "shell.h"
#include "timex.h"

#define SC_CAN_MAX_FILTERS 10
Expand Down Expand Up @@ -183,3 +183,5 @@ int _can_handler(int argc, char **argv)
}
return 0;
}

SHELL_COMMAND(can, "CAN commands", _can_handler);
16 changes: 13 additions & 3 deletions sys/shell/commands/sc_ccnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

#include <string.h>

#include "random.h"
#include "sched.h"
#include "net/gnrc/netif.h"
#include "ccn-lite-riot.h"
#include "ccnl-pkt-ndntlv.h"
#include "net/gnrc/netif.h"
#include "random.h"
#include "sched.h"
#include "shell.h"

#define BUF_SIZE (64)

Expand Down Expand Up @@ -73,6 +74,8 @@ int _ccnl_open(int argc, char **argv)
return 0;
}

SHELL_COMMAND(ccnl_open, "opens an interface or socket", _ccnl_open);

static void _content_usage(char *argv)
{
printf("usage: %s [URI] [content]\n"
Expand Down Expand Up @@ -142,6 +145,9 @@ int _ccnl_content(int argc, char **argv)
return 0;
}

SHELL_COMMAND(ccnl_cs, "shows CS or creates content and populates it",
_ccnl_content);

static struct ccnl_face_s *_intern_face_get(char *addr_str)
{
/* initialize address with 0xFF for broadcast */
Expand Down Expand Up @@ -219,6 +225,8 @@ int _ccnl_interest(int argc, char **argv)
return res;
}

SHELL_COMMAND(ccnl_int, "sends an interest", _ccnl_interest);

static void _ccnl_fib_usage(char *argv)
{
printf("usage: %s [<action> <options>]\n"
Expand Down Expand Up @@ -272,3 +280,5 @@ int _ccnl_fib(int argc, char **argv)
}
return 0;
}

SHELL_COMMAND(ccnl_fib, "shows or modifies the CCN-Lite FIB", _ccnl_fib);
5 changes: 4 additions & 1 deletion sys/shell/commands/sc_cord_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
#include <stdio.h>
#include <stdlib.h>

#include "net/cord/config.h"
#include "net/cord/ep.h"
#include "net/gnrc/netif.h"
#include "net/nanocoap.h"
#include "net/sock/util.h"
#include "net/cord/config.h"
#include "shell.h"

static int make_sock_ep(sock_udp_ep_t *ep, const char *addr)
{
Expand Down Expand Up @@ -132,3 +133,5 @@ int _cord_ep_handler(int argc, char **argv)

return 0;
}

SHELL_COMMAND(cord_ep, "Resource directory endpoint commands", _cord_ep_handler);
5 changes: 5 additions & 0 deletions sys/shell/commands/sc_cryptoauthlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
*/
#include <stdio.h>
#include <stdint.h>

#include "cryptoauthlib.h"
#include "shell.h"

void get_bin(char *result, uint8_t byte)
{
Expand Down Expand Up @@ -237,3 +239,6 @@ int _cryptoauth(int argc, char **argv)
}
return 0;
}

SHELL_COMMAND(cryptoauth, "Commands for Microchip CryptoAuth devices",
_cryptoauth);
5 changes: 4 additions & 1 deletion sys/shell/commands/sc_dfplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "dfplayer.h"
#include "dfplayer_internal.h"
#include "fmt.h"
#include "shell.h"

static const char *_equalizers[] = {
[DFPLAYER_EQ_NORMAL] = "normal",
Expand Down Expand Up @@ -305,7 +306,7 @@ static void _print_help(const char *progname)
);
}

int _sc_dfplayer(int argc, char **argv)
static int _sc_dfplayer(int argc, char **argv)
{
unsigned dev_num = 0;
int pos = 1;
Expand Down Expand Up @@ -619,3 +620,5 @@ int _sc_dfplayer(int argc, char **argv)
_print_help(argv[0]);
return 1;
}

SHELL_COMMAND(dfplayer, "Control a DFPlayer Mini MP3 player", _sc_dfplayer);
Loading

0 comments on commit fb32419

Please sign in to comment.