diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-11 23:07:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-11 23:07:26 +0000 |
commit | 258b47ea9b8686f71788ac804c9be909815f6934 (patch) | |
tree | acd4ae9a714326c741d43e34c9ccc2df26242daf /nuttx/examples | |
parent | 2ca9507eddbf4ae56a45983c551a84d37cd6db05 (diff) | |
download | px4-nuttx-258b47ea9b8686f71788ac804c9be909815f6934.tar.gz px4-nuttx-258b47ea9b8686f71788ac804c9be909815f6934.tar.bz2 px4-nuttx-258b47ea9b8686f71788ac804c9be909815f6934.zip |
Clean configuration varialbe names
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@816 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r-- | nuttx/examples/README.txt | 7 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh.h | 15 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_fscmds.c | 22 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_main.c | 5 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_serial.c | 7 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_telnetd.c | 4 |
6 files changed, 33 insertions, 27 deletions
diff --git a/nuttx/examples/README.txt b/nuttx/examples/README.txt index 3b09768d5..07a3f9d54 100644 --- a/nuttx/examples/README.txt +++ b/nuttx/examples/README.txt @@ -57,14 +57,17 @@ examples/nsh Other behavior of NSH can be modified with the following settings in the configs/<board-name>/defconfig file: - * CONFIG_NSH_IOBUFFERSIZE + * CONFIG_EXAMPLES_NSH_FILEIOSIZE Size of a static I/O buffer used for file access (ignored if there is no filesystem). - * CONFIG_NSH_STRERROR + * CONFIG_EXAMPLES_NSH_STRERROR strerror(errno) makes more readable output but strerror() is very large and will not be used unless this setting is 'y' + * CONFIG_EXAMPLES_NSH_LINELEN + The maximum length of one command line. Default: 80 + * CONFIG_EXAMPLES_NSH_TELNET By default, NSH is configured to use the serial console. If CONFIG_EXAMPLES_NSH_TELNET is set to 'y', then a TELENET diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h index 3a8948b2a..a4b9c4160 100644 --- a/nuttx/examples/nsh/nsh.h +++ b/nuttx/examples/nsh/nsh.h @@ -55,15 +55,21 @@ #define NSH_MAX_ARGUMENTS 6 /* strerror() produces much nicer output but is, however, quite large and - * will only be used if CONFIG_NSH_STRERROR is defined. + * will only be used if CONFIG_EXAMPLES_NSH_STRERROR is defined. */ -#ifdef CONFIG_NSH_STRERROR +#ifdef CONFIG_EXAMPLES_NSH_STRERROR # define NSH_ERRNO strerror(errno) #else # define NSH_ERRNO errno #endif +/* Maximum size of one command line (telnet or serial) */ + +#ifndef CONFIG_EXAMPLES_NSH_LINELEN +# define CONFIG_EXAMPLES_NSH_LINELEN 80 +#endif + /* The following two settings are used only in the telnetd interface */ #ifndef CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE @@ -85,10 +91,7 @@ /* Define to enable dumping of all input/output buffers */ #undef CONFIG_EXAMPLES_NSH_TELNETD_DUMPBUFFER - -/* Sizing */ - -#define NSH_MAX_LINELEN 80 +#undef CONFIG_EXAMPLES_NSH_FULLPATH /**************************************************************************** * Public Types diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c index 45426604f..2cfb24098 100644 --- a/nuttx/examples/nsh/nsh_fscmds.c +++ b/nuttx/examples/nsh/nsh_fscmds.c @@ -76,14 +76,14 @@ */ #if CONFIG_NFILE_DESCRIPTORS > 0 -# ifdef CONFIG_NSH_IOBUFFERSIZE -# if CONFIG_NSH_IOBUFFERSIZE > (PATH_MAX + 1) -# define IOBUFFERSIZE CONFIG_NSH_IOBUFFERSIZE +# ifdef CONFIG_EXAMPLES_NSH_FILEIOSIZE +# if CONFIG_EXAMPLES_NSH_FILEIOSIZE > (PATH_MAX + 1) +# define IOBUFFERSIZE CONFIG_EXAMPLES_NSH_FILEIOSIZE # else # define IOBUFFERSIZE (PATH_MAX + 1) # endif # else -# define IOBUFFERSIZE 1024 +# define IOBUFFERSIZE 1024 # endif # else # define IOBUFFERSIZE (PATH_MAX + 1) @@ -103,6 +103,12 @@ typedef int (*direntry_handler_t)(FAR void *, const char *, struct dirent *, voi * Private Data ****************************************************************************/ +/* Common buffer for file I/O. Note the use of this common buffer precludes + * multiple copies of NSH running concurrently. It should be allocated per + * NSH instance and retained in the "handle" as is done for the telnet + * connection. + */ + static char g_iobuffer[IOBUFFERSIZE]; /**************************************************************************** @@ -163,7 +169,7 @@ static int foreach_direntry(FAR void *handle, const char *cmd, const char *dirpa /* Trim trailing '/' from directory names */ -#ifdef CONFIG_FULL_PATH +#ifdef CONFIG_EXAMPLES_NSH_FULLPATH trim_dir(arg); #endif @@ -306,7 +312,7 @@ static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entr /* then provide the filename that is common to normal and verbose output */ -#ifdef CONFIG_FULL_PATH +#ifdef CONFIG_EXAMPLES_NSH_FULLPATH nsh_output(handle, " %s/%s", arg, entryp->d_name); #else nsh_output(handle, " %s", entryp->d_name); @@ -365,7 +371,7 @@ static int ls_recursive(FAR void *handle, const char *dirpath, struct dirent *en #if CONFIG_NFILE_DESCRIPTORS > 0 void cmd_cat(FAR void *handle, int argc, char **argv) { - char buffer[1024]; + char buffer[IOBUFFERSIZE]; /* Open the file for reading */ @@ -380,7 +386,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv) for (;;) { - int nbytesread = read(fd, buffer, 1024); + int nbytesread = read(fd, buffer, IOBUFFERSIZE); /* Check for read errors */ diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index b240df2e1..4f6b62454 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -52,9 +52,6 @@ * Definitions ****************************************************************************/ -#define CONFIG_NSH_LINE_SIZE 80 -#undef CONFIG_FULL_PATH - /**************************************************************************** * Private Types ****************************************************************************/ @@ -147,7 +144,7 @@ const char g_fmtcmdnotfound[] = "nsh: %s: command not found\n"; const char g_fmtcmdnotimpl[] = "nsh: %s: command not implemented\n"; const char g_fmtnosuch[] = "nsh: %s: no such %s: %s\n"; const char g_fmttoomanyargs[] = "nsh: %s: too many arguments\n"; -#ifdef CONFIG_NSH_STRERROR +#ifdef CONFIG_EXAMPLES_NSH_STRERROR const char g_fmtcmdfailed[] = "nsh: %s: %s failed: %s\n"; #else const char g_fmtcmdfailed[] = "nsh: %s: %s failed: %d\n"; diff --git a/nuttx/examples/nsh/nsh_serial.c b/nuttx/examples/nsh/nsh_serial.c index 7716521ab..ad8ccad17 100644 --- a/nuttx/examples/nsh/nsh_serial.c +++ b/nuttx/examples/nsh/nsh_serial.c @@ -50,9 +50,6 @@ * Definitions ****************************************************************************/ -#define CONFIG_NSH_LINE_SIZE 80 -#undef CONFIG_FULL_PATH - /**************************************************************************** * Private Types ****************************************************************************/ @@ -74,7 +71,7 @@ struct cmdmap_s * Private Data ****************************************************************************/ -static char line[CONFIG_NSH_LINE_SIZE]; +static char line[CONFIG_EXAMPLES_NSH_LINELEN]; /**************************************************************************** * Public Data @@ -106,7 +103,7 @@ int nsh_serialmain(void) /* Get the next line of input */ - fgets(line, CONFIG_NSH_LINE_SIZE, stdin); + fgets(line, CONFIG_EXAMPLES_NSH_LINELEN, stdin); /* Parse process the command */ diff --git a/nuttx/examples/nsh/nsh_telnetd.c b/nuttx/examples/nsh/nsh_telnetd.c index 089a27faf..872390d5f 100644 --- a/nuttx/examples/nsh/nsh_telnetd.c +++ b/nuttx/examples/nsh/nsh_telnetd.c @@ -511,7 +511,7 @@ int nsh_telnetout(FAR void *handle, const char *fmt, ...) va_list ap; /* Put the new info into the buffer. Here we are counting on the fact that - * no output strings will exceed NSH_MAX_LINELEN! + * no output strings will exceed CONFIG_EXAMPLES_NSH_LINELEN! */ va_start(ap, fmt); @@ -542,7 +542,7 @@ int nsh_telnetout(FAR void *handle, const char *fmt, ...) * maximum length string. */ - if (nbytes > CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - NSH_MAX_LINELEN) + if (nbytes > CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - CONFIG_EXAMPLES_NSH_LINELEN) { nsh_flush(pstate); } |