diff --git a/examples/shell_extended/Makefile b/examples/shell_extended/Makefile new file mode 100644 index 000000000..8b146f979 --- /dev/null +++ b/examples/shell_extended/Makefile @@ -0,0 +1,11 @@ +APPLICATION ?= shell_extended + +include ../Makefile.common + +# Include the shell extended module, shell and shell commands modules +# will be implicitly included. +USEMODULE += shell_extended +# Include desired modules where shell extended is enabled. +USEMODULE += uniqueid + +include $(RIOTBASE)/Makefile.include diff --git a/examples/shell_extended/doc.txt b/examples/shell_extended/doc.txt new file mode 100644 index 000000000..2e6385a24 --- /dev/null +++ b/examples/shell_extended/doc.txt @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2022 Mesh4all + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @defgroup examples_shell_extended Application example for the shell extended module + * @ingroup examples + * @author Luis A. Ruiz + * @author Eduardo Azócar + * + * ## How does it works? + * + * **ToDo** + */ \ No newline at end of file diff --git a/examples/shell_extended/main.c b/examples/shell_extended/main.c new file mode 100644 index 000000000..484250b62 --- /dev/null +++ b/examples/shell_extended/main.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Mesh4all + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @ingroup examples_shell_extended + * @brief shows some uses of **shell-extended** module + * @author Luis A. Ruiz + * @author Eduardo Azócar + */ + +#include +#include "shell.h" +#include "msg.h" +#include "shell_extended.h" + +#define MAIN_QUEUE_SIZE (8) +msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; + +int main(void) { + puts("Shell extended example\n"); + + msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); + + /* start the shell */ + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(shell_extended_commands, line_buf, SHELL_DEFAULT_BUFSIZE); + + return 0; +} diff --git a/firmware/sys/Makefile.dep b/firmware/sys/Makefile.dep index e69de29bb..d593d7687 100644 --- a/firmware/sys/Makefile.dep +++ b/firmware/sys/Makefile.dep @@ -0,0 +1,4 @@ +ifneq (,$(filter shell_extended,$(USEMODULE))) + USEMODULE += shell + USEMODULE += shell_commands +endif diff --git a/firmware/sys/shell_extended/Makefile b/firmware/sys/shell_extended/Makefile new file mode 100644 index 000000000..baa9472a8 --- /dev/null +++ b/firmware/sys/shell_extended/Makefile @@ -0,0 +1,9 @@ +MODULE = shell_extended + +SRC += shell_extended.c + +ifneq (,$(filter uniqueid,$(USEMODULE))) + SRC += se_uniqueid.c +endif + +include $(RIOTBASE)/Makefile.base diff --git a/firmware/sys/shell_extended/Makefile.dep b/firmware/sys/shell_extended/Makefile.dep new file mode 100644 index 000000000..46f0ad313 --- /dev/null +++ b/firmware/sys/shell_extended/Makefile.dep @@ -0,0 +1 @@ +USEMODULE += shell diff --git a/firmware/sys/shell_extended/Makefile.include b/firmware/sys/shell_extended/Makefile.include new file mode 100644 index 000000000..380f7c95a --- /dev/null +++ b/firmware/sys/shell_extended/Makefile.include @@ -0,0 +1,2 @@ +USEMODULE_INCLUDES_shell_extended := $(LAST_MAKEFILEDIR)/include +USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shell_extended) diff --git a/firmware/sys/shell_extended/doc.txt b/firmware/sys/shell_extended/doc.txt new file mode 100644 index 000000000..f880d3409 --- /dev/null +++ b/firmware/sys/shell_extended/doc.txt @@ -0,0 +1,7 @@ +/** + * @defgroup sys_shell_extended Extends shell functionality + * @ingroup sys + * + * ## Shell extended + * ToDo + */ diff --git a/firmware/sys/shell_extended/include/shell_extended.h b/firmware/sys/shell_extended/include/shell_extended.h new file mode 100644 index 000000000..9beee4ed2 --- /dev/null +++ b/firmware/sys/shell_extended/include/shell_extended.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Mesh4all + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @ingroup sys_shell_extended + * @{ + * @file + * @brief Extends shell functionality + * @author Luis A. Ruiz + * @author Eduardo Azócar + * + */ +#ifndef SHELL_EXTENDED_H +#define SHELL_EXTENDED_H + +#include "shell.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief Shell extended command array + */ +extern const shell_command_t shell_extended_commands[]; + +#ifdef __cplusplus +} +#endif +#endif /* SHELL_EXTENDED_H */ +/** @} */ diff --git a/firmware/sys/shell_extended/se_uniqueid.c b/firmware/sys/shell_extended/se_uniqueid.c new file mode 100644 index 000000000..bcc59d69b --- /dev/null +++ b/firmware/sys/shell_extended/se_uniqueid.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Mesh4all + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @brief Extends the shell functionality for uniqueid + * @author Luis A. Ruiz + * @author Eduardo Azócar + */ + +#include +#include +#include "uniqueid.h" + +void uid_usage(void) { + puts("Uniqueid Tool"); + puts("Usage: uid [static|rand]"); + puts(""); +} + +int uid_cmd(int argc, char **argv) { + (void)argc; + (void)argv; + + if ((argc < 2) || (argc > 2) || (strcmp(argv[1], "help") == 0)) { + uid_usage(); + return 0; + } + + if (strcmp(argv[1], "static") == 0) { + puts("ToDo: return static id (cpu-based)"); + } else if (strcmp(argv[1], "random") == 0) { + puts("Todo: return random id"); + } + + return 0; +} diff --git a/firmware/sys/shell_extended/shell_extended.c b/firmware/sys/shell_extended/shell_extended.c new file mode 100644 index 000000000..cb4e872b9 --- /dev/null +++ b/firmware/sys/shell_extended/shell_extended.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Mesh4all + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @brief Extends functionality on the shell for uniqueid + * @author Luis A. Ruiz + * @author Eduardo Azócar + */ + +#include "shell_extended.h" +#include "kernel_defines.h" + +#if IS_USED(MODULE_UNIQUEID) +int uid_cmd(int argc, char **argv); +#endif + +const shell_command_t shell_extended_commands[] = { +#if IS_USED(MODULE_UNIQUEID) + {"uid", "uniqueid commands", uid_cmd}, +#endif + {NULL, NULL, NULL}, +}; diff --git a/tests/system_shell_extended/Makefile b/tests/system_shell_extended/Makefile new file mode 100644 index 000000000..415ff8f3e --- /dev/null +++ b/tests/system_shell_extended/Makefile @@ -0,0 +1,6 @@ +include ../Makefile.tests_common + +USEMODULE += embunit +USEMODULE += shell_extended + +include $(RIOTBASE)/Makefile.include diff --git a/tests/system_shell_extended/doc.txt b/tests/system_shell_extended/doc.txt new file mode 100644 index 000000000..805eb3ea3 --- /dev/null +++ b/tests/system_shell_extended/doc.txt @@ -0,0 +1,10 @@ +/** +@defgroup tests_shell_extended Shell-Extended unit tests +@ingroup tests +@{ + +## Shell Extended Tests. + +@} + + */ diff --git a/tests/system_shell_extended/main.c b/tests/system_shell_extended/main.c new file mode 100644 index 000000000..9d1f337da --- /dev/null +++ b/tests/system_shell_extended/main.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Mesh4all + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @brief + * + * @author Luis A. Ruiz + * @author Eduardo Azócar + * + */ diff --git a/tests/system_shell_extended/tests/01-run.py b/tests/system_shell_extended/tests/01-run.py new file mode 100755 index 000000000..bccd6a160 --- /dev/null +++ b/tests/system_shell_extended/tests/01-run.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2017 Freie Universität Berlin +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import sys +from testrunner import run_check_unittests + +if __name__ == "__main__": + sys.exit(run_check_unittests())