diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html new file mode 100644 index 00000000000..6989688fc44 --- /dev/null +++ b/Documentation/NuttShell.html @@ -0,0 +1,1355 @@ + + +NuttX + + +

+ + + + +
+

NuttShell (NSH)

+

Last Updated: September 3, 2008

+
+

+ + + + +
+

Table of Contents

+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 1.0 Overview +

+ 1.1 Console/NSH Front End +

+ 1.2 Command Overview +

+ 1.3 Conditional Command Execution +

+ 1.4 Built-In Variables +

+ 1.5 Current Working Directory +

+ 1.6 Environment Variables +
+ 2.0 Commands. +

+ 2.1 Evaluate Expression (test) +

+ 2.2 Concatenate Files (cat) +

+ 2.3 Change Current Working Directory (cd) +

+ 2.4 Copy Files (cp) +

+ 2.5 Echo Strings and Variables (echo) +

+ 2.6 Execute User Code (exec) +

+ 2.7 Exit NSH (exit) +

+ 2.8 Show Usage Command Usage (help) +

+ 2.9 Show Network Configuration (ifconfig) +

+ 2.10 List Directory Contents (ls) +

+ 2.11 Access Memory (mb, mh, and mw) +

+ 2.12 Show Memory Manager Status (mem) +

+ 2.13 Show Current Tasks and Threads (ps) +

+ 2.14 Create a Directory (mkdir) +

+ 2.15 Create a FAT Filesystem (mkfatfs) +

+ 2.16 Create a FIFO (mkfifo) +

+ 2.17 Mount a File System (mount) +

+ 2.18 Check Network Peer (ping) +

+ 2.19 Show Current Working Directory (pwd) +

+ 2.20 Remove a File (rm) +

+ 2.21 Remove a Directory (rmdir) +

+ 2.22 Set an Environment Variable (set) +

+ 2.23 Execute an NSH Script (sh) +

+ 2.24 Wait for Seconds (sleep) +

+ 2.25 Unmount a File System (umount) +

+ 2.26 Unset an Environment Variable (unset) +

+ 2.27 Wait for Microseconds (usleep) +
+ 3.0 Configuration Settings +

+ 3.1 Command Dependencies on Configuration Settings +

+ 3.2 NSH-Specific Configuration Settings +
+
+ + + + + +
+

1.0 Overview

+
+ +

+ The examples/nsh sub-directory contains the NuttShell (NSH). + NSH is a simple shell application for NuttX. +

+ + + + + +
+

1.1 Console/NSH Front End

+
+ +

+ Using settings in the configuration file, NSH may be configured to + use either the serial stdin/out or a telnet connection as the console + or BOTH. When NSH is started, you will see the following welcome on + either console: +

+ nsh> is the NSH prompt and indicates that you may enter a command + from the console. +

+ + + + + +
+

1.2 Command Overview

+
+ +

+ Simple, Re-directed, and Background Commands. + The NuttShell (NSH) is a simple shell application. + NSH supports the following commands forms: +

+ +

Where:

+ +

+ nice'd Background Commands + NSH executes at the mid-priority (128). Backgrounded commands can + be made to execute at higher or lower priorities using nice: +

+ +

+ Where <niceness> is any value between -20 and 19 where lower + (more negative values) correspond to higher priorities. + The default niceness is 10. +

+ + + + + +
+

1.3 Conditional Command Execution

+
+ +

+ An if-then[-else]-fi construct is also supported in order to + support conditional execution of commands. This works from the + command line but is primarily intended for use within NSH scripts + (see the sh commnd). The syntax is as follows: +

+ + + + + + +
+

1.4 Built-In Variables

+
+ + + + + + + +
+

1.5 Current Working Directory

+
+ +

+ cd and pwd. + All path arguments to commands may be either an absolute path or a + path relative to the current working directory. The current working + directory is set using the 'cd' command and can be queried either + by using the pwd command or by + using the echo $PWD + command. +

+ + + + + +
+

1.6 Environment Variables

+
+ +

+ Environment Variables: +

+ + + + + + +
+

2.0 Commands

+
+ + + + + +
+

2.1 Evaluate Expression (test)

+
+ +

Command Syntax:

+ +

+ Synopsis. + These are two alternative forms of the same command. They support + evaluation of a boolean expression which sets $?. + This command is used most frequently as the conditional command following the + if in the if-then[-else]-fi construct. +

+

Expression Syntax:

