This is an automated email from the ASF dual-hosted git repository. vipulrahane pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push: new a59bd54 sys/config, date CLIs: add syscfgs for read/write (#1709) a59bd54 is described below commit a59bd540c5a1f2c0ce9bf46592f6f5286d1690c2 Author: Vipul Rahane <vrah...@gmail.com> AuthorDate: Wed Mar 27 13:07:19 2019 -0700 sys/config, date CLIs: add syscfgs for read/write (#1709) * sys/config, date CLIs: add syscfgs for read/write --- sys/config/src/config_cli.c | 36 ++++++++++++++++++++++++------------ sys/config/syscfg.yml | 4 ++++ sys/shell/src/shell_os.c | 14 ++++++++++++-- sys/shell/syscfg.yml | 6 ++++++ 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c index 7c97556..582da55 100644 --- a/sys/config/src/config_cli.c +++ b/sys/config/src/config_cli.c @@ -37,6 +37,7 @@ static struct shell_cmd shell_conf_cmd = { .sc_cmd_func = shell_conf_command }; +#if (MYNEWT_VAL(CONFIG_CLI_RW) & 1) == 1 static void conf_running_one(char *name, char *val) { @@ -56,6 +57,7 @@ conf_dump_running(void) } conf_unlock(); } +#endif #if MYNEWT_VAL(CONFIG_CLI_DEBUG) static void @@ -84,23 +86,28 @@ conf_dump_saved(void) static int shell_conf_command(int argc, char **argv) { +#if MYNEWT_VAL(CONFIG_CLI_RW) char *name = NULL; char *val = NULL; char tmp_buf[CONF_MAX_VAL_LEN + 1]; int rc; + (void)rc; switch (argc) { +#if (MYNEWT_VAL(CONFIG_CLI_RW) & 1) == 1 case 2: name = argv[1]; break; +#endif +#if (MYNEWT_VAL(CONFIG_CLI_RW) & 2) == 2 case 3: name = argv[1]; val = argv[2]; break; +#endif default: goto err; } - if (!strcmp(name, "commit")) { rc = conf_commit(val); if (rc) { @@ -110,19 +117,23 @@ shell_conf_command(int argc, char **argv) } console_printf("%s", val); return 0; - } else if (!strcmp(name, "dump")) { - if (!val || !strcmp(val, "running")) { - conf_dump_running(); - } + } else { + if (!strcmp(name, "dump")) { + if (!val || !strcmp(val, "running")) { + conf_dump_running(); + } #if MYNEWT_VAL(CONFIG_CLI_DEBUG) - if (val && !strcmp(val, "saved")) { - conf_dump_saved(); - } + if (val && !strcmp(val, "saved")) { + conf_dump_saved(); + } #endif - return 0; - } else if (!strcmp(name, "save")) { - conf_save(); - return 0; + return 0; + } else { + if (!strcmp(name, "save")) { + conf_save(); + return 0; + } + } } if (!val) { val = conf_get_value(name, tmp_buf, sizeof(tmp_buf)); @@ -140,6 +151,7 @@ shell_conf_command(int argc, char **argv) } return 0; err: +#endif console_printf("Invalid args\n"); return 0; } diff --git a/sys/config/syscfg.yml b/sys/config/syscfg.yml index 9a8d58d..b3995f7 100644 --- a/sys/config/syscfg.yml +++ b/sys/config/syscfg.yml @@ -58,6 +58,10 @@ syscfg.defs: Secondary sysinit stage for the config package; populates the underlying storage medium for config if it is has not been done. value: 220 + CONFIG_CLI_RW: + description: > + Config CLI commands read 1, write 2, read/write 3 + value: 3 syscfg.defs.CONFIG_FCB: CONFIG_FCB_FLASH_AREA: diff --git a/sys/shell/src/shell_os.c b/sys/shell/src/shell_os.c index 3c325f8..a4d0cdf 100644 --- a/sys/shell/src/shell_os.c +++ b/sys/shell/src/shell_os.c @@ -130,21 +130,26 @@ shell_os_mpool_display_cmd(int argc, char **argv) int shell_os_date_cmd(int argc, char **argv) { + int rc; +#if MYNEWT_VAL(SHELL_OS_DATETIME_CMD) struct os_timeval tv; struct os_timezone tz; char buf[DATETIME_BUFSIZE]; - int rc; argc--; argv++; /* skip command name */ + rc = -1; if (argc == 0) { +#if (MYNEWT_VAL(SHELL_OS_DATETIME_CMD) & 1) == 1 /* Display the current datetime */ rc = os_gettimeofday(&tv, &tz); assert(rc == 0); rc = datetime_format(&tv, &tz, buf, sizeof(buf)); assert(rc == 0); console_printf("%s\n", buf); +#endif } else if (argc == 1) { +#if (MYNEWT_VAL(SHELL_OS_DATETIME_CMD) & 2) == 2 /* Set the current datetime */ rc = datetime_parse(*argv, &tv, &tz); if (rc == 0) { @@ -152,10 +157,11 @@ shell_os_date_cmd(int argc, char **argv) } else { console_printf("Invalid datetime\n"); } +#endif } else { rc = -1; } - +#endif return rc; } @@ -213,15 +219,19 @@ static const struct shell_cmd_help mpool_help = { .params = mpool_params, }; +#if (MYNEWT_VAL(SHELL_OS_DATETIME_CMD) & 2) == 2 static const struct shell_param date_params[] = { {"", "datetime to set"}, {NULL, NULL} }; +#endif static const struct shell_cmd_help date_help = { .summary = "show system date", .usage = NULL, +#if (MYNEWT_VAL(SHELL_OS_DATETIME_CMD) & 2) == 2 .params = date_params, +#endif }; static const struct shell_param reset_params[] = { diff --git a/sys/shell/syscfg.yml b/sys/shell/syscfg.yml index ecc8b67..1f416bc 100644 --- a/sys/shell/syscfg.yml +++ b/sys/shell/syscfg.yml @@ -68,6 +68,12 @@ syscfg.defs: Sysinit stage for shell functionality. value: 500 + SHELL_OS_DATETIME_CMD: + description: > + Datetime command enabled, read 1, + write 2, read/write 3 (default) + value: 3 + ## duplicated from boot/boot_serial BOOT_SERIAL_NVREG_MAGIC: description: >