Skip to content

Commit

Permalink
firmware/sys/shell_extended: Added Commands uniqueid
Browse files Browse the repository at this point in the history
  • Loading branch information
eduazocar committed Sep 22, 2022
1 parent dd27df5 commit f78a5f8
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 45 deletions.
9 changes: 5 additions & 4 deletions examples/shell_extended/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
APPLICATION ?= shell_extended

include ../Makefile.common
# include desired modules:
USEMODULE += radio
# include the shell:

# Include the shell extended module, shell and shell commands modules
# will be implicitly included.
USEMODULE += shell_extended
USEMODULE += xtimer
# 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**
*/
8 changes: 4 additions & 4 deletions examples/shell_extended/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
/**
* @ingroup examples_shell_extended
*
* @brief shows some uses of **shell_tools** module
* @author luisan00 <luisan00@hotmail.com>
* @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>
Expand All @@ -26,7 +26,7 @@
#include "shell_extended.h"

#define MAIN_QUEUE_SIZE (8)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
msg_t _main_msg_queue[MAIN_QUEUE_SIZE];

int main(void) {
puts("Shell extended example\n");
Expand Down
2 changes: 1 addition & 1 deletion firmware/sys/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ifneq (,$(filter shell_extended,$(USEMODULE)))
USEMODULE += shell
USEMODULE += shell_commands
endif
endif
6 changes: 3 additions & 3 deletions firmware/sys/shell_extended/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ MODULE = shell_extended

SRC += shell_extended.c

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

include $(RIOTBASE)/Makefile.base
include $(RIOTBASE)/Makefile.base
4 changes: 0 additions & 4 deletions firmware/sys/shell_extended/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
USEMODULE += shell

ifneq (,$(filter radio,$(USEMODULE)))
USEMODULE += radio
endif
2 changes: 1 addition & 1 deletion firmware/sys/shell_extended/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
USEMODULE_INCLUDES_shell_extended := $(LAST_MAKEFILEDIR)/include
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shell_extended)
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_shell_extended)
2 changes: 1 addition & 1 deletion firmware/sys/shell_extended/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
*
* ## Shell extended
* ToDo
*/
*/
3 changes: 2 additions & 1 deletion firmware/sys/shell_extended/include/shell_extended.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* @{
* @file
* @brief Extends shell functionality
* @author luisan00 <luisan00@hotmail.com>
* @author Luis A. Ruiz <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*
*/
#ifndef SHELL_EXTENDED_H
Expand Down
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;
}
11 changes: 6 additions & 5 deletions firmware/sys/shell_extended/shell_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
*/
/**
* @brief Extends functionality on the shell for uniqueid
* @author luisan00 <luisan00@hotmail.com>
* @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_RADIO)
int radio_usage(int argc, char **argv);
#if IS_USED(MODULE_UNIQUEID)
int uid_cmd(int argc, char **argv);
#endif

const shell_command_t shell_extended_commands[] = {
#if IS_USED(MODULE_RADIO)
{"radio", "shown radio command help", radio_usage},
#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.

@}

*/
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @brief Extends functionality on the shell for uniqueid
* @author luisan00 <luisan00@hotmail.com>
* @brief
*
* @author Luis A. Ruiz <luisan00@hotmail.com>
* @author Eduardo Azócar <eduazocarv@gmail.com>
*
*/

#include <stdio.h>
#include "radio.h"

int radio_usage(int argc, char **argv) {
(void) argc;
(void) argv;
puts("Low level routines for radio module");
puts("usage: uniqueid <command> [arguments]");
puts("commands:");
puts("\tiface_identify");
puts("\tget_iface");
puts("\tget_channel");
puts("\tget_power");
puts("\tset_channel [channel_number]");
puts("\tset_power [power_value]");
puts("");
return 0;
}
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 f78a5f8

Please sign in to comment.