From 014d35795528e79699c2401a2d8a80ff533944c9 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 25 Feb 2021 12:20:27 +0100 Subject: [PATCH 1/6] sys/shell: convert in_tree shell commands to XFA --- sys/include/shell_commands.h | 16 +-- sys/shell/commands/shell_commands.c | 164 ++++++++++++++-------------- sys/shell/shell.c | 15 --- 3 files changed, 84 insertions(+), 111 deletions(-) diff --git a/sys/include/shell_commands.h b/sys/include/shell_commands.h index 11dbe97a0928..a9a0f5a2f6dc 100644 --- a/sys/include/shell_commands.h +++ b/sys/include/shell_commands.h @@ -27,21 +27,7 @@ extern "C" { #endif -/** - * @name Disk manipulation command names - * @{ - */ -#define DISK_GET_SECTOR_SIZE "dget_ssize" -#define DISK_GET_SECTOR_COUNT "dget_scount" -#define DISK_GET_BLOCK_SIZE "dget_bsize" -#define DISK_READ_SECTOR_CMD "dread_sec" -#define DISK_READ_BYTES_CMD "dread" -/** @} */ - -/** - * @brief List of shell commands - */ -extern const shell_command_t _shell_command_list[]; +// nothing to see here, file is obsolete #ifdef __cplusplus } diff --git a/sys/shell/commands/shell_commands.c b/sys/shell/commands/shell_commands.c index 02aca6fd3430..54386d0dee77 100644 --- a/sys/shell/commands/shell_commands.c +++ b/sys/shell/commands/shell_commands.c @@ -16,15 +16,14 @@ * @author Oliver Hahm * @author Zakaria Kasmi * @author Ludwig Knüpfer + * @author Kaspar Schleiser * * @} */ #include -#include "shell_commands.h" -#ifdef MODULE_CONGURE_TEST -#include "congure/test.h" -#endif + +#include "shell.h" extern int _reboot_handler(int argc, char **argv); extern int _version_handler(int argc, char **argv); @@ -203,163 +202,166 @@ extern int _cryptoauth(int argc, char **argv); extern int _bootloader_handler(int argc, char **argv); #endif -const shell_command_t _shell_command_list[] = { - {"reboot", "Reboot the node", _reboot_handler}, - {"version", "Prints current RIOT_VERSION", _version_handler}, +SHELL_COMMAND(reboot, "Reboot the node", _reboot_handler); +SHELL_COMMAND(version, "Prints current RIOT_VERSION", _version_handler); #ifdef MODULE_USB_BOARD_RESET - {"bootloader", "Reboot to bootloader", _bootloader_handler}, +SHELL_COMMAND(bootloader, "Reboot to bootloader", _bootloader_handler); #endif #ifdef MODULE_CONFIG - {"id", "Gets or sets the node's id.", _id_handler}, +SHELL_COMMAND(id, "Gets or sets the node's id.", _id_handler); #endif #ifdef MODULE_HEAP_CMD - {"heap", "Prints heap statistics.", _heap_handler}, +SHELL_COMMAND(heap, "Prints heap statistics.", _heap_handler); #endif #ifdef MODULE_PERIPH_PM - { "pm", "interact with layered PM subsystem", _pm_handler }, +SHELL_COMMAND(pm, "interact with layered PM subsystem", _pm_handler); #endif #ifdef MODULE_PS - {"ps", "Prints information about running threads.", _ps_handler}, +SHELL_COMMAND(ps, "Prints information about running threads.", _ps_handler); #endif #ifdef MODULE_SHT1X - {"temp", "Prints measured temperature.", _get_temperature_handler}, - {"hum", "Prints measured humidity.", _get_humidity_handler}, - {"weather", "Prints measured humidity and temperature.", _get_weather_handler}, - {"sht-config", "Get/set SHT10/11/15 sensor configuration.", _sht_config_handler}, +SHELL_COMMAND(temp, "Prints measured temperature.", _get_temperature_handler); +SHELL_COMMAND(hum, "Prints measured humidity.", _get_humidity_handler); +SHELL_COMMAND(weather, "Prints measured humidity and temperature.", _get_weather_handler); +SHELL_COMMAND(sht_config, "Get/set SHT10/11/15 sensor configuration.", _sht_config_handler); #endif #ifdef MODULE_AT30TSE75X - {"at30tse75x", "Test AT30TSE75X temperature sensor", _at30tse75x_handler}, +SHELL_COMMAND(at30tse75x, "Test AT30TSE75X temperature sensor", _at30tse75x_handler); #endif #ifdef MODULE_MCI - {DISK_READ_SECTOR_CMD, "Reads the specified sector of inserted memory card", _read_sector}, - {DISK_READ_BYTES_CMD, "Reads the specified bytes from inserted memory card", _read_bytes}, - {DISK_GET_SECTOR_SIZE, "Get the sector size of inserted memory card", _get_sectorsize}, - {DISK_GET_SECTOR_COUNT, "Get the sector count of inserted memory card", _get_sectorcount}, - {DISK_GET_BLOCK_SIZE, "Get the block size of inserted memory card", _get_blocksize}, +SHELL_COMMAND(dread_sec, "Reads the specified sector of inserted memory card", _read_sector); +SHELL_COMMAND(dread, "Reads the specified bytes from inserted memory card", _read_bytes); +SHELL_COMMAND(dget_ssize, "Get the sector size of inserted memory card", _get_sectorsize); +SHELL_COMMAND(dget_scount, "Get the sector count of inserted memory card", _get_sectorcount); +SHELL_COMMAND(dget_bsize, "Get the block size of inserted memory card", _get_blocksize); #endif #ifdef MODULE_GNRC_ICMPV6_ECHO #ifdef MODULE_XTIMER - { "ping6", "Ping via ICMPv6", _gnrc_icmpv6_ping }, - { "ping", "Alias for ping6", _gnrc_icmpv6_ping }, +SHELL_COMMAND(ping6, "Ping via ICMPv6", _gnrc_icmpv6_ping); +SHELL_COMMAND(ping, "Alias for ping6", _gnrc_icmpv6_ping); #endif #endif #ifdef MODULE_RANDOM - { "random_init", "initializes the PRNG", _random_init }, - { "random_get", "returns 32 bit of pseudo randomness", _random_get }, +SHELL_COMMAND(random_init, "initializes the PRNG", _random_init); +SHELL_COMMAND(random_get, "returns 32 bit of pseudo randomness", _random_get); #endif #ifdef MODULE_PERIPH_RTC - {"rtc", "control RTC peripheral interface", _rtc_handler}, +SHELL_COMMAND(rtc, "control RTC peripheral interface", _rtc_handler); #endif #ifdef MODULE_RTT_CMD - {"rtt", "control RTC peripheral interface", _rtt_handler}, +SHELL_COMMAND(rtt, "control RTC peripheral interface", _rtt_handler); #endif #ifdef MODULE_GNRC_IPV6_NIB - {"nib", "Configure neighbor information base", _gnrc_ipv6_nib}, +SHELL_COMMAND(nib, "Configure neighbor information base", _gnrc_ipv6_nib); #endif #ifdef MODULE_NETSTATS_NEIGHBOR - {"neigh", "Show neighbor statistics", _netstats_nb}, +SHELL_COMMAND(neigh, "Show neighbor statistics", _netstats_nb); #endif #ifdef MODULE_GNRC_NETIF - {"ifconfig", "Configure network interfaces", _gnrc_netif_config}, +SHELL_COMMAND(ifconfig, "Configure network interfaces", _gnrc_netif_config); #ifdef MODULE_GNRC_TXTSND - {"txtsnd", "Sends a custom string as is over the link layer", _gnrc_netif_send }, +SHELL_COMMAND(txtsnd, "Sends a custom string as is over the link layer", _gnrc_netif_send); #endif #endif #ifdef MODULE_OPENWSN - {"ifconfig", "Shows assigned IPv6 addresses", _openwsn_ifconfig}, - {"openwsn", "OpenWSN commands", _openwsn_handler}, +SHELL_COMMAND(ifconfig, "Shows assigned IPv6 addresses", _openwsn_ifconfig); +SHELL_COMMAND(openwsn, "OpenWSN commands", _openwsn_handler); #endif #ifdef MODULE_LWIP_NETIF - {"ifconfig", "List network interfaces", _lwip_netif_config}, +SHELL_COMMAND(ifconfig, "List network interfaces", _lwip_netif_config); #endif #ifdef MODULE_FIB - {"fibroute", "Manipulate the FIB (info: 'fibroute [add|del]')", _fib_route_handler}, +SHELL_COMMAND(fibroute, "Manipulate the FIB (info: 'fibroute [add|del]')", _fib_route_handler); #endif #ifdef MODULE_GNRC_IPV6_EXT_FRAG_STATS - {"ip6_frag", "IPv6 fragmentation statistics", _gnrc_ipv6_frag_stats }, +SHELL_COMMAND(ip6_frag, "IPv6 fragmentation statistics", _gnrc_ipv6_frag_stats); #endif #ifdef MODULE_GNRC_IPV6_WHITELIST - {"whitelist", "whitelists an address for receival ('whitelist [add|del|help]')", _whitelist }, +SHELL_COMMAND(whitelist, "whitelists an address for receival ('whitelist [add|del|help]')", _whitelist); #endif #ifdef MODULE_GNRC_IPV6_BLACKLIST - {"blacklist", "blacklists an address for receival ('blacklist [add|del|help]')", _blacklist }, +SHELL_COMMAND(blacklist, "blacklists an address for receival ('blacklist [add|del|help]')", _blacklist); #endif #ifdef MODULE_GNRC_PKTBUF_CMD - {"pktbuf", "prints internal stats of the packet buffer", _gnrc_pktbuf_cmd }, +SHELL_COMMAND(pktbuf, "prints internal stats of the packet buffer", _gnrc_pktbuf_cmd); #endif #ifdef MODULE_GNRC_RPL - {"rpl", "rpl configuration tool ('rpl help' for more information)", _gnrc_rpl }, +SHELL_COMMAND(rpl, "rpl configuration tool ('rpl help' for more information)", _gnrc_rpl); #endif #ifdef MODULE_GNRC_SIXLOWPAN_CTX - {"6ctx", "6LoWPAN context configuration tool", _gnrc_6ctx }, +SHELL_COMMAND(6ctx, "6LoWPAN context configuration tool", _gnrc_6ctx); #endif #ifdef MODULE_GNRC_SIXLOWPAN_FRAG_STATS - {"6lo_frag", "6LoWPAN fragment statistics", _gnrc_6lo_frag_stats }, +SHELL_COMMAND(6lo_frag, "6LoWPAN fragment statistics", _gnrc_6lo_frag_stats); #endif #ifdef MODULE_SAUL_REG - {"saul", "interact with sensors and actuators using SAUL", _saul }, +SHELL_COMMAND(saul, "interact with sensors and actuators using SAUL", _saul); #endif #ifdef MODULE_CCN_LITE_UTILS - { "ccnl_open", "opens an interface or socket", _ccnl_open }, - { "ccnl_int", "sends an interest", _ccnl_interest }, - { "ccnl_cs", "shows CS or creates content and populates it", _ccnl_content }, - { "ccnl_fib", "shows or modifies the CCN-Lite FIB", _ccnl_fib }, +SHELL_COMMAND(ccnl_open, "opens an interface or socket", _ccnl_open); +SHELL_COMMAND(ccnl_int, "sends an interest", _ccnl_interest); +SHELL_COMMAND(ccnl_cs, "shows CS or creates content and populates it", _ccnl_content); +SHELL_COMMAND(ccnl_fib, "shows or modifies the CCN-Lite FIB", _ccnl_fib); #endif #ifdef MODULE_SNTP - { "ntpdate", "synchronizes with a remote time server", _ntpdate }, +SHELL_COMMAND(ntpdate, "synchronizes with a remote time server", _ntpdate); #endif #ifdef MODULE_VFS - {"vfs", "virtual file system operations", _vfs_handler}, - {"ls", "list files", _ls_handler}, +SHELL_COMMAND(vfs, "virtual file system operations", _vfs_handler); +SHELL_COMMAND(ls, "list files", _ls_handler); #endif #ifdef MODULE_CONN_CAN - {"can", "CAN commands", _can_handler}, +SHELL_COMMAND(can, "CAN commands", _can_handler); #endif #ifdef MODULE_CORD_EP - {"cord_ep", "Resource directory endpoint commands", _cord_ep_handler }, +SHELL_COMMAND(cord_ep, "Resource directory endpoint commands", _cord_ep_handler); #endif #ifdef MODULE_APP_METADATA - {"app_metadata", "Returns application metadata", _app_metadata_handler }, +SHELL_COMMAND(app_metadata, "Returns application metadata", _app_metadata_handler); #endif #ifdef MODULE_I2C_SCAN - { "i2c_scan", "Performs an I2C bus scan", _i2c_scan }, +SHELL_COMMAND(i2c_scan, "Performs an I2C bus scan", _i2c_scan); #endif #ifdef MODULE_SEMTECH_LORAMAC - {"loramac", "Control Semtech loramac stack", _loramac_handler}, +SHELL_COMMAND(loramac, "Control Semtech loramac stack", _loramac_handler); #endif #ifdef MODULE_NIMBLE_NETIF - { "ble", "Manage BLE connections for NimBLE", _nimble_netif_handler }, +SHELL_COMMAND(ble, "Manage BLE connections for NimBLE", _nimble_netif_handler); #endif #ifdef MODULE_NIMBLE_STATCONN - { "statconn", "NimBLE netif statconn", _nimble_statconn_handler}, +SHELL_COMMAND(statconn, "NimBLE netif statconn", _nimble_statconn_handler); #endif #ifdef MODULE_SUIT_TRANSPORT_COAP - { "suit", "Trigger a SUIT firmware update", _suit_handler }, +SHELL_COMMAND(suit, "Trigger a SUIT firmware update", _suit_handler); #endif #ifdef MODULE_CRYPTOAUTHLIB - { "cryptoauth", "Commands for Microchip CryptoAuth devices", _cryptoauth }, +SHELL_COMMAND(cryptoauth, "Commands for Microchip CryptoAuth devices", _cryptoauth); #endif #ifdef MODULE_DFPLAYER - {"dfplayer", "Control a DFPlayer Mini MP3 player", _sc_dfplayer}, +SHELL_COMMAND(dfplayer, "Control a DFPlayer Mini MP3 player", _sc_dfplayer); #endif + #ifdef MODULE_CONGURE_TEST - { "cong_clear", "Clears CongURE state object", congure_test_clear_state }, - { "cong_setup", "Calls the setup function for the CongURE state object", - congure_test_call_setup }, - { "cong_init", "Calls init method of the CongURE state object", - congure_test_call_init }, - { "cong_imi", "Calls inter_message_interval method of the CongURE state object", - congure_test_call_inter_msg_interval }, - { "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 }, - { "cong_msgs_reset", - "Resets the list of messages to be reported with report_msgs_lost or " - "report_msgs_timeout", - congure_test_msgs_reset }, - { "cong_report", "Calls a report_* method of the CongURE state object", - congure_test_call_report }, -#endif - {NULL, NULL, NULL} -}; +#include "congure/test.h" +SHELL_COMMAND(cong_clear, "Clears CongURE state object", + congure_test_clear_state); +SHELL_COMMAND(cong_setup, + "Calls the setup function for the CongURE state object", + congure_test_call_setup); +SHELL_COMMAND(cong_init, "Calls init method of the CongURE state object", + congure_test_call_init); +SHELL_COMMAND(cong_imi, + "Calls inter_message_interval method of the CongURE state object", + congure_test_call_inter_msg_interval); +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); +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); +SHELL_COMMAND(cong_report, + "Calls a report_* method of the CongURE state object", + congure_test_call_report); +#endif diff --git a/sys/shell/shell.c b/sys/shell/shell.c index 45bbcc2784bf..0730f8b1e963 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -38,7 +38,6 @@ #include "kernel_defines.h" #include "xfa.h" #include "shell.h" -#include "shell_commands.h" /* define shell command cross file array */ XFA_INIT_CONST(shell_command_t*, shell_commands_xfa); @@ -54,12 +53,6 @@ XFA_INIT_CONST(shell_command_t*, shell_commands_xfa); #define flush_if_needed() #endif /* MODULE_NEWLIB || MODULE_PICOLIBC */ -#ifdef MODULE_SHELL_COMMANDS - #define _builtin_cmds _shell_command_list -#else - #define _builtin_cmds NULL -#endif - #define SQUOTE '\'' #define DQUOTE '"' #define ESCAPECHAR '\\' @@ -117,10 +110,6 @@ static shell_command_handler_t find_handler( handler = search_commands(command_list, command); } - if (handler == NULL && _builtin_cmds != NULL) { - handler = search_commands(_builtin_cmds, command); - } - if (handler == NULL) { handler = search_commands_xfa(command); } @@ -152,10 +141,6 @@ static void print_help(const shell_command_t *command_list) print_commands(command_list); } - if (_builtin_cmds != NULL) { - print_commands(_builtin_cmds); - } - print_commands_xfa(); } From 50de138133d644d54bbfd7017122744889e8fbe5 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 25 Feb 2021 14:50:49 +0100 Subject: [PATCH 2/6] Revert "tests/periph_spi_dma: blacklist samd10-xmini" This reverts commit d9cda53554e0b16828448f0497d0d475d70264aa. --- tests/periph_spi_dma/Makefile.ci | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/periph_spi_dma/Makefile.ci b/tests/periph_spi_dma/Makefile.ci index d0a370493e36..9a9f98fad960 100644 --- a/tests/periph_spi_dma/Makefile.ci +++ b/tests/periph_spi_dma/Makefile.ci @@ -2,5 +2,4 @@ # this test. include ../periph_spi/Makefile.ci BOARD_INSUFFICIENT_MEMORY += \ - samd10-xmini \ # From 82b2c16aabf153c0ff62c245515c378493ea7d45 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 2 Mar 2021 17:50:39 +0100 Subject: [PATCH 3/6] tests/ps_schedstatistics: fix command order in shell help test --- tests/ps_schedstatistics/tests/01-run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ps_schedstatistics/tests/01-run.py b/tests/ps_schedstatistics/tests/01-run.py index beabbfd2bb2d..157d5dd8cb02 100755 --- a/tests/ps_schedstatistics/tests/01-run.py +++ b/tests/ps_schedstatistics/tests/01-run.py @@ -44,9 +44,9 @@ def _check_help(child): child.sendline('help') child.expect_exact('Command Description') child.expect_exact('---------------------------------------') - child.expect_exact('reboot Reboot the node') child.expect_exact('ps Prints information about ' 'running threads.') + child.expect_exact('reboot Reboot the node') def _check_ps(child): From 6bd38b1fd8d81e2be5440513a2074be9274e373e Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 2 Mar 2021 17:52:35 +0100 Subject: [PATCH 4/6] tests/shell: fix expected command order in test --- tests/shell/tests/01-run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/shell/tests/01-run.py b/tests/shell/tests/01-run.py index a4b423ad8db1..03f44e13f6bd 100755 --- a/tests/shell/tests/01-run.py +++ b/tests/shell/tests/01-run.py @@ -17,9 +17,9 @@ 'start_test starts a test', 'end_test ends a test', 'echo prints the input command', - 'reboot Reboot the node', - 'ps Prints information about running threads.', 'app_metadata Returns application metadata', + 'ps Prints information about running threads.', + 'reboot Reboot the node', 'xfa_test1 xfa test command 1', 'xfa_test2 xfa test command 2' ) From cb25c8d2044105315f297a8ea927174bbcd604ad Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 2 Mar 2021 17:55:26 +0100 Subject: [PATCH 5/6] tests/pkg_microcoap: memory blacklist atmega1284p --- tests/pkg_microcoap/Makefile.ci | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pkg_microcoap/Makefile.ci b/tests/pkg_microcoap/Makefile.ci index a9d30bd77de9..ec4a102dfa2d 100644 --- a/tests/pkg_microcoap/Makefile.ci +++ b/tests/pkg_microcoap/Makefile.ci @@ -5,6 +5,7 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-nano \ arduino-uno \ atmega328p \ + atmega1284p \ bluepill-stm32f030c8 \ derfmega128 \ i-nucleo-lrwan1 \ From 9d6738cdee7bd6920cd25927e1ce86b83c546fae Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 11 Mar 2021 11:24:02 +0100 Subject: [PATCH 6/6] tests/pkg_microcoap: memory-blacklist mega-xplained --- tests/pkg_microcoap/Makefile.ci | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pkg_microcoap/Makefile.ci b/tests/pkg_microcoap/Makefile.ci index ec4a102dfa2d..9ba71d7c6b79 100644 --- a/tests/pkg_microcoap/Makefile.ci +++ b/tests/pkg_microcoap/Makefile.ci @@ -9,6 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := \ bluepill-stm32f030c8 \ derfmega128 \ i-nucleo-lrwan1 \ + mega-xplained \ microduino-corerf \ msb-430 \ msb-430h \