+ + + + + + +
+

2.2 Concatenate Files (cat)

+
+ +Command Syntax:

+ +

+ Synopsis. + This command copies and concatentates all of the files at <path> + to the console (or to another file if the output is redirected). +

+ + + + + +
+

2.3 Change Current Working Directory (cd)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Changes the current working directory (PWD). Also sets the + previous working directory environment variable (OLDPWD). +

+

Forms:

+ + + + + + +
+

2.4 Copy Files (cp)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Copy of the contents of the file at <source-path< to the location + in the filesystem indicated by <path-path>. +

+ + + + + +
+

2.5 Echo Strings and Variables (echo)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Copy the sequence of strings and expanded environment variables to + console output (or to a file if the output is re-directed). +

+ + + + + +
+

2.6 Execute User Code (exec)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Execute the user logic at address <hex-address>. NSH will pause + until the execution unless the user logic is executed in background + via exec <hex-address> &. +

+ + + + + +
+

2.7 Exit NSH (exit)

+
+ +Command Syntax:

+ +

+ Synopsis. + Exit NSH. Only useful for the serial front end if you have started some other tasks (perhaps + using the exec command) and you would like to have NSH out of the + way. For the telnet front-end, exit terminates the telenet session. +

+ + + + + +
+

2.8 Show Usage Command Usage (help)

+
+ +Command Syntax:

+ +

+ Synopsis. + Presents summary information about each command to console. +

+ + + + + +
+

2.9 Show Network Configuration (ifconfig)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Show the current configuration of the network, for example: +

+ +

+ if uIP statistics are enabled (CONFIG_NET_STATISTICS), then + this command will also show the detailed state of uIP. +

+ + + + + +
+

2.10 List Directory Contents (ls)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Show the contents of the directory at <dir-path>. NOTE: + <dir-path> must refer to a directory and no other filesystem + object. +

+

Options:

+ + + + + + +
+

2.11 Access Memory (mb, mh, and mw)

+
+ +

Command Syntax:

+ +

+ Synopsis. + Access memory using byte size access (mb), 16-bit accesses (mh), + or 32-bit access (mw). In each case, +

+ +

Example:

+

+ + + + + +
+

2.12 Show Memory Manager Status (mem)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Show the current state of the memory allocator. For example, +

+ +

Where:

+ + + + + + +
+

2.13 Show Current Tasks and Threads (ps)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Show the currently active threads and tasks. For example, +

+ + + + + + +
+

2.14 Create a Directory (mkdir)

+
+ + + + + +
+

2.15 Create a FAT Filesystem (mkfatfs)

+
+ + + + + +
+

2.16 Create a FIFO (mkfifo)

+
+ + + + + +
+

2.17 Mount a File System (mount)

+
+ + + + + +
+

2.18 Check Network Peer (ping)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Test the network communication with a remote peer. Example, +

+ + + + + + +
+

2.19 Show Current Working Directory (pwd)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Show the current working directory. +

+ + +

Same as echo $PWD.

+ + + + + + +
+

2.20 Remove a File (rm)

+
+ + + + + +
+

2.21 Remove a Directory (rmdir)

+
+ + + + + +
+

2.22 Set an Environment Variable (set)

+
+ +Command Syntax:

+ +

+ Synopsis. + Set the environment variable <name> to the string <value>. + For example, +

+ + + + + + +
+

2.23 Execute an NSH Script (sh)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Execute the sequence of NSH commands in the file referred + to by <script-path>. +

+ + + + + +
+

2.24 Wait for Seconds (sleep)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Pause execution (sleep) for <sec> seconds. +

+ + + + + +
+

2.25 Unmount a File System (umount)

+
+ + + + + +
+

2.26 Unset an Environment Variable (unset)

+
+ +
Command Syntax:

+ +

+ Synopsis. + Remove the value associated with the environment variable + <name>. Example: +

+
    +nsh> echo $foobar
    +foovalue
    +nsh> unset foobar
    +nsh> echo $foobar
    +
    +nsh>
    +
+ + + + + +
+

2.27 Wait for Microseconds (usleep)

+
+ +
Command Syntax:

+
    +usleep <usec>
    +
+

+ Synopsis. + Pause execution (sleep) of <usec> microseconds. +

+ + + + + +
+

3.0 Configuration Settings

+
+ +

+ The availability of the above commands depends upon features that + may or may not be enabled in the NuttX configuration file. The + following table indicates the dependency of each command on NuttX + configuration settings. General configuration settings are discussed + in the NuttX Porting Guide. + Configuration settings specific to NSH as discussed at the bottom of this document. +

+ + + + + +
+

3.1 Command Dependencies on Configuration Settings

+
+ +

Table. Command Dependencies on Configuration Settings

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CommandDepends on Configuration
[!CONFIG_EXAMPLES_NSH_DISABLESCRIPT
catCONFIG_NFILE_DESCRIPTORS > 0
cd!CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
cpCONFIG_NFILE_DESCRIPTORS > 0
echo
exec
exit
help
ifconfigCONFIG_NET
lsCONFIG_NFILE_DESCRIPTORS > 0
mb,mh,mw
mem
mkdir!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
mkfatfs!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
mkfifo!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
mount!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
pingCONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_CLOCK && !CONFIG_DISABLE_SIGNALS
ps
pwd!CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
rm!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
rmdir!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
set!CONFIG_DISABLE_ENVIRON
shCONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !CONFIG_EXAMPLES_NSH_DISABLESCRIPT
sleep!CONFIG_DISABLE_SIGNALS
test!CONFIG_EXAMPLES_NSH_DISABLESCRIPT
umount!CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
unset!CONFIG_DISABLE_ENVIRON
usleep!CONFIG_DISABLE_SIGNALS
+ + + + + +
+

3.2 NSH-Specific Configuration Settings

+
+ +

+ The behavior of NSH can be modified with the following settings in + the configs/<board-name>/defconfig file: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription

CONFIG_EXAMPLES_NSH_FILEIOSIZE
+ Size of a static I/O buffer used for file access (ignored if + there is no filesystem). +

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 and of one output line. + Default: 80 +

CONFIG_EXAMPLES_NSH_STACKSIZE
+ The stack size to use when spawning new threads or tasks. Such + new threads are generated when a command is executed in background + or as new TELNET connections are established. +

CONFIG_EXAMPLES_NSH_NESTDEPTH
+ The maximum number of nested if-then[-else]-fi sequences that + are permissable. Default: 3 +

CONFIG_EXAMPLES_NSH_DISABLESCRIPT
+ This can be set to y to suppress support for scripting. This + setting disables the sh, test, and [ commands and the + if-then[-else]-fi construct. This would only be set on systems + where a minimal footprint is a necessity and scripting is not. +

CONFIG_EXAMPLES_NSH_DISABLEBG
+ This can be set to y to suppress support for background + commands. This setting disables the nice command prefix and + the & command suffix. This would only be set on systems + where a minimal footprint is a necessity and background command execution is not. +

CONFIG_EXAMPLES_NSH_CONSOLE
+ If CONFIG_EXAMPLES_NSH_CONSOLEis set to y, then a serial + console front-end is selected. +

CONFIG_EXAMPLES_NSH_TELNET
+ If CONFIG_EXAMPLES_NSH_TELNET is set to y, then a TELENET + server front-end is selected. When this option is provided, + you may log into NuttX remotely using telnet in order to + access NSH. +
+ +

+ One or both of CONFIG_EXAMPLES_NSH_CONSOLE and CONFIG_EXAMPLES_NSH_TELNET + must be defined. If CONFIG_EXAMPLES_NSH_TELNET is selected, then there some + other configuration settings that apply: +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationDescription

CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE
+ Determines the size of the I/O buffer to use for sending/ + receiving TELNET commands/reponses +

CONFIG_EXAMPLES_NSH_DHCPC
+ Obtain the the IP address via DHCP. +

CONFIG_EXAMPLES_NSH_IPADDR
+ If CONFIG_EXAMPLES_NSH_DHCPC is NOT set, then the static IP + address must be provided. +

CONFIG_EXAMPLES_NSH_DRIPADDR
+ Default router IP address +

CONFIG_EXAMPLES_NSH_NETMASK
+ Network mask +

CONFIG_EXAMPLES_NSH_NOMAC
+ Set if your ethernet hardware has no built-in MAC address. + If set, a bogus MAC will be assigned. +
+ + + + \ No newline at end of file diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 560107afda3..c49c488834b 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -100,7 +100,7 @@ - +
@@ -1115,6 +1115,10 @@ buildroot-0.1.1 2008-xx-xx <spudmonkey@racsa.co.cr> + + + +
Porting Guide
NuttShell (NSH)
Change Log