|
| 1 | +/* |
| 2 | + * Copyright (c) 2015 Intel Corporation |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#include <zephyr.h> |
| 8 | +#include <sys/printk.h> |
| 9 | +#include <shell/shell.h> |
| 10 | +#include <version.h> |
| 11 | +#include <logging/log.h> |
| 12 | +#include <stdlib.h> |
| 13 | + |
| 14 | +LOG_MODULE_REGISTER(app); |
| 15 | + |
| 16 | +static int cmd_demo_params(const struct shell *shell, size_t argc, char **argv) |
| 17 | +{ |
| 18 | + shell_print(shell, "argc = %d", argc); |
| 19 | + for (size_t cnt = 0; cnt < argc; cnt++) { |
| 20 | + shell_print(shell, " argv[%d] = %s", cnt, argv[cnt]); |
| 21 | + } |
| 22 | + |
| 23 | + return 0; |
| 24 | +} |
| 25 | + |
| 26 | +static int cmd_demo_hexdump(const struct shell *shell, size_t argc, char **argv) |
| 27 | +{ |
| 28 | + shell_print(shell, "argc = %d", argc); |
| 29 | + for (size_t cnt = 0; cnt < argc; cnt++) { |
| 30 | + shell_print(shell, "argv[%d]", cnt); |
| 31 | + shell_hexdump(shell, argv[cnt], strlen(argv[cnt])); |
| 32 | + } |
| 33 | + |
| 34 | + return 0; |
| 35 | +} |
| 36 | + |
| 37 | +static int cmd_version(const struct shell *shell, size_t argc, char **argv) |
| 38 | +{ |
| 39 | + ARG_UNUSED(argc); |
| 40 | + ARG_UNUSED(argv); |
| 41 | + |
| 42 | + shell_print(shell, "Zephyr Version: %s", KERNEL_VERSION_STRING); |
| 43 | + shell_print(shell, "Build Date: %s, %s\n", __DATE__, __TIME__); |
| 44 | + |
| 45 | + return 0; |
| 46 | +} |
| 47 | + |
| 48 | +SHELL_STATIC_SUBCMD_SET_CREATE(utils, |
| 49 | + SHELL_CMD(hexdump, NULL, "Hexdump params command.", cmd_demo_hexdump), |
| 50 | + SHELL_CMD(params, NULL, "Print params command.", cmd_demo_params), |
| 51 | + SHELL_SUBCMD_SET_END /* Array terminated. */ |
| 52 | +); |
| 53 | +SHELL_CMD_REGISTER(utilities, &utils, "Handy Utilities", NULL); |
| 54 | + |
| 55 | +SHELL_CMD_ARG_REGISTER(version, NULL, "Show kernel version", cmd_version, 1, 0); |
| 56 | + |
| 57 | +void main(void) |
| 58 | +{ |
| 59 | + |
| 60 | +} |
0 commit comments