diff --git a/nshlib/Kconfig b/nshlib/Kconfig index 45f56be29..b60bd08ae 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -179,8 +179,8 @@ config NSH_DISABLE_CMP config NSH_DISABLE_DATE bool "Disable date" - default n - depends on RTC + default n if RTC + default y if !RTC config NSH_DISABLE_DD bool "Disable dd" diff --git a/nshlib/Makefile b/nshlib/Makefile index 9f2e504bc..69f2f0a18 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -42,7 +42,7 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_script.c CSRCS += nsh_command.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c -CSRCS += nsh_envcmds.c nsh_dbgcmds.c +CSRCS += nsh_timcmds.c nsh_envcmds.c nsh_dbgcmds.c ifeq ($(CONFIG_NFILE_STREAMS),0) CSRCS += nsh_stdsession.c @@ -69,10 +69,6 @@ CSRCS += nsh_routecmds.c endif endif -ifeq ($(CONFIG_RTC),y) -CSRCS += nsh_timcmds.c -endif - ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) CSRCS += nsh_mntcmds.c endif diff --git a/nshlib/README.txt b/nshlib/README.txt index 9da35acff..275f15185 100644 --- a/nshlib/README.txt +++ b/nshlib/README.txt @@ -343,8 +343,7 @@ o cp o date [-s "MMM DD HH:MM:SS YYYY"] - Show or set the current date and time. This command is only supported - if the platform supported RTC hardware (CONFIG_RTC=y). + Show or set the current date and time. Only one format is used both on display and when setting the date/time: MMM DD HH:MM:SS YYYY. For example, diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 4d612a490..1a544429b 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -848,7 +848,7 @@ void nsh_usbtrace(void); int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE int cmd_date(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index fa8efa9c5..edc858e09 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -140,7 +140,7 @@ static const struct cmdmap_s g_cmdmap[] = # endif #endif -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE { "date", cmd_date, 1, 3, "[-s \"MMM DD HH:MM:SS YYYY\"]" }, #endif diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 3900fc64a..06947acc7 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -240,7 +240,7 @@ static inline int ls_specialdir(const char *dir) static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, FAR struct dirent *entryp, FAR void *pvarg) { - unsigned int lsflags = (unsigned int)pvarg; + unsigned int lsflags = (unsigned int)((uintptr_t)pvarg); int ret; /* Check if any options will require that we stat the file */ @@ -995,19 +995,22 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * file */ - ret = ls_handler(vtbl, fullpath, NULL, (void*)lsflags); + ret = ls_handler(vtbl, fullpath, NULL, (FAR void *)((uintptr_t)lsflags)); } else { /* List the directory contents */ nsh_output(vtbl, "%s:\n", fullpath); - ret = foreach_direntry(vtbl, "ls", fullpath, ls_handler, (void*)lsflags); + + ret = foreach_direntry(vtbl, "ls", fullpath, ls_handler, + (FAR void*)((uintptr_t)lsflags)); if (ret == OK && (lsflags & LSFLAGS_RECURSIVE) != 0) { /* Then recurse to list each directory within the directory */ - ret = foreach_direntry(vtbl, "ls", fullpath, ls_recursive, (void*)lsflags); + ret = foreach_direntry(vtbl, "ls", fullpath, ls_recursive, + (FAR void *)((uintptr_t)lsflags)); } } diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index a7a35e8f2..e9d3aef97 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -365,7 +365,7 @@ static pthread_addr_t nsh_child(pthread_addr_t arg) dbg("BG %s complete\n", carg->argv[0]); nsh_releaseargs(carg); - return (void*)ret; + return (pthread_addr_t)((uintptr_t)ret); } #endif diff --git a/nshlib/nsh_timcmds.c b/nshlib/nsh_timcmds.c index 3fa1a06b6..992cd8ecb 100644 --- a/nshlib/nsh_timcmds.c +++ b/nshlib/nsh_timcmds.c @@ -65,7 +65,7 @@ * Private Data ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static FAR const char * const g_datemontab[] = { "jan", "feb", "mar", "apr", "may", "jun", @@ -85,7 +85,7 @@ static FAR const char * const g_datemontab[] = * Name: date_month ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_month(FAR const char *abbrev) { int i; @@ -105,7 +105,7 @@ static inline int date_month(FAR const char *abbrev) * Name: date_gettime ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name) { static const char format[] = "%b %d %H:%M:%S %Y"; @@ -139,7 +139,7 @@ static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl, FAR const char *nam * Name: date_settime ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name, FAR char *newtime) { @@ -178,6 +178,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_mday = (int)result; /* Get the hours */ @@ -193,6 +194,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_hour = (int)result; /* Get the minutes */ @@ -208,6 +210,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_min = (int)result; /* Get the seconds */ @@ -223,6 +226,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_sec = (int)result; /* And finally the year */ @@ -238,6 +242,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_year = (int)result - 1900; /* Convert this to the right form, then set the timer */ @@ -251,6 +256,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name nsh_output(vtbl, g_fmtcmdfailed, name, "clock_settime", NSH_ERRNO); return ERROR; } + return OK; errout_bad_parm: @@ -267,7 +273,7 @@ errout_bad_parm: * Name: cmd_date ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE int cmd_date(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR char *newtime = NULL;