Skip to content

Commit

Permalink
Merge pull request #350 from luisan00/feature/shell_extended
Browse files Browse the repository at this point in the history
shell extended tool: extends shell funct. to our custom modules
  • Loading branch information
luisan00 committed Sep 22, 2022
2 parents 3d21b60 + f78a5f8 commit bf7b72b
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/shell_extended/Makefile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions examples/shell_extended/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*
* ## How does it works?
*
* **ToDo**
*/
41 changes: 41 additions & 0 deletions examples/shell_extended/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*/

#include <stdio.h>
#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;
}
4 changes: 4 additions & 0 deletions firmware/sys/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ifneq (,$(filter shell_extended,$(USEMODULE)))
USEMODULE += shell
USEMODULE += shell_commands
endif
9 changes: 9 additions & 0 deletions firmware/sys/shell_extended/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MODULE = shell_extended

SRC += shell_extended.c

ifneq (,$(filter uniqueid,$(USEMODULE)))
SRC += se_uniqueid.c
endif

include $(RIOTBASE)/Makefile.base
1 change: 1 addition & 0 deletions firmware/sys/shell_extended/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USEMODULE += shell
2 changes: 2 additions & 0 deletions firmware/sys/shell_extended/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USEMODULE_INCLUDES_shell_extended := $(LAST_MAKEFILEDIR)/include
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shell_extended)
7 changes: 7 additions & 0 deletions firmware/sys/shell_extended/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @defgroup sys_shell_extended Extends shell functionality
* @ingroup sys
*
* ## Shell extended
* ToDo
*/
45 changes: 45 additions & 0 deletions firmware/sys/shell_extended/include/shell_extended.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*
*/
#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 */
/** @} */
48 changes: 48 additions & 0 deletions firmware/sys/shell_extended/se_uniqueid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*/

#include <stdio.h>
#include <string.h>
#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;
}
34 changes: 34 additions & 0 deletions firmware/sys/shell_extended/shell_extended.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*/

#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},
};
6 changes: 6 additions & 0 deletions tests/system_shell_extended/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include ../Makefile.tests_common

USEMODULE += embunit
USEMODULE += shell_extended

include $(RIOTBASE)/Makefile.include
10 changes: 10 additions & 0 deletions tests/system_shell_extended/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
@defgroup tests_shell_extended Shell-Extended unit tests
@ingroup tests
@{

## Shell Extended Tests.

@}

*/
23 changes: 23 additions & 0 deletions tests/system_shell_extended/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2022 Mesh4all <mesh4all.org>
*
* 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 <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*
*/
13 changes: 13 additions & 0 deletions tests/system_shell_extended/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit bf7b72b

Please sign in to comment